VMware: support for 2.6 and sslContext (#42237)

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Abhijeet Kasurde 2018-07-17 08:00:33 +05:30 committed by GitHub
parent f26272a492
commit e8c90b47eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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