python - snapshot.wait_until_completed 不显示进度也不显示完成时间

标签 python boto3

我有一个小函数负责创建快照,它工作正常;但我也想获得进度,但以下功能对我没有帮助:

def call_creater():
    regions = ['eu-central-1']
    for region in regions:
        ec2 = boto3.resource('ec2', region, aws_access_key_id=ACCESS_KEY, aws_secret_access_key=SECRET_KEY, )
        snapshot = ec2.create_snapshot(VolumeId='vol-f9e7d220', Description='fra01-he-trial-ansible01')
        print snapshot.id

        get_all_snapshots = ec2.snapshots.filter(snap_id=['SnapshotIds'])
        print get_all_snapshots
        #snapshot.wait_until_completed()
        print "STARTING TO CREATE :"
        time.sleep(10)
        snapshot.wait_until_completed(
            Filters=[
                {
                    'Name': 'progress'
                }
                ]
        )
        print "snapshot ready"

这会抛出:

    'Name': 'progress'
  File "C:\Python27\lib\site-packages\boto3\resources\factory.py", line 368, in do_waiter
    waiter(self, *args, **kwargs)
  File "C:\Python27\lib\site-packages\boto3\resources\action.py", line 201, in __call__
    response = waiter.wait(**params)
  File "C:\Python27\lib\site-packages\botocore\waiter.py", line 53, in wait
    Waiter.wait(self, **kwargs)
  File "C:\Python27\lib\site-packages\botocore\waiter.py", line 321, in wait
    reason='Max attempts exceeded')
botocore.exceptions.WaiterError: Waiter SnapshotCompleted failed: Max attempts exceeded

虽然快照已创建,但我无法获取状态

最佳答案

wait_until_completed should wait for a maximum of about 10 minutes ,这对于大快照来说还远远不够,并且 reportedly it's returning faster even than that 。由于此功能似乎已损坏,我建议您编写自己的服务员。

关于python - snapshot.wait_until_completed 不显示进度也不显示完成时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38218141/

相关文章:

python - 使用 xml.dom.minidom 中的 getElementsByTagName

php - 通过python更新文件时运行php脚本

python - boto3 s3 对象过期 "MalformedXML"错误

amazon-web-services - 获取所有给定前缀的s3存储桶

python - 如何通过 Boto3 将文件上传到 S3 中的特定文件夹

python - 使用 python 脚本和 boto3 创建 MSK 主题

python - 对于 x in y() : how does this work?

python - python 中上升最快的阶乘(Pochhammer 函数)

python - AWS SES 将自定义 header 添加到邮件中

python - 共享主机上带有 FastCGI 的 CherryPy(或其他 Python 框架)