Fix remaining centurylink modules for py3

Also update the imports to take advantage of the Ansiballz imports
This commit is contained in:
Toshio Kuratomi 2016-10-23 12:36:17 -07:00 committed by Matt Clay
parent 8fb4fd6736
commit 46a1f73778
4 changed files with 18 additions and 12 deletions

View file

@ -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()

View file

@ -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()

View file

@ -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()

View file

@ -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