mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 14:22:46 +00:00
Fixing error exception handling for python3. Does not need to be compa… (#3840)
* Fixing error exception handling for python. Does not need to be compatible with Python2.4 b/c boto is Python 2.6 and above. * Fixing error exception handling for python. Does not need to be compatible with Python2.4 b/c boto is Python 2.6 and above. * Fixing compile time errors IRT error exception handling for Python 3.5. This does not need to be compatible with Python2.4 b/c Boto is Python 2.6 and above.
This commit is contained in:
@@ -262,7 +262,7 @@ def get_volume(module, ec2):
|
||||
volume_ids = [id]
|
||||
try:
|
||||
vols = ec2.get_all_volumes(volume_ids=volume_ids, filters=filters)
|
||||
except boto.exception.BotoServerError, e:
|
||||
except boto.exception.BotoServerError as e:
|
||||
module.fail_json(msg = "%s: %s" % (e.error_code, e.error_message))
|
||||
|
||||
if not vols:
|
||||
@@ -288,7 +288,7 @@ def get_volumes(module, ec2):
|
||||
vols = ec2.get_all_volumes()
|
||||
else:
|
||||
vols = ec2.get_all_volumes(filters={'attachment.instance-id': instance})
|
||||
except boto.exception.BotoServerError, e:
|
||||
except boto.exception.BotoServerError as e:
|
||||
module.fail_json(msg = "%s: %s" % (e.error_code, e.error_message))
|
||||
return vols
|
||||
|
||||
@@ -342,7 +342,7 @@ def create_volume(module, ec2, zone):
|
||||
|
||||
if name:
|
||||
ec2.create_tags([volume.id], {"Name": name})
|
||||
except boto.exception.BotoServerError, e:
|
||||
except boto.exception.BotoServerError as e:
|
||||
module.fail_json(msg = "%s: %s" % (e.error_code, e.error_message))
|
||||
|
||||
return volume, changed
|
||||
@@ -367,7 +367,7 @@ def attach_volume(module, ec2, volume, instance):
|
||||
device_name = '/dev/sdf'
|
||||
else:
|
||||
device_name = '/dev/xvdf'
|
||||
except boto.exception.BotoServerError, e:
|
||||
except boto.exception.BotoServerError as e:
|
||||
module.fail_json(msg = "%s: %s" % (e.error_code, e.error_message))
|
||||
|
||||
if volume.attachment_state() is not None:
|
||||
@@ -385,7 +385,7 @@ def attach_volume(module, ec2, volume, instance):
|
||||
time.sleep(3)
|
||||
volume.update()
|
||||
changed = True
|
||||
except boto.exception.BotoServerError, e:
|
||||
except boto.exception.BotoServerError as e:
|
||||
module.fail_json(msg = "%s: %s" % (e.error_code, e.error_message))
|
||||
|
||||
modify_dot_attribute(module, ec2, instance, device_name)
|
||||
@@ -402,7 +402,7 @@ def modify_dot_attribute(module, ec2, instance, device_name):
|
||||
try:
|
||||
instance.update()
|
||||
dot = instance.block_device_mapping[device_name].delete_on_termination
|
||||
except boto.exception.BotoServerError, e:
|
||||
except boto.exception.BotoServerError as e:
|
||||
module.fail_json(msg = "%s: %s" % (e.error_code, e.error_message))
|
||||
|
||||
if delete_on_termination != dot:
|
||||
@@ -417,7 +417,7 @@ def modify_dot_attribute(module, ec2, instance, device_name):
|
||||
time.sleep(3)
|
||||
instance.update()
|
||||
changed = True
|
||||
except boto.exception.BotoServerError, e:
|
||||
except boto.exception.BotoServerError as e:
|
||||
module.fail_json(msg = "%s: %s" % (e.error_code, e.error_message))
|
||||
|
||||
return changed
|
||||
@@ -522,7 +522,7 @@ def main():
|
||||
if region:
|
||||
try:
|
||||
ec2 = connect_to_aws(boto.ec2, region, **aws_connect_params)
|
||||
except (boto.exception.NoAuthHandlerFound, AnsibleAWSError), e:
|
||||
except (boto.exception.NoAuthHandlerFound, AnsibleAWSError) as e:
|
||||
module.fail_json(msg=str(e))
|
||||
else:
|
||||
module.fail_json(msg="region must be specified")
|
||||
|
||||
Reference in New Issue
Block a user