我有一个小功能,负责创建快照,它工作正常;但我也希望得到进展,但以下功能对我没有帮助:
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
虽然快照已创建,但我无法获得状态
答案 0 :(得分:3)
wait_until_completed
should wait for a maximum of about 10 minutes,远远不足以拍摄大快照,reportedly it's returning faster even than that。由于这个功能似乎被破坏了,我建议你自己写一个服务员。