Few more places where gce modules need python3 compat exceptions

This commit is contained in:
Toshio Kuratomi 2016-10-15 10:16:22 -07:00 committed by Matt Clay
parent 7ba630eda2
commit f77aa869b8
2 changed files with 13 additions and 17 deletions

View file

@ -111,7 +111,6 @@ EXAMPLES = '''
state: absent
'''
import sys
try:
import libcloud
@ -125,6 +124,9 @@ try:
except ImportError:
has_libcloud = False
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.gce import gce_connect
GCS_URI = 'https://storage.googleapis.com/'
@ -152,7 +154,7 @@ def create_image(gce, name, module):
except ResourceNotFoundError:
module.fail_json(msg='Disk %s not found in zone %s' % (source, zone),
changed=False)
except GoogleBaseError, e:
except GoogleBaseError as e:
module.fail_json(msg=str(e), changed=False)
gce_extra_args = {}
@ -166,8 +168,7 @@ def create_image(gce, name, module):
return True
except ResourceExistsError:
return False
except GoogleBaseError:
e = get_exception()
except GoogleBaseError as e:
module.fail_json(msg=str(e), changed=False)
finally:
gce.connection.timeout = old_timeout
@ -180,7 +181,7 @@ def delete_image(gce, name, module):
return True
except ResourceNotFoundError:
return False
except GoogleBaseError, e:
except GoogleBaseError as e:
module.fail_json(msg=str(e), changed=False)
@ -224,8 +225,5 @@ def main():
module.exit_json(changed=changed, name=name)
# import module snippets
from ansible.module_utils.basic import *
from ansible.module_utils.gce import *
main()
if __name__ == '__main__':
main()

View file

@ -100,6 +100,9 @@ try:
except ImportError:
HAS_LIBCLOUD = False
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.gce import gce_connect
def add_tags(gce, module, instance_name, tags):
"""Add tags to instance."""
@ -117,7 +120,7 @@ def add_tags(gce, module, instance_name, tags):
node = gce.ex_get_node(instance_name, zone=zone)
except ResourceNotFoundError:
module.fail_json(msg='Instance %s not found in zone %s' % (instance_name, zone), changed=False)
except GoogleBaseError, e:
except GoogleBaseError as e:
module.fail_json(msg=str(e), changed=False)
node_tags = node.extra['tags']
@ -156,8 +159,7 @@ def remove_tags(gce, module, instance_name, tags):
node = gce.ex_get_node(instance_name, zone=zone)
except ResourceNotFoundError:
module.fail_json(msg='Instance %s not found in zone %s' % (instance_name, zone), changed=False)
except GoogleBaseError:
e = get_exception()
except GoogleBaseError as e:
module.fail_json(msg=str(e), changed=False)
node_tags = node.extra['tags']
@ -221,10 +223,6 @@ def main():
module.exit_json(changed=changed, instance_name=instance_name, tags=tags_changed, zone=zone)
# import module snippets
from ansible.module_utils.basic import *
from ansible.module_utils.gce import *
if __name__ == '__main__':
main()