Skip to content

Commit

Permalink
cleaned up waits and script names
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcz committed Jul 2, 2012
1 parent da38f6b commit 09c5f96
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,5 +1,6 @@
.DS_Store
shell_*
ssh_*
.idea
*.swp
*.pyc
Expand Down
15 changes: 9 additions & 6 deletions aws.py
Expand Up @@ -28,12 +28,7 @@ def provision_with_boto(name):
instance = res.instances[0]

print "Waiting for", name, instance.id, "to start ..."
time.sleep(5)
instance.update()

while instance.state != 'running':
time.sleep(5)
instance.update()
wait_while(instance, 'pending')

conn.create_tags([instance.id], {'Name': name})

Expand Down Expand Up @@ -62,10 +57,18 @@ def terminate_instance(name):
for instance in reservation.instances:
print 'Terminating instance', instance.id
instance.terminate()
wait_while(instance, 'running')

def terminate_all_instances():
conn = connect()
for reservation in conn.get_all_instances():
for instance in reservation.instances:
print 'Terminating instance', instance.id
instance.terminate()
wait_while(instance, 'running')

def wait_while(instance, status):
instance.update()
while instance.state == status:
time.sleep(5)
instance.update()
2 changes: 1 addition & 1 deletion fabfile.py
Expand Up @@ -39,7 +39,7 @@ def start(node_name):
node = aws.provision_with_boto(node_name)
wait_for_ssh_connection(node)

filename = 'shell_' + node_name
filename = 'ssh_' + node_name
command = "ssh -i %s -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no %s@%s\n"
command = command % (node.ssh_key_file, node.ssh_user, node.hostname)

Expand Down
2 changes: 1 addition & 1 deletion go
Expand Up @@ -25,7 +25,7 @@ fi
if [ $# == 0 ]; then
venv/bin/python venv/bin/fab --list
echo ""
echo "OR ./run <any local python script>"
echo "OR ./go <any local python script>"
echo ""
elif [ -e $1 ]; then
venv/bin/python $@
Expand Down

0 comments on commit 09c5f96

Please sign in to comment.