Created
June 21, 2020 14:39
-
-
Save Burekasim/a5219fbeefc76e84984c58a5fbdf8db9 to your computer and use it in GitHub Desktop.
debug with google
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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