diff options
author | Monty Taylor <mordred@inaugust.com> | 2015-11-03 10:42:53 -0500 |
---|---|---|
committer | Monty Taylor <mordred@inaugust.com> | 2015-11-03 12:01:07 -0500 |
commit | 6d957b01e55637ad4e8ce69c31cf3b3f64881c57 (patch) | |
tree | 81672e3c008dec51539627a119a5aa49704bcd47 | |
parent | 335ed4a6944ad32759ad810aa6a4da599bc358fd (diff) | |
download | os-client-config-6d957b01e55637ad4e8ce69c31cf3b3f64881c57.tar.gz |
Disable spurious urllib warnings
Since we can return a keystoneauth1 Session correctly, disable the
stupid warnings that are evil and never should be emitted.
Change-Id: I128e4587ab07a20c7c5da745b12e4f5d0a3ee5a7
-rw-r--r-- | os_client_config/cloud_config.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/os_client_config/cloud_config.py b/os_client_config/cloud_config.py index fe5c302..17941c9 100644 --- a/os_client_config/cloud_config.py +++ b/os_client_config/cloud_config.py @@ -20,6 +20,15 @@ from keystoneauth1 import session from os_client_config import _log from os_client_config import exceptions +# Importing these for later but not disabling for now +try: + from requests.packages.urllib3 import exceptions as urllib_exc +except ImportError: + try: + from urllib3 import exceptions as urllib_exc + except ImportError: + urllib_exc = None + class CloudConfig(object): def __init__(self, name, region, config, @@ -134,6 +143,16 @@ class CloudConfig(object): raise exceptions.OpenStackConfigException( "Problem with auth parameters") (verify, cert) = self.get_requests_verify_args() + # Turn off urllib3 warnings about insecure certs if we have + # explicitly configured requests to tell it we do not want + # cert verification + if not verify and urllib_exc is not None: + self.log.debug( + "Turning off SSL warnings for {cloud}:{region}" + " since verify=False".format( + cloud=self.name, region=self.region)) + warnings.filterwarnings( + 'ignore', category=urllib_exc.InsecureRequestWarning) self._keystone_session = session.Session( auth=self._auth, verify=verify, |