components/openstack/cinder/patches/07-launchpad-1460156.patch
changeset 6849 f9a2279efa0d
parent 6848 8e252a37ed0d
child 6850 f8d3bc724af7
equal deleted inserted replaced
6848:8e252a37ed0d 6849:f9a2279efa0d
     1 This patch is to work-around the fact that Python 2.7.9 and beyond have
       
     2 implemented PEP 476 which enabled certificate verification by default
       
     3 and ZFSSAs may not be deployed with a valid, CA-signed certificate.
       
     4 
       
     5 commit 814cbb8a937e2a01f2c8814dd032c0f12baa6fd4
       
     6 Author: Diem Tran <[email protected]>
       
     7 Date:   Wed Jul 1 21:12:48 2015 +0000
       
     8 
       
     9     Fix PEP476 & format message of Oracle ZFSSA drivers
       
    10     
       
    11     * Handles the PEP 476 by opting out certificate verification.
       
    12     * Fix debug format messages in restclient.py
       
    13     
       
    14     Change-Id: Iaf9e546f0aed6b57fe9c2bf43aa2ce003a05ddf8
       
    15     Closes-Bug: #1460156
       
    16 
       
    17 --- cinder-2015.1.2/cinder/volume/drivers/zfssa/restclient.py.~1~	2015-10-13 09:27:35.000000000 -0700
       
    18 +++ cinder-2015.1.2/cinder/volume/drivers/zfssa/restclient.py	2016-01-31 00:56:12.410126083 -0800
       
    19 @@ -1,4 +1,4 @@
       
    20 -# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
       
    21 +# Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
       
    22  #
       
    23  #    Licensed under the Apache License, Version 2.0 (the "License"); you may
       
    24  #    not use this file except in compliance with the License. You may obtain
       
    25 @@ -17,6 +17,7 @@ ZFS Storage Appliance REST API Client Pr
       
    26  
       
    27  import httplib
       
    28  import json
       
    29 +import ssl
       
    30  import StringIO
       
    31  import time
       
    32  import urllib2
       
    33 @@ -268,14 +269,27 @@ class RestClientURL(object):
       
    34          retry = 0
       
    35          response = None
       
    36  
       
    37 -        LOG.debug('Request: %s %s' % (request, zfssaurl))
       
    38 +        LOG.debug('Request: %(request)s %(url)s',
       
    39 +                  {'request': request, 'url': zfssaurl})
       
    40          LOG.debug('Out headers: %s' % out_hdrs)
       
    41          if body and body != '':
       
    42              LOG.debug('Body: %s' % body)
       
    43  
       
    44 +        context = None
       
    45 +        if hasattr(ssl, '_create_unverified_context'):
       
    46 +            context = ssl._create_unverified_context()
       
    47 +        else:
       
    48 +            context = None
       
    49 +
       
    50          while retry < maxreqretries:
       
    51              try:
       
    52 -                response = urllib2.urlopen(req, timeout=self.timeout)
       
    53 +                if context:
       
    54 +                    response = urllib2.urlopen(req,
       
    55 +                                               timeout=self.timeout,
       
    56 +                                               context=context)
       
    57 +                else:
       
    58 +                    response = urllib2.urlopen(req,
       
    59 +                                               timeout=self.timeout)
       
    60              except urllib2.HTTPError as err:
       
    61                  if err.code == httplib.NOT_FOUND:
       
    62                      LOG.debug('REST Not Found: %s' % err.code)
       
    63 @@ -315,8 +329,9 @@ class RestClientURL(object):
       
    64  
       
    65              break
       
    66  
       
    67 -        if response and response.getcode() == httplib.SERVICE_UNAVAILABLE and \
       
    68 -           retry >= maxreqretries:
       
    69 +        if (response and
       
    70 +            (response.getcode() == httplib.SERVICE_UNAVAILABLE and
       
    71 +                retry >= maxreqretries)):
       
    72              raise RestClientError(response.getcode(), name="ERR_HTTPError",
       
    73                                    message="REST Not Available: Disabled")
       
    74