]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
CONF add suppress_requests_ssl_warnings
authorWalter A. Boring IV <walter.boring@hpe.com>
Thu, 14 Jan 2016 14:27:11 +0000 (06:27 -0800)
committerWalter A. Boring IV <walter.boring@hpe.com>
Mon, 29 Feb 2016 10:24:01 +0000 (02:24 -0800)
Many cinder drivers now seem to use the python requests library
to talk to their arrays.  One of the joys of the requests library
is that it correctly complains when it connects to a service where
the SSL certificate is bogus or out of date.  While this is a much
needed warning to raise in production environments, it's often a
useless warning for developers and or for POC deployments of Cinder.

This patch adds a CONF setting that allows the volume manager to
disable all requests ssl warnings for each driver instance.
This greatly cleans up the c-vol logs and makes them readable.

By default the CONF setting is False, or disabled.  So the admin
has to manually edit the cinder.conf file and turn this on.

DocImpact
Change-Id: I2f3d21d828aea9a04cf006dcd471ece668bfd947

cinder/volume/manager.py

index 3bb833000e29f80513d79c8e1b4df57e1b4d5767..d39d9a5706ef6cad13c145728e198594b410f06b 100644 (file)
@@ -36,7 +36,7 @@ intact.
 
 """
 
-
+import requests
 import time
 
 from oslo_config import cfg
@@ -106,6 +106,9 @@ volume_manager_opts = [
                     'location of a backend, then creating a volume type to '
                     'allow the user to select by these different '
                     'properties.'),
+    cfg.BoolOpt('suppress_requests_ssl_warnings',
+                default=False,
+                help='Suppress requests library SSL certificate warnings.'),
 ]
 
 CONF = cfg.CONF
@@ -256,6 +259,13 @@ class VolumeManager(manager.SchedulerDependentManager):
         else:
             curr_active_backend_id = service.active_backend_id
 
+        if self.configuration.suppress_requests_ssl_warnings:
+            LOG.warning(_LW("Suppressing requests library SSL Warnings"))
+            requests.packages.urllib3.disable_warnings(
+                requests.packages.urllib3.exceptions.InsecureRequestWarning)
+            requests.packages.urllib3.disable_warnings(
+                requests.packages.urllib3.exceptions.InsecurePlatformWarning)
+
         self.driver = importutils.import_object(
             volume_driver,
             configuration=self.configuration,