Port module_utils/ec2.py to python 3 syntax (#15879)

Since boto is considered as python 2.6 only (cf
https://github.com/ansible/ansible/blob/devel/test/utils/run_tests.sh#L15 ),
no need to use the 2.4 compatible syntax.
This commit is contained in:
Michael Scherer 2016-05-16 14:44:51 +02:00 committed by Brian Coca
parent eb52dc9af0
commit 10edaabed5

View file

@ -226,13 +226,13 @@ def ec2_connect(module):
if region: if region:
try: try:
ec2 = connect_to_aws(boto.ec2, region, **boto_params) ec2 = connect_to_aws(boto.ec2, region, **boto_params)
except (boto.exception.NoAuthHandlerFound, AnsibleAWSError), e: except (boto.exception.NoAuthHandlerFound, AnsibleAWSError) as e:
module.fail_json(msg=str(e)) module.fail_json(msg=str(e))
# Otherwise, no region so we fallback to the old connection method # Otherwise, no region so we fallback to the old connection method
elif ec2_url: elif ec2_url:
try: try:
ec2 = boto.connect_ec2_endpoint(ec2_url, **boto_params) ec2 = boto.connect_ec2_endpoint(ec2_url, **boto_params)
except (boto.exception.NoAuthHandlerFound, AnsibleAWSError), e: except (boto.exception.NoAuthHandlerFound, AnsibleAWSError) as e:
module.fail_json(msg=str(e)) module.fail_json(msg=str(e))
else: else:
module.fail_json(msg="Either region or ec2_url must be specified") module.fail_json(msg="Either region or ec2_url must be specified")