Avoid invoking session/create API with client cert

This fails on NSX since the API is only supported with basic auth.

Change-Id: I4043836d9b0d96ec659f33cef19ec31b73747667
This commit is contained in:
Anna Khmelnitsky 2020-10-14 12:10:37 -07:00 committed by Adit Sarfaty
parent 0f063afd10
commit 5fb0084192
1 changed files with 7 additions and 1 deletions

View File

@ -243,6 +243,12 @@ class NSXRequestsHTTPProvider(AbstractHTTPProvider):
# Add allow-overwrite if configured
if allow_overwrite_header:
session.default_headers['X-Allow-Overwrite'] = 'true'
if session.cert_provider:
# Session create will fail with cert provider
LOG.debug("Skipping session create with client certificate auth")
return
# Perform the initial session create and get the relevant jsessionid &
# X-XSRF-TOKEN for future requests
req_data = ''
@ -260,7 +266,7 @@ class NSXRequestsHTTPProvider(AbstractHTTPProvider):
LOG.error("Session create failed for endpoint %s due to "
"error in retrieving JSON Web Token: %s",
provider.url, e)
elif not session.cert_provider:
else:
# With client certificate authentication, username and password
# may not be provided.
# If provided, backend treats these credentials as authentication