def list_instances(client_cert_file, client_email, project, zone):
with open(client_cert_file) as f:
private_key = f.read()
credentials = SignedJwtAssertionCredentials(client_email, private_key,
'https://www.googleapis.com/auth/compute.readonly')
http = Http()
credentials.authorize(http)
try:
compute = build('compute', 'v1', http=http)
resp_json = compute.instances().list(project=project, zone=zone).execute()
except HttpError:
raise GoogleClientError('Failed to make "list instances" Google cloud API request')
return resp_json
评论列表
文章目录