provider.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:kozinaki 作者: compunova 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号