Fix remaining centurylink modules for py3
Also update the imports to take advantage of the Ansiballz imports
This commit is contained in:
parent
8fb4fd6736
commit
46a1f73778
4 changed files with 18 additions and 12 deletions
|
@ -131,6 +131,8 @@ policy:
|
||||||
|
|
||||||
__version__ = '${version}'
|
__version__ = '${version}'
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
from distutils.version import LooseVersion
|
from distutils.version import LooseVersion
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -153,6 +155,8 @@ except ImportError:
|
||||||
else:
|
else:
|
||||||
CLC_FOUND = True
|
CLC_FOUND = True
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
|
|
||||||
class ClcAntiAffinityPolicy:
|
class ClcAntiAffinityPolicy:
|
||||||
|
|
||||||
|
@ -267,7 +271,7 @@ class ClcAntiAffinityPolicy:
|
||||||
return self.clc.v2.AntiAffinity.Create(
|
return self.clc.v2.AntiAffinity.Create(
|
||||||
name=p['name'],
|
name=p['name'],
|
||||||
location=p['location'])
|
location=p['location'])
|
||||||
except CLCException, ex:
|
except CLCException as ex:
|
||||||
self.module.fail_json(msg='Failed to create anti affinity policy : {0}. {1}'.format(
|
self.module.fail_json(msg='Failed to create anti affinity policy : {0}. {1}'.format(
|
||||||
p['name'], ex.response_text
|
p['name'], ex.response_text
|
||||||
))
|
))
|
||||||
|
@ -281,7 +285,7 @@ class ClcAntiAffinityPolicy:
|
||||||
try:
|
try:
|
||||||
policy = self.policy_dict[p['name']]
|
policy = self.policy_dict[p['name']]
|
||||||
policy.Delete()
|
policy.Delete()
|
||||||
except CLCException, ex:
|
except CLCException as ex:
|
||||||
self.module.fail_json(msg='Failed to delete anti affinity policy : {0}. {1}'.format(
|
self.module.fail_json(msg='Failed to delete anti affinity policy : {0}. {1}'.format(
|
||||||
p['name'], ex.response_text
|
p['name'], ex.response_text
|
||||||
))
|
))
|
||||||
|
@ -346,6 +350,5 @@ def main():
|
||||||
clc_aa_policy = ClcAntiAffinityPolicy(module)
|
clc_aa_policy = ClcAntiAffinityPolicy(module)
|
||||||
clc_aa_policy.process_request()
|
clc_aa_policy.process_request()
|
||||||
|
|
||||||
from ansible.module_utils.basic import * # pylint: disable=W0614
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -212,6 +212,7 @@ group:
|
||||||
|
|
||||||
__version__ = '${version}'
|
__version__ = '${version}'
|
||||||
|
|
||||||
|
import os
|
||||||
from distutils.version import LooseVersion
|
from distutils.version import LooseVersion
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -234,6 +235,8 @@ except ImportError:
|
||||||
else:
|
else:
|
||||||
CLC_FOUND = True
|
CLC_FOUND = True
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
|
|
||||||
class ClcGroup(object):
|
class ClcGroup(object):
|
||||||
|
|
||||||
|
@ -362,7 +365,7 @@ class ClcGroup(object):
|
||||||
group, parent = self.group_dict.get(group_name)
|
group, parent = self.group_dict.get(group_name)
|
||||||
try:
|
try:
|
||||||
response = group.Delete()
|
response = group.Delete()
|
||||||
except CLCException, ex:
|
except CLCException as ex:
|
||||||
self.module.fail_json(msg='Failed to delete group :{0}. {1}'.format(
|
self.module.fail_json(msg='Failed to delete group :{0}. {1}'.format(
|
||||||
group_name, ex.response_text
|
group_name, ex.response_text
|
||||||
))
|
))
|
||||||
|
@ -423,7 +426,7 @@ class ClcGroup(object):
|
||||||
(parent, grandparent) = self.group_dict[parent]
|
(parent, grandparent) = self.group_dict[parent]
|
||||||
try:
|
try:
|
||||||
response = parent.Create(name=group, description=description)
|
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(
|
self.module.fail_json(msg='Failed to create group :{0}. {1}'.format(
|
||||||
group, ex.response_text))
|
group, ex.response_text))
|
||||||
return response
|
return response
|
||||||
|
@ -508,6 +511,6 @@ def main():
|
||||||
clc_group = ClcGroup(module)
|
clc_group = ClcGroup(module)
|
||||||
clc_group.process_request()
|
clc_group.process_request()
|
||||||
|
|
||||||
from ansible.module_utils.basic import * # pylint: disable=W0614
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -124,6 +124,7 @@ server_ids:
|
||||||
|
|
||||||
__version__ = '${version}'
|
__version__ = '${version}'
|
||||||
|
|
||||||
|
import os
|
||||||
from distutils.version import LooseVersion
|
from distutils.version import LooseVersion
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -146,6 +147,8 @@ except ImportError:
|
||||||
else:
|
else:
|
||||||
CLC_FOUND = True
|
CLC_FOUND = True
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
|
|
||||||
class ClcPublicIp(object):
|
class ClcPublicIp(object):
|
||||||
clc = clc_sdk
|
clc = clc_sdk
|
||||||
|
@ -241,7 +244,7 @@ class ClcPublicIp(object):
|
||||||
result = None
|
result = None
|
||||||
try:
|
try:
|
||||||
result = server.PublicIPs().Add(ports_to_expose)
|
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(
|
self.module.fail_json(msg='Failed to add public ip to the server : {0}. {1}'.format(
|
||||||
server.id, ex.response_text
|
server.id, ex.response_text
|
||||||
))
|
))
|
||||||
|
@ -278,7 +281,7 @@ class ClcPublicIp(object):
|
||||||
try:
|
try:
|
||||||
for ip_address in server.PublicIPs().public_ips:
|
for ip_address in server.PublicIPs().public_ips:
|
||||||
result = ip_address.Delete()
|
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(
|
self.module.fail_json(msg='Failed to remove public ip from the server : {0}. {1}'.format(
|
||||||
server.id, ex.response_text
|
server.id, ex.response_text
|
||||||
))
|
))
|
||||||
|
@ -358,6 +361,6 @@ def main():
|
||||||
clc_public_ip = ClcPublicIp(module)
|
clc_public_ip = ClcPublicIp(module)
|
||||||
clc_public_ip.process_request()
|
clc_public_ip.process_request()
|
||||||
|
|
||||||
from ansible.module_utils.basic import * # pylint: disable=W0614
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -28,9 +28,6 @@
|
||||||
/cloud/amazon/sqs_queue.py
|
/cloud/amazon/sqs_queue.py
|
||||||
/cloud/amazon/sts_assume_role.py
|
/cloud/amazon/sts_assume_role.py
|
||||||
/cloud/amazon/sts_session_token.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_net.py
|
||||||
/cloud/misc/virt_pool.py
|
/cloud/misc/virt_pool.py
|
||||||
/cloud/profitbricks/profitbricks.py
|
/cloud/profitbricks/profitbricks.py
|
||||||
|
|
Loading…
Reference in a new issue