]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fixes HP LeftHand driver with Paramiko 1.13.0
authorJim Branen <james.branen@hp.com>
Fri, 4 Apr 2014 20:36:42 +0000 (13:36 -0700)
committerJim Branen <james.branen@hp.com>
Wed, 9 Apr 2014 15:43:51 +0000 (08:43 -0700)
With Paramiko 1.13.0, the method exec_command now returns Unicode.
This causes a problem when the driver tries to build the XML returned
from the LeftHand array. The XML header returned from the array defines
the encoding as encoding=UTF-8. Therefore, we must now ensure the
encoding passed to the parser is utf-8.

Change-Id: I7b504626e2d9a0ee2b62820b11f56eb136e31987
closes-bug: #1298608

cinder/tests/test_hplefthand.py
cinder/volume/drivers/san/hp/hp_lefthand_cliq_proxy.py

index 040ad86bf85936405f7ce15cef30f82cd3c16355..d9ad1a8e096b873e8f64207d062cf68b2bccafef 100644 (file)
@@ -309,6 +309,42 @@ class TestHPLeftHandCLIQISCSIDriver(HPLeftHandBaseDriver, test.TestCase):
                 </gauche>"""
             return output, None
 
+        def test_paramiko_1_13_0(cliq_args):
+
+            # paramiko 1.13.0 now returns unicode
+            output = unicode(
+                '<?xml version="1.0" encoding="UTF-8" standalone="no" ?>\n'
+                '<gauche version="1.0">\n\n  <response description="Operation'
+                ' succeeded." name="CliqSuccess" processingTime="423" '
+                'result="0">\n    <cluster adaptiveOptimization="false" '
+                'blockSize="1024" description="" maxVolumeSizeReplication1='
+                '"114594676736" minVolumeSize="262144" name="clusterdemo" '
+                'pageSize="262144" spaceTotal="118889644032" storageNodeCount='
+                '"1" unprovisionedSpace="114594676736" useVip="true">\n'
+                '      <nsm ipAddress="10.10.29.102" name="lefdemo1"/>\n'
+                '      <vip ipAddress="10.10.22.87" subnetMask='
+                '"255.255.224.0"/>\n    </cluster>\n  </response>\n\n'
+                '</gauche>\n    ')
+            return output, None
+
+        def test_paramiko_1_10_0(cliq_args):
+
+            # paramiko 1.10.0 returns python default encoding.
+            output = (
+                '<?xml version="1.0" encoding="UTF-8" standalone="no" ?>\n'
+                '<gauche version="1.0">\n\n  <response description="Operation'
+                ' succeeded." name="CliqSuccess" processingTime="423" '
+                'result="0">\n    <cluster adaptiveOptimization="false" '
+                'blockSize="1024" description="" maxVolumeSizeReplication1='
+                '"114594676736" minVolumeSize="262144" name="clusterdemo" '
+                'pageSize="262144" spaceTotal="118889644032" storageNodeCount='
+                '"1" unprovisionedSpace="114594676736" useVip="true">\n'
+                '      <nsm ipAddress="10.10.29.102" name="lefdemo1"/>\n'
+                '      <vip ipAddress="10.10.22.87" subnetMask='
+                '"255.255.224.0"/>\n    </cluster>\n  </response>\n\n'
+                '</gauche>\n    ')
+            return output, None
+
         self.assertEqual(cliq_args['output'], 'XML')
         try:
             verbs = {'createVolume': create_volume,
@@ -324,7 +360,9 @@ class TestHPLeftHandCLIQISCSIDriver(HPLeftHandBaseDriver, test.TestCase):
                      'getSnapshotInfo': get_snapshot_info,
                      'getServerInfo': get_server_info,
                      'createServer': create_server,
-                     'testError': test_error}
+                     'testError': test_error,
+                     'testParamiko_1.10.1': test_paramiko_1_10_0,
+                     'testParamiko_1.13.1': test_paramiko_1_13_0}
         except KeyError:
             raise NotImplementedError()
 
@@ -593,6 +631,20 @@ class TestHPLeftHandCLIQISCSIDriver(HPLeftHandBaseDriver, test.TestCase):
         # validate call chain
         mock_cliq_run.assert_has_calls(expected)
 
+    def test_cliq_run_xml_paramiko_1_13_0(self):
+
+        # set up driver with default config
+        self.setup_driver()
+        xml = self.driver.proxy._cliq_run_xml('testParamiko_1.13.1', {})
+        self.assertIsNotNone(xml)
+
+    def test_cliq_run_xml_paramiko_1_10_0(self):
+
+        # set up driver with default config
+        self.setup_driver()
+        xml = self.driver.proxy._cliq_run_xml('testParamiko_1.10.1', {})
+        self.assertIsNotNone(xml)
+
 
 class TestHPLeftHandRESTISCSIDriver(HPLeftHandBaseDriver, test.TestCase):
 
index 2127133dd52da20b42d1f004d9a3660fb9885b7a..0b36ee7f5f8265fe09927ea0af1bf7909380b425 100644 (file)
@@ -72,9 +72,10 @@ class HPLeftHandCLIQProxy(SanISCSIDriver):
         1.2.0 - Ported into the new HP LeftHand driver.
         1.2.1 - Fixed bug #1279897, HP LeftHand CLIQ proxy may return incorrect
                 capacity values.
+        1.2.2 - Fixed driver with Paramiko 1.13.0, bug #1298608.
     """
 
-    VERSION = "1.2.1"
+    VERSION = "1.2.2"
 
     device_stats = {}
 
@@ -106,7 +107,7 @@ class HPLeftHandCLIQProxy(SanISCSIDriver):
 
         LOG.debug(_("CLIQ command returned %s"), out)
 
-        result_xml = etree.fromstring(out)
+        result_xml = etree.fromstring(out.encode('utf8'))
         if check_cliq_result:
             response_node = result_xml.find("response")
             if response_node is None: