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
This commit is contained in:
Monty Taylor 2015-11-04 18:28:41 -05:00
parent ac51f44591
commit 1bf09410d1
2 changed files with 4 additions and 12 deletions

View File

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

View File

@ -4,3 +4,4 @@
PyYAML>=3.1.0
appdirs>=1.3.0
keystoneauth1>=1.0.0
requestsexceptions>=1.1.1 # Apache-2.0