summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-11-04 12:51:59 +0000
committerGerrit Code Review <review@openstack.org>2015-11-04 12:51:59 +0000
commitba2571dcdc750a5f973b4f63b18888d0543a09a5 (patch)
treeb7d76bb351d6c42c7a934993fdc222a77293df11
parent0f0449cdf22383c5e27e6e476ad62edc64c4638b (diff)
parent6d957b01e55637ad4e8ce69c31cf3b3f64881c57 (diff)
downloados-client-config-ba2571dcdc750a5f973b4f63b18888d0543a09a5.tar.gz
Merge "Disable spurious urllib warnings"
-rw-r--r--os_client_config/cloud_config.py19
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,