def _wait_for_image_state(self, ami, desired_state):
"""Timer to wait for the image/snapshot to reach a desired state
:params:ami_id: correspoding image id in Amazon
:params:desired_state: the desired new state of the image to be in.
"""
def _wait_for_state():
"""Called at an interval until the AMI image is available."""
try:
# LOG.info("\n\n\nImage id = %s" % ami_id + ", state = %s\n\n\n" % state)
image = self.driver.Image(ami.id)
if image.state == desired_state:
LOG.info("Image has changed state to %s." % desired_state)
raise loopingcall.LoopingCallDone()
else:
LOG.info("Image state %s." % image.state)
except BotoCoreError as e:
LOG.info("BotoCoreError: {}".format(e))
pass
timer = loopingcall.FixedIntervalLoopingCall(_wait_for_state)
timer.start(interval=3).wait()
评论列表
文章目录