mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-09 17:59:09 -07:00
Port the module snippet to python3 (#15870)
vca depend on pyvcloud, who depend on PyYAML 3.10, which support python 2.5 as a minimum, cf https://github.com/vmware/pyvcloud/blob/master/requirements.txt and http://pyyaml.org/wiki/PyYAML vmware.py depend on PyVIM, who depend on python 2.6. So we can use the modern syntax for both of them.
This commit is contained in:
parent
e539b2003d
commit
127a37f67c
2 changed files with 4 additions and 4 deletions
|
@ -144,7 +144,7 @@ class VcaAnsibleModule(AnsibleModule):
|
||||||
meth()
|
meth()
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
self.fail('no login method exists for service_type %s' % service_type)
|
self.fail('no login method exists for service_type %s' % service_type)
|
||||||
except VcaError, e:
|
except VcaError as e:
|
||||||
self.fail(e.message, response=self.vca.response, **e.kwargs)
|
self.fail(e.message, response=self.vca.response, **e.kwargs)
|
||||||
|
|
||||||
def login_vca(self):
|
def login_vca(self):
|
||||||
|
@ -318,7 +318,7 @@ def vca_login(module):
|
||||||
_vchs_login(vca, password, service, org)
|
_vchs_login(vca, password, service, org)
|
||||||
elif service_type == 'vcd':
|
elif service_type == 'vcd':
|
||||||
_vcd_login(vca, password, org)
|
_vcd_login(vca, password, org)
|
||||||
except VcaError, e:
|
except VcaError as e:
|
||||||
module.fail_json(msg=e.message, **e.kwargs)
|
module.fail_json(msg=e.message, **e.kwargs)
|
||||||
|
|
||||||
return vca
|
return vca
|
||||||
|
|
|
@ -194,9 +194,9 @@ def connect_to_api(module, disconnect_atexit=True):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
service_instance = connect.SmartConnect(host=hostname, user=username, pwd=password)
|
service_instance = connect.SmartConnect(host=hostname, user=username, pwd=password)
|
||||||
except vim.fault.InvalidLogin, invalid_login:
|
except vim.fault.InvalidLogin as invalid_login:
|
||||||
module.fail_json(msg=invalid_login.msg, apierror=str(invalid_login))
|
module.fail_json(msg=invalid_login.msg, apierror=str(invalid_login))
|
||||||
except requests.ConnectionError, connection_error:
|
except requests.ConnectionError as connection_error:
|
||||||
if '[SSL: CERTIFICATE_VERIFY_FAILED]' in str(connection_error) and not validate_certs:
|
if '[SSL: CERTIFICATE_VERIFY_FAILED]' in str(connection_error) and not validate_certs:
|
||||||
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
|
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
|
||||||
context.verify_mode = ssl.CERT_NONE
|
context.verify_mode = ssl.CERT_NONE
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue