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