fedimg: Checkin the patch for PR#100. Check if the AMI is complete before proceeding
Signed-off-by: Sayan Chowdhury <sayan.chowdhury2012@gmail.com>
This commit is contained in:
parent
6752f195d9
commit
ad950dbcc3
1 changed files with 18 additions and 0 deletions
|
@ -90,6 +90,22 @@ class EC2ImagePublisher(EC2Base):
|
|||
|
||||
return is_snapshot_public
|
||||
|
||||
def _retry_till_image_is_available(self, image_id):
|
||||
driver = self._connect()
|
||||
|
||||
while True:
|
||||
try:
|
||||
image = driver.get_image(image_id)
|
||||
image_name = image.name
|
||||
if image_name is None:
|
||||
continue
|
||||
return image
|
||||
except Exception as e:
|
||||
if 'InvalidAMIID.Unavailable' in str(e):
|
||||
# The copy isn't completed yet, so wait for 20 seconds
|
||||
# more.
|
||||
sleep(20)
|
||||
continue
|
||||
|
||||
def _retry_till_snapshot_is_available(self, image):
|
||||
|
||||
|
@ -255,6 +271,8 @@ class EC2ImagePublisher(EC2Base):
|
|||
name=self.image_name,
|
||||
description=self.image_description)
|
||||
|
||||
copied_image = self._retry_till_image_is_available(copied_image.id)
|
||||
|
||||
virt_type = image.extra['virtualization_type']
|
||||
volume_type = image.extra['block_device_mapping'][0]['ebs']['volume_type']
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue