New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge #30231 with updates to dependency documentation #30347

Merged
merged 3 commits into from Jan 13, 2016
Jump to file or symbol
Failed to load files and symbols.
+21 −7
Diff settings

Always

Just for now

Next

Fix issue where pyVmomi 6.0.0 raises SSL Error for systems using Pyth…

…on2.7+
  • Loading branch information...
nmadhok committed Jan 8, 2016
commit 256ace081a7313fc79a0302c3cf37e0ee0fc9bdd
Copy path View file
@@ -139,8 +139,8 @@ def get_service_instance(host, username, password, protocol=None, port=None):
except Exception as exc:
default_msg = 'Could not connect to host \'{0}\'. ' \
'Please check the debug log for more information.'.format(host)
if isinstance(exc, vim.fault.HostConnectFault) and '[SSL: CERTIFICATE_VERIFY_FAILED]' in exc.msg:
try:
try:
if (isinstance(exc, vim.fault.HostConnectFault) and '[SSL: CERTIFICATE_VERIFY_FAILED]' in exc.msg) or '[SSL: CERTIFICATE_VERIFY_FAILED]' in str(exc):
import ssl
default_context = ssl._create_default_https_context
ssl._create_default_https_context = ssl._create_unverified_context
@@ -152,14 +152,28 @@ def get_service_instance(host, username, password, protocol=None, port=None):
port=port
)
ssl._create_default_https_context = default_context
except Exception as exc:
else:
err_msg = exc.msg if hasattr(exc, 'msg') else default_msg
log.debug(exc)
raise SaltSystemExit(err_msg)
except Exception as exc:
if 'certificate verify failed' in str(exc):
import ssl
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
context.verify_mode = ssl.CERT_NONE
service_instance = SmartConnect(
host=host,
user=username,
pwd=password,
protocol=protocol,
port=port,
sslContext=context
)
else:
err_msg = exc.msg if hasattr(exc, 'msg') else default_msg
log.debug(exc)
raise SaltSystemExit(err_msg)
else:
err_msg = exc.msg if hasattr(exc, 'msg') else default_msg
log.debug(exc)
raise SaltSystemExit(err_msg)
atexit.register(Disconnect, service_instance)
ProTip! Use n and p to navigate between commits in a pull request.