Aparna & Cameron | Added a try & except in the wait_for_image_state(), cos on snapshot, the image may not be ready to be queried rightaway
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
"""Connection to the Amazon Web Services - EC2 service"""
|
"""Connection to the Amazon Web Services - EC2 service"""
|
||||||
from boto import ec2
|
from boto import ec2
|
||||||
|
from boto import exception as boto_exc
|
||||||
from ec2driver_config import *
|
from ec2driver_config import *
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
@@ -167,11 +168,11 @@ class EC2Driver(driver.ComputeDriver):
|
|||||||
if desired_state == 'running':
|
if desired_state == 'running':
|
||||||
timer = loopingcall.FixedIntervalLoopingCall(_wait_for_status_check)
|
timer = loopingcall.FixedIntervalLoopingCall(_wait_for_status_check)
|
||||||
timer.start(interval=0.5).wait()
|
timer.start(interval=0.5).wait()
|
||||||
|
|
||||||
def _wait_for_image_state(self, ami_id, desired_state):
|
def _wait_for_image_state(self, ami_id, desired_state):
|
||||||
# Timer to wait for the iamge to reach a state
|
# Timer to wait for the iamge to reach a state
|
||||||
def _wait_for_state():
|
def _wait_for_state():
|
||||||
"""Called at an interval until the AMI image is available."""
|
"""Called at an interval until the AMI image is available."""
|
||||||
|
try:
|
||||||
images = self.ec2_conn.get_all_images(image_ids=[ami_id], owners=None,
|
images = self.ec2_conn.get_all_images(image_ids=[ami_id], owners=None,
|
||||||
executable_by=None, filters=None, dry_run=None)
|
executable_by=None, filters=None, dry_run=None)
|
||||||
state = images[0].state
|
state = images[0].state
|
||||||
@@ -179,6 +180,9 @@ class EC2Driver(driver.ComputeDriver):
|
|||||||
if state == desired_state:
|
if state == desired_state:
|
||||||
LOG.info("Image has changed state to %s." % desired_state)
|
LOG.info("Image has changed state to %s." % desired_state)
|
||||||
raise loopingcall.LoopingCallDone()
|
raise loopingcall.LoopingCallDone()
|
||||||
|
except boto_exc.EC2ResponseError:
|
||||||
|
LOG.info("************** EC2ResponseError thrown!!! *****************************")
|
||||||
|
pass
|
||||||
|
|
||||||
timer = loopingcall.FixedIntervalLoopingCall(_wait_for_state)
|
timer = loopingcall.FixedIntervalLoopingCall(_wait_for_state)
|
||||||
timer.start(interval=0.5).wait()
|
timer.start(interval=0.5).wait()
|
||||||
|
|||||||
Reference in New Issue
Block a user