From 46a1f73778ee1cd9bf8698bcb7d7d62bde4da9c5 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Sun, 23 Oct 2016 12:36:17 -0700 Subject: [PATCH] Fix remaining centurylink modules for py3 Also update the imports to take advantage of the Ansiballz imports --- .../modules/extras/cloud/centurylink/clc_aa_policy.py | 9 ++++++--- .../modules/extras/cloud/centurylink/clc_group.py | 9 ++++++--- .../modules/extras/cloud/centurylink/clc_publicip.py | 9 ++++++--- .../extras/test/utils/shippable/sanity-skip-python3.txt | 3 --- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/lib/ansible/modules/extras/cloud/centurylink/clc_aa_policy.py b/lib/ansible/modules/extras/cloud/centurylink/clc_aa_policy.py index 681e71cb3a1..5ba0ac35b8f 100644 --- a/lib/ansible/modules/extras/cloud/centurylink/clc_aa_policy.py +++ b/lib/ansible/modules/extras/cloud/centurylink/clc_aa_policy.py @@ -131,6 +131,8 @@ policy: __version__ = '${version}' +import os + from distutils.version import LooseVersion try: @@ -153,6 +155,8 @@ except ImportError: else: CLC_FOUND = True +from ansible.module_utils.basic import AnsibleModule + class ClcAntiAffinityPolicy: @@ -267,7 +271,7 @@ class ClcAntiAffinityPolicy: return self.clc.v2.AntiAffinity.Create( name=p['name'], location=p['location']) - except CLCException, ex: + except CLCException as ex: self.module.fail_json(msg='Failed to create anti affinity policy : {0}. {1}'.format( p['name'], ex.response_text )) @@ -281,7 +285,7 @@ class ClcAntiAffinityPolicy: try: policy = self.policy_dict[p['name']] policy.Delete() - except CLCException, ex: + except CLCException as ex: self.module.fail_json(msg='Failed to delete anti affinity policy : {0}. {1}'.format( p['name'], ex.response_text )) @@ -346,6 +350,5 @@ def main(): clc_aa_policy = ClcAntiAffinityPolicy(module) clc_aa_policy.process_request() -from ansible.module_utils.basic import * # pylint: disable=W0614 if __name__ == '__main__': main() diff --git a/lib/ansible/modules/extras/cloud/centurylink/clc_group.py b/lib/ansible/modules/extras/cloud/centurylink/clc_group.py index 95da5234f11..07707f45f76 100644 --- a/lib/ansible/modules/extras/cloud/centurylink/clc_group.py +++ b/lib/ansible/modules/extras/cloud/centurylink/clc_group.py @@ -212,6 +212,7 @@ group: __version__ = '${version}' +import os from distutils.version import LooseVersion try: @@ -234,6 +235,8 @@ except ImportError: else: CLC_FOUND = True +from ansible.module_utils.basic import AnsibleModule + class ClcGroup(object): @@ -362,7 +365,7 @@ class ClcGroup(object): group, parent = self.group_dict.get(group_name) try: response = group.Delete() - except CLCException, ex: + except CLCException as ex: self.module.fail_json(msg='Failed to delete group :{0}. {1}'.format( group_name, ex.response_text )) @@ -423,7 +426,7 @@ class ClcGroup(object): (parent, grandparent) = self.group_dict[parent] try: response = parent.Create(name=group, description=description) - except CLCException, ex: + except CLCException as ex: self.module.fail_json(msg='Failed to create group :{0}. {1}'.format( group, ex.response_text)) return response @@ -508,6 +511,6 @@ def main(): clc_group = ClcGroup(module) clc_group.process_request() -from ansible.module_utils.basic import * # pylint: disable=W0614 + if __name__ == '__main__': main() diff --git a/lib/ansible/modules/extras/cloud/centurylink/clc_publicip.py b/lib/ansible/modules/extras/cloud/centurylink/clc_publicip.py index be75ae4c58c..10f84e56d37 100644 --- a/lib/ansible/modules/extras/cloud/centurylink/clc_publicip.py +++ b/lib/ansible/modules/extras/cloud/centurylink/clc_publicip.py @@ -124,6 +124,7 @@ server_ids: __version__ = '${version}' +import os from distutils.version import LooseVersion try: @@ -146,6 +147,8 @@ except ImportError: else: CLC_FOUND = True +from ansible.module_utils.basic import AnsibleModule + class ClcPublicIp(object): clc = clc_sdk @@ -241,7 +244,7 @@ class ClcPublicIp(object): result = None try: result = server.PublicIPs().Add(ports_to_expose) - except CLCException, ex: + except CLCException as ex: self.module.fail_json(msg='Failed to add public ip to the server : {0}. {1}'.format( server.id, ex.response_text )) @@ -278,7 +281,7 @@ class ClcPublicIp(object): try: for ip_address in server.PublicIPs().public_ips: result = ip_address.Delete() - except CLCException, ex: + except CLCException as ex: self.module.fail_json(msg='Failed to remove public ip from the server : {0}. {1}'.format( server.id, ex.response_text )) @@ -358,6 +361,6 @@ def main(): clc_public_ip = ClcPublicIp(module) clc_public_ip.process_request() -from ansible.module_utils.basic import * # pylint: disable=W0614 + if __name__ == '__main__': main() diff --git a/lib/ansible/modules/extras/test/utils/shippable/sanity-skip-python3.txt b/lib/ansible/modules/extras/test/utils/shippable/sanity-skip-python3.txt index bce8225ce85..9fba92376f2 100644 --- a/lib/ansible/modules/extras/test/utils/shippable/sanity-skip-python3.txt +++ b/lib/ansible/modules/extras/test/utils/shippable/sanity-skip-python3.txt @@ -28,9 +28,6 @@ /cloud/amazon/sqs_queue.py /cloud/amazon/sts_assume_role.py /cloud/amazon/sts_session_token.py -/cloud/centurylink/clc_aa_policy.py -/cloud/centurylink/clc_group.py -/cloud/centurylink/clc_publicip.py /cloud/misc/virt_net.py /cloud/misc/virt_pool.py /cloud/profitbricks/profitbricks.py