20938347 ZFSSA Cinder driver needs to account for PEP 476 in Python 2.7.9 s11u2-sru
authordavid.comay@oracle.com
Thu, 30 Apr 2015 09:54:11 -0700
branchs11u2-sru
changeset 4225 4d2c2cc972d9
parent 4224 d9bd163194bd
child 4231 eb60338f90d1
20938347 ZFSSA Cinder driver needs to account for PEP 476 in Python 2.7.9
components/openstack/cinder/patches/07-zfssa-pep-476.patch
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/openstack/cinder/patches/07-zfssa-pep-476.patch	Thu Apr 30 09:54:11 2015 -0700
@@ -0,0 +1,36 @@
+This patch is to work-around the fact that Python 2.7.9 and beyond have
+implemented PEP 476 which enabled certificate verification by default
+and ZFSSAs may not be deployed with a valid, CA-signed certificate.
+
+This patch may be suitable for pushing upsteam.
+
+--- cinder-2014.2.2/cinder/volume/drivers/zfssa/restclient.py.~1~	2015-02-05 08:03:26.000000000 -0800
++++ cinder-2014.2.2/cinder/volume/drivers/zfssa/restclient.py	2015-04-23 17:32:01.898738656 -0700
[email protected]@ -17,6 +17,7 @@ ZFS Storage Appliance REST API Client Pr
+ 
+ import httplib
+ import json
++import ssl
+ import StringIO
+ import time
+ import urllib2
[email protected]@ -272,9 +273,18 @@ class RestClientURL(object):
+         if body and body != '':
+             LOG.debug('Body: %s' % body)
+ 
++        if hasattr(ssl, '_create_unverified_context'):
++            context = ssl._create_unverified_context()
++        else:
++            context = None
++
+         while retry < maxreqretries:
+             try:
+-                response = urllib2.urlopen(req, timeout=self.timeout)
++                if context:
++                    response = urllib2.urlopen(req, timeout=self.timeout,
++                        context=context)
++                else:
++                    response = urllib2.urlopen(req, timeout=self.timeout)
+             except urllib2.HTTPError as err:
+                 if err.code == httplib.NOT_FOUND:
+                     LOG.debug('REST Not Found: %s' % err.code)