20938347 ZFSSA Cinder driver needs to account for PEP 476 in Python 2.7.9
authordavid.comay@oracle.com
Fri, 24 Apr 2015 10:53:56 -0700
changeset 4189 599f274b9bcc
parent 4188 23e54414e57c
child 4190 85f3f56a012c
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	Fri Apr 24 10:53:56 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
+@@ -17,6 +17,7 @@ ZFS Storage Appliance REST API Client Pr
+ 
+ import httplib
+ import json
++import ssl
+ import StringIO
+ import time
+ import urllib2
+@@ -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)