From 0c6c57d70826b36db30795fa993cf677a4c2a6e4 Mon Sep 17 00:00:00 2001 From: Jim Branen Date: Thu, 27 Feb 2014 10:41:34 -0800 Subject: [PATCH] Fix volume stats with multiple LeftHand clusters When more than one cluster exists in a LeftHand management group, get_volume_stats may return the stats for the wrong cluster. This patch fixes the problem by listing the cluster name in the getClusterInfo query. Change-Id: I2d5a76869c6bb1b3d514f0546ea00998e5ee32fb Closes-Bug: #1279897 --- cinder/tests/test_hplefthand.py | 18 ++++++++++++++++++ .../drivers/san/hp/hp_lefthand_cliq_proxy.py | 9 +++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/cinder/tests/test_hplefthand.py b/cinder/tests/test_hplefthand.py index 8b6912463..3fc7b96d1 100644 --- a/cinder/tests/test_hplefthand.py +++ b/cinder/tests/test_hplefthand.py @@ -575,6 +575,24 @@ class TestHPLeftHandCLIQISCSIDriver(HPLeftHandBaseDriver, test.TestCase): # validate call chain mock_cliq_run.assert_has_calls(expected) + def test_get_volume_stats(self): + + # set up driver with default config + mock_cliq_run = self.setup_driver() + volume_stats = self.driver.get_volume_stats(True) + + self.assertEqual(volume_stats['vendor_name'], 'Hewlett-Packard') + self.assertEqual(volume_stats['storage_protocol'], 'iSCSI') + + expected = [ + mock.call('getClusterInfo', { + 'searchDepth': 1, + 'clusterName': 'CloudCluster1', + 'output': 'XML'}, True)] + + # validate call chain + mock_cliq_run.assert_has_calls(expected) + class TestHPLeftHandRESTISCSIDriver(HPLeftHandBaseDriver, test.TestCase): diff --git a/cinder/volume/drivers/san/hp/hp_lefthand_cliq_proxy.py b/cinder/volume/drivers/san/hp/hp_lefthand_cliq_proxy.py index 58be55fbd..443319b0c 100644 --- a/cinder/volume/drivers/san/hp/hp_lefthand_cliq_proxy.py +++ b/cinder/volume/drivers/san/hp/hp_lefthand_cliq_proxy.py @@ -69,9 +69,11 @@ class HPLeftHandCLIQProxy(SanISCSIDriver): 1.1.0 - Added create/delete snapshot, extend volume, create volume from snapshot support. 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. """ - VERSION = "1.2.0" + VERSION = "1.2.1" device_stats = {} @@ -427,7 +429,10 @@ class HPLeftHandCLIQProxy(SanISCSIDriver): data['storage_protocol'] = 'iSCSI' data['vendor_name'] = 'Hewlett-Packard' - result_xml = self._cliq_run_xml("getClusterInfo", {'searchDepth': 1}) + result_xml = self._cliq_run_xml( + "getClusterInfo", { + 'searchDepth': 1, + 'clusterName': self.configuration.san_clustername}) cluster_node = result_xml.find("response/cluster") total_capacity = cluster_node.attrib.get("spaceTotal") free_capacity = cluster_node.attrib.get("unprovisionedSpace") -- 2.45.2