forked from compiler-explorer/infra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_instances.py
executable file
·26 lines (22 loc) · 993 Bytes
/
update_instances.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python
import boto.ec2
from boto.manage.cmdshell import sshclient_from_instance
def update_gcc_explorers():
conn = boto.ec2.connect_to_region('us-east-1')
reservations = conn.get_all_instances()
for reservation in reservations:
for instance in reservation.instances:
if instance.state != 'running':
print "Skipping {} instance {}".format(instance.state, instance.id)
continue
print "Connecting to", instance
ssh_client = sshclient_from_instance(instance, "ec2-mattgodbolt.pem",
user_name='ubuntu')
print "Connected. Running command"
status, stdout, stderr = ssh_client.run('sudo -i docker pull mattgodbolt/gcc-explorer && sudo service gcc-explorer restart')
print "Status", status
print "Stdout", stdout
print "Stderr", stderr
print "Done"
if __name__ == '__main__':
update_gcc_explorers()