Fix amazon extras modules to compile under python3

This commit is contained in:
Toshio Kuratomi 2016-10-23 13:41:03 -07:00 committed by Matt Clay
commit 3901fe72d3
31 changed files with 192 additions and 190 deletions

View file

@ -175,6 +175,8 @@ ansible_facts:
returned: when service existed and was deleted
type: complex
'''
import time
try:
import boto
import botocore
@ -188,6 +190,10 @@ try:
except ImportError:
HAS_BOTO3 = False
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.ec2 import boto3_conn, ec2_argument_spec, get_aws_connection_info
class EcsServiceManager:
"""Handles ECS Services"""
@ -200,8 +206,8 @@ class EcsServiceManager:
if not region:
module.fail_json(msg="Region must be specified as a parameter, in EC2_REGION or AWS_REGION environment variables or in boto configuration file")
self.ecs = boto3_conn(module, conn_type='client', resource='ecs', region=region, endpoint=ec2_url, **aws_connect_kwargs)
except boto.exception.NoAuthHandlerFound, e:
self.module.fail_json(msg="Can't authorize connection - "+str(e))
except boto.exception.NoAuthHandlerFound as e:
self.module.fail_json(msg="Can't authorize connection - %s" % str(e))
# def list_clusters(self):
# return self.client.list_clusters()
@ -321,7 +327,7 @@ def main():
service_mgr = EcsServiceManager(module)
try:
existing = service_mgr.describe_service(module.params['cluster'], module.params['name'])
except Exception, e:
except Exception as e:
module.fail_json(msg="Exception describing service '"+module.params['name']+"' in cluster '"+module.params['cluster']+"': "+str(e))
results = dict(changed=False )
@ -392,7 +398,7 @@ def main():
module.params['name'],
module.params['cluster']
)
except botocore.exceptions.ClientError, e:
except botocore.exceptions.ClientError as e:
module.fail_json(msg=e.message)
results['changed'] = True
@ -418,9 +424,6 @@ def main():
module.exit_json(**results)
# import module snippets
from ansible.module_utils.basic import *
from ansible.module_utils.ec2 import *
if __name__ == '__main__':
main()