def wait_operation(operation):
# NOT thread safe
credentials = GoogleCredentials.get_application_default()
compute = discovery.build('compute', 'v1', credentials=credentials)
# Wait for confirmation that the instance is created
while True:
result = compute.zoneOperations().get(
project=project,
zone=zone,
operation=operation['name']).execute()
if result['status'] == 'DONE':
return False if ('error' in result) else True
sys.stdout.write(".")
sys.stdout.flush()
time.sleep(2)
# [END wait_operation]
# [START list_instances]
评论列表
文章目录