Skip to content

Instantly share code, notes, and snippets.

@Burekasim
Created June 21, 2020 14:39
Show Gist options
  • Save Burekasim/7c70f3badab7e2192c2ccdd067cda81b to your computer and use it in GitHub Desktop.
Save Burekasim/7c70f3badab7e2192c2ccdd067cda81b 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