summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty Taylor <mordred@inaugust.com>2015-11-04 18:28:41 -0500
committerMonty Taylor <mordred@inaugust.com>2015-11-04 18:47:40 -0500
commit1bf09410d191b872b975634f8cf3f8847865b546 (patch)
tree1555381e3268e1353d6490d75f7bc6d2918ea72e
parentac51f4459106c10b0564747f36635779d40fadac (diff)
downloados-client-config-1bf09410d191b872b975634f8cf3f8847865b546.tar.gz
Use requestsexceptions for urllib squelching
The code to deal with this properly is quite sharable and we should not care. Use requestsexceptions from the Infra team to handle it. Change-Id: Ie20a3e1b2d8d18a4a76b34219cf12510cb1cda98 Depends-On: I52249b6d2fe04c49a9f4ed139d7625c890309ca8
-rw-r--r--os_client_config/cloud_config.py15
-rw-r--r--requirements.txt1
2 files changed, 4 insertions, 12 deletions
diff --git a/os_client_config/cloud_config.py b/os_client_config/cloud_config.py
index 17941c9..5e8d492 100644
--- a/os_client_config/cloud_config.py
+++ b/os_client_config/cloud_config.py
@@ -16,19 +16,11 @@ import warnings
from keystoneauth1 import plugin
from keystoneauth1 import session
+import requestsexceptions
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,
@@ -146,13 +138,12 @@ class CloudConfig(object):
# 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:
+ if not verify:
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)
+ requestsexceptions.squelch_warnings(insecure_requests=not verify)
self._keystone_session = session.Session(
auth=self._auth,
verify=verify,
diff --git a/requirements.txt b/requirements.txt
index db0b635..3c32ced 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -4,3 +4,4 @@
PyYAML>=3.1.0
appdirs>=1.3.0
keystoneauth1>=1.0.0
+requestsexceptions>=1.1.1 # Apache-2.0