ec2_ami_copy.py 文件源码

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

项目:DevOps 作者: YoLoveLife 项目源码 文件源码
def wait_until_image_is_recognized(module, ec2, wait_timeout, image_id, wait):
    for i in range(wait_timeout):
        try:
            return ec2.get_image(image_id)
        except boto.exception.EC2ResponseError as e:
            # This exception we expect initially right after registering the copy with EC2 API
            if 'InvalidAMIID.NotFound' in e.error_code and wait:
                time.sleep(1)
            else:
                # On any other exception we should fail
                module.fail_json(
                    msg="Error while trying to find the new image. Using wait=yes and/or a longer wait_timeout may help: " + str(
                        e))
    else:
        module.fail_json(msg="timed out waiting for image to be recognized")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号