]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Ignore InsecureReq warning in SolidFire Driver
authorJohn Griffith <john.griffith8@gmail.com>
Sun, 9 Aug 2015 16:00:51 +0000 (10:00 -0600)
committerJohn Griffith <john.griffith8@gmail.com>
Sun, 9 Aug 2015 16:03:44 +0000 (10:03 -0600)
The python requests package logs the use of Insecure as
a warning.  Currently the use of http vs https is a
configurable option, and for those that use http, the
log files include a Warning message for every single
request to the SolidFire Cluster.

In our case we're explicitly providing the
option to use http instead of https, so we can safely
ignore this message and remove it from the logs.

Change-Id: I746b5f7d7351ef594bf0004ec76458fc1a633031

cinder/volume/drivers/solidfire.py

index e330d9892fdd4672d7af055f4199354f6d6ef9ec..8cefc45fc9328a33be7939244406138e9641bf20 100644 (file)
@@ -26,6 +26,9 @@ from oslo_utils import importutils
 from oslo_utils import timeutils
 from oslo_utils import units
 import requests
+from requests.packages.urllib3 import exceptions
+import warnings
+
 import six
 
 from cinder import context
@@ -212,11 +215,13 @@ class SolidFireDriver(san.SanISCSIDriver):
         payload = {'method': method, 'params': params}
 
         url = '%s/json-rpc/%s/' % (endpoint['url'], version)
-        req = requests.post(url,
-                            data=json.dumps(payload),
-                            auth=(endpoint['login'], endpoint['passwd']),
-                            verify=False,
-                            timeout=30)
+        with warnings.catch_warnings():
+            warnings.simplefilter("ignore", exceptions.InsecureRequestWarning)
+            req = requests.post(url,
+                                data=json.dumps(payload),
+                                auth=(endpoint['login'], endpoint['passwd']),
+                                verify=False,
+                                timeout=30)
 
         response = req.json()
         req.close()