Wait until AMI is available
authorRail Aliiev <rail@mozilla.com>
Mon, 16 Jun 2014 23:51:45 -0400
changeset 446 c1f0610790267f019f71afa17d7ab5ca2ab10d3f
parent 445 fa0238f4759342061888d651824b996d5794ca3b
child 447 af23152dc50d1cd381d635840d1242cabf151e4d
push id441
push userraliiev@mozilla.com
push dateTue, 17 Jun 2014 03:51:50 +0000
Wait until AMI is available
cloudtools/aws/ami.py
--- a/cloudtools/aws/ami.py
+++ b/cloudtools/aws/ami.py
@@ -85,22 +85,22 @@ def copy_ami(source_ami, region_to_copy)
         try:
             new_ami = conn.get_image(ami_copy.image_id)
             for tag, value in source_ami.tags.iteritems():
                 new_ami.add_tag(tag, value)
             new_ami.update()
             log.info('AMI created')
             log.info('ID: {id}, name: {name}'.format(id=new_ami.id,
                                                      name=new_ami.name))
-            return new_ami
+            break
         except:
             log.info('Wating for AMI')
             time.sleep(10)
-        else:
-            return new_ami
+    wait_for_status(new_ami, "state", "available", "update")
+    return new_ami
 
 
 def get_spot_amis(region, tags, name_glob="spot-*"):
     conn = get_aws_connection(region)
     filters = {}
     for tag, value in tags.iteritems():
         filters["tag:%s" % tag] = value
     # override Name tag