Fixes HP LeftHand driver with Paramiko 1.13.0

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
(cherry picked from commit 57e8cdb9dd)
This commit is contained in:
Jim Branen 2014-04-04 13:36:42 -07:00 committed by Jay S. Bryant
parent abc4461a5a
commit 00b7574d9a
2 changed files with 56 additions and 3 deletions

View 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):

View 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: