Fix remaining python3 compile problems

This commit is contained in:
Toshio Kuratomi
2016-10-23 16:24:38 -07:00
committed by Matt Clay
parent 3901fe72d3
commit ea05c56a41
19 changed files with 279 additions and 196 deletions

View File

@@ -18,16 +18,6 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
try:
import json
except ImportError:
try:
import simplejson as json
except ImportError:
# Let snippet from module_utils/basic.py return a proper error in this case
pass
import urllib
DOCUMENTATION = '''
---
module: cloudflare_dns
@@ -269,6 +259,22 @@ record:
sample: sample.com
'''
try:
import json
except ImportError:
try:
import simplejson as json
except ImportError:
# Let snippet from module_utils/basic.py return a proper error in this case
pass
import urllib
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.pycompat24 import get_exception
from ansible.module_utils.urls import fetch_url
class CloudflareAPI(object):
cf_api_endpoint = 'https://api.cloudflare.com/client/v4'
@@ -315,8 +321,9 @@ class CloudflareAPI(object):
if payload:
try:
data = json.dumps(payload)
except Exception, e:
self.module.fail_json(msg="Failed to encode payload as JSON: {0}".format(e))
except Exception:
e = get_exception()
self.module.fail_json(msg="Failed to encode payload as JSON: %s " % str(e))
resp, info = fetch_url(self.module,
self.cf_api_endpoint + api_call,
@@ -636,9 +643,6 @@ def main():
changed = cf_api.delete_dns_records(solo=False)
module.exit_json(changed=changed)
# import module snippets
from ansible.module_utils.basic import *
from ansible.module_utils.urls import *
if __name__ == '__main__':
main()

View File

@@ -86,6 +86,10 @@ except ImportError:
else:
bigsuds_found = True
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.pycompat24 import get_exception
from ansible.module_utils.f5 import bigip_api, f5_argument_spec
def server_exists(api, server):
# hack to determine if virtual server exists
@@ -93,7 +97,8 @@ def server_exists(api, server):
try:
api.GlobalLB.Server.get_object_status([server])
result = True
except bigsuds.OperationFailed, e:
except bigsuds.OperationFailed:
e = get_exception()
if "was not found" in str(e):
result = False
else:
@@ -109,7 +114,8 @@ def virtual_server_exists(api, name, server):
virtual_server_id = {'name': name, 'server': server}
api.GlobalLB.VirtualServerV2.get_object_status([virtual_server_id])
result = True
except bigsuds.OperationFailed, e:
except bigsuds.OperationFailed:
e = get_exception()
if "was not found" in str(e):
result = False
else:
@@ -222,14 +228,12 @@ def main():
else:
result = {'changed': True}
except Exception, e:
except Exception:
e = get_exception()
module.fail_json(msg="received exception: %s" % e)
module.exit_json(**result)
# import module snippets
from ansible.module_utils.basic import *
from ansible.module_utils.f5 import *
if __name__ == '__main__':
main()

View File

@@ -71,6 +71,11 @@ except ImportError:
else:
bigsuds_found = True
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.pycompat24 import get_exception
from ansible.module_utils.f5 import bigip_api, f5_argument_spec
def get_wide_ip_lb_method(api, wide_ip):
lb_method = api.GlobalLB.WideIP.get_lb_method(wide_ips=[wide_ip])[0]
lb_method = lb_method.strip().replace('LB_METHOD_', '').lower()
@@ -79,8 +84,9 @@ def get_wide_ip_lb_method(api, wide_ip):
def get_wide_ip_pools(api, wide_ip):
try:
return api.GlobalLB.WideIP.get_wideip_pool([wide_ip])
except Exception, e:
print e
except Exception:
e = get_exception()
print(e)
def wide_ip_exists(api, wide_ip):
# hack to determine if wide_ip exists
@@ -88,7 +94,8 @@ def wide_ip_exists(api, wide_ip):
try:
api.GlobalLB.WideIP.get_object_status(wide_ips=[wide_ip])
result = True
except bigsuds.OperationFailed, e:
except bigsuds.OperationFailed:
e = get_exception()
if "was not found" in str(e):
result = False
else:
@@ -145,14 +152,12 @@ def main():
else:
result = {'changed': True}
except Exception, e:
except Exception:
e = get_exception()
module.fail_json(msg="received exception: %s" % e)
module.exit_json(**result)
# import module snippets
from ansible.module_utils.basic import *
from ansible.module_utils.f5 import *
if __name__ == '__main__':
main()