From e8c90b47eb89af3b8b030bdf3b6737eddc0332bf Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Tue, 17 Jul 2018 08:00:33 +0530 Subject: [PATCH] VMware: support for 2.6 and sslContext (#42237) Signed-off-by: Abhijeet Kasurde --- lib/ansible/module_utils/vmware.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/ansible/module_utils/vmware.py b/lib/ansible/module_utils/vmware.py index ca94ae021b..4d9ab68b24 100644 --- a/lib/ansible/module_utils/vmware.py +++ b/lib/ansible/module_utils/vmware.py @@ -501,7 +501,15 @@ def connect_to_api(module, disconnect_atexit=True): service_instance = None try: - service_instance = connect.SmartConnect(host=hostname, user=username, pwd=password, sslContext=ssl_context, port=port) + connect_args = dict( + host=hostname, + user=username, + pwd=password, + port=port, + ) + if ssl_context: + connect_args.update(sslContext=ssl_context) + service_instance = connect.SmartConnect(**connect_args) except vim.fault.InvalidLogin as invalid_login: module.fail_json(msg="Unable to log on to vCenter or ESXi API at %s:%s as %s: %s" % (hostname, port, username, invalid_login.msg)) except vim.fault.NoPermission as no_permission: