Skip to content

Instantly share code, notes, and snippets.

@Burekasim
Created June 21, 2020 14:39
Show Gist options
  • Save Burekasim/a5219fbeefc76e84984c58a5fbdf8db9 to your computer and use it in GitHub Desktop.
Save Burekasim/a5219fbeefc76e84984c58a5fbdf8db9 to your computer and use it in GitHub Desktop.
debug with google
def tag_instance(instance: str, project: str, zone: str, creator_email: str):
instance_information = compute.instances().get(project=project, zone=zone, instance=instance).execute()
print(instance_information)
instance_disks_list = [disk['deviceName'] for disk in instance_information['disks']]
instance_fingerprint = instance_information['fingerprint']
print(instance_fingerprint)
instance_labels = {'labels': {'createdby': '123'}, 'labelFingerprint': instance_fingerprint}
print(instance_labels)
request = compute.instances().setLabels(project=project, zone=zone, instance=instance, body=instance_labels)
try:
print(request.execute())
return {'status': True, 'instance_disks_list': instance_disks_list}
except Exception as e:
print(str(e))
return {'status': False, instance_disks_list: []}
print(tag_instance('instance-8', 'avik-playground', 'us-east1-b', 'avik_doit'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment