From 09c5f96b66b79d349e58be08c34639a74f62ec40 Mon Sep 17 00:00:00 2001 From: tomcz Date: Sun, 1 Jul 2012 23:25:50 -0700 Subject: [PATCH] cleaned up waits and script names --- .gitignore | 1 + aws.py | 15 +++++++++------ fabfile.py | 2 +- go | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index bd5f171..9a2ba78 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .DS_Store shell_* +ssh_* .idea *.swp *.pyc diff --git a/aws.py b/aws.py index e97d017..625c27b 100644 --- a/aws.py +++ b/aws.py @@ -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}) @@ -62,6 +57,7 @@ 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() @@ -69,3 +65,10 @@ def terminate_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() diff --git a/fabfile.py b/fabfile.py index 84186a9..b932b15 100644 --- a/fabfile.py +++ b/fabfile.py @@ -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) diff --git a/go b/go index 29ff32f..ce82ad1 100755 --- a/go +++ b/go @@ -25,7 +25,7 @@ fi if [ $# == 0 ]; then venv/bin/python venv/bin/fab --list echo "" - echo "OR ./run " + echo "OR ./go " echo "" elif [ -e $1 ]; then venv/bin/python $@