From: Gloria Gu Date: Wed, 10 Dec 2014 01:56:09 +0000 (-0800) Subject: Report better capacity info for a limitless 3par cpg X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=92888e514b37c3ce3c0502e66e183a40da1b4249;p=openstack-build%2Fcinder-build.git Report better capacity info for a limitless 3par cpg This change has the following improvement: 1. Uses getCPGAvailableSpace from hp3parclient to report free_capapcity for a limitless cpg. 2. Uses cpg's SDUsage.usedMiB + UsrUsage.usedMiB + free_capacity to calculate the total_capacity for a limitless cpg. This is the best we can do for a limitless cpg. Closes-Bug: #1398651 Change-Id: I62f446786360c61288a788be29d1daa6e409c7b1 --- diff --git a/cinder/tests/test_hp3par.py b/cinder/tests/test_hp3par.py index f944f67f9..d95df7c6a 100644 --- a/cinder/tests/test_hp3par.py +++ b/cinder/tests/test_hp3par.py @@ -174,11 +174,11 @@ class HP3PARBaseDriver(object): 'SDUsage': {'rawTotalMiB': 49152, 'rawUsedMiB': 1023, 'totalMiB': 36864, - 'usedMiB': 768}, + 'usedMiB': 1024 * 1}, 'UsrUsage': {'rawTotalMiB': 57344, 'rawUsedMiB': 43349, 'totalMiB': 43008, - 'usedMiB': 32512}, + 'usedMiB': 1024 * 20}, 'additionalStates': [], 'degradedStates': [], 'failedStates': [], @@ -2959,9 +2959,14 @@ class TestHP3PARFCDriver(HP3PARBaseDriver, test.TestCase): mock_client = self.setup_driver() mock_client.getCPG.return_value = self.cpgs[0] mock_client.getStorageSystemInfo.return_value = { - 'serialNumber': '1234', - 'freeCapacityMiB': 1024.0 * 2, - 'totalCapacityMiB': 1024.0 * 123 + 'serialNumber': '1234' + } + + # cpg has no limit + mock_client.getCPGAvailableSpace.return_value = { + "capacityEfficiency": {u'compaction': 594.4}, + "rawFreeMiB": 1024.0 * 6, + "usableFreeMiB": 1024.0 * 3 } with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ @@ -2974,13 +2979,15 @@ class TestHP3PARFCDriver(HP3PARBaseDriver, test.TestCase): self.assertEqual(stats['storage_protocol'], 'FC') self.assertEqual(stats['total_capacity_gb'], 0) self.assertEqual(stats['free_capacity_gb'], 0) - self.assertEqual(stats['pools'][0]['total_capacity_gb'], 123.0) - self.assertEqual(stats['pools'][0]['free_capacity_gb'], 2.0) + self.assertEqual(stats['pools'][0]['total_capacity_gb'], 24.0) + self.assertEqual(stats['pools'][0]['free_capacity_gb'], 3.0) expected = [ mock.call.getStorageSystemInfo(), mock.call.getCPG(HP3PAR_CPG), - mock.call.getCPG(HP3PAR_CPG2)] + mock.call.getCPGAvailableSpace(HP3PAR_CPG), + mock.call.getCPG(HP3PAR_CPG2), + mock.call.getCPGAvailableSpace(HP3PAR_CPG2)] mock_client.assert_has_calls( self.standard_login + @@ -2990,8 +2997,8 @@ class TestHP3PARFCDriver(HP3PARBaseDriver, test.TestCase): self.assertEqual(stats['storage_protocol'], 'FC') self.assertEqual(stats['total_capacity_gb'], 0) self.assertEqual(stats['free_capacity_gb'], 0) - self.assertEqual(stats['pools'][0]['total_capacity_gb'], 123.0) - self.assertEqual(stats['pools'][0]['free_capacity_gb'], 2.0) + self.assertEqual(stats['pools'][0]['total_capacity_gb'], 24.0) + self.assertEqual(stats['pools'][0]['free_capacity_gb'], 3.0) cpg2 = self.cpgs[0].copy() cpg2.update({'SDGrowth': {'limitMiB': 8192}}) @@ -3310,9 +3317,13 @@ class TestHP3PARISCSIDriver(HP3PARBaseDriver, test.TestCase): mock_client = self.setup_driver() mock_client.getCPG.return_value = self.cpgs[0] mock_client.getStorageSystemInfo.return_value = { - 'serialNumber': '1234', - 'freeCapacityMiB': 1024.0 * 2, - 'totalCapacityMiB': 1024.0 * 123 + 'serialNumber': '1234' + } + # cpg has no limit + mock_client.getCPGAvailableSpace.return_value = { + "capacityEfficiency": {u'compaction': 594.4}, + "rawFreeMiB": 1024.0 * 6, + "usableFreeMiB": 1024.0 * 3 } with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ @@ -3324,13 +3335,15 @@ class TestHP3PARISCSIDriver(HP3PARBaseDriver, test.TestCase): self.assertEqual(stats['storage_protocol'], 'iSCSI') self.assertEqual(stats['total_capacity_gb'], 0) self.assertEqual(stats['free_capacity_gb'], 0) - self.assertEqual(stats['pools'][0]['total_capacity_gb'], 123.0) - self.assertEqual(stats['pools'][0]['free_capacity_gb'], 2.0) + self.assertEqual(stats['pools'][0]['total_capacity_gb'], 24.0) + self.assertEqual(stats['pools'][0]['free_capacity_gb'], 3.0) expected = [ mock.call.getStorageSystemInfo(), mock.call.getCPG(HP3PAR_CPG), - mock.call.getCPG(HP3PAR_CPG2)] + mock.call.getCPGAvailableSpace(HP3PAR_CPG), + mock.call.getCPG(HP3PAR_CPG2), + mock.call.getCPGAvailableSpace(HP3PAR_CPG2)] mock_client.assert_has_calls( self.standard_login + diff --git a/cinder/volume/drivers/san/hp/hp_3par_common.py b/cinder/volume/drivers/san/hp/hp_3par_common.py index 26f7beb74..3782894d3 100644 --- a/cinder/volume/drivers/san/hp/hp_3par_common.py +++ b/cinder/volume/drivers/san/hp/hp_3par_common.py @@ -159,10 +159,11 @@ class HP3PARCommon(object): 2.0.26 - Don't ignore extra-specs snap_cpg when missing cpg #1368972 2.0.27 - Fixing manage source-id error bug #1357075 2.0.28 - Removing locks bug #1381190 + 2.0.29 - Report a limitless cpg's stats better bug #1398651 """ - VERSION = "2.0.28" + VERSION = "2.0.29" stats = {} @@ -669,9 +670,16 @@ class HP3PARCommon(object): try: cpg = self.client.getCPG(cpg_name) if 'limitMiB' not in cpg['SDGrowth']: - # System capacity is best we can do for now. - total_capacity = info['totalCapacityMiB'] * const - free_capacity = info['freeCapacityMiB'] * const + # cpg usable free space + cpg_avail_space = \ + self.client.getCPGAvailableSpace(cpg_name) + free_capacity = int( + cpg_avail_space['usableFreeMiB'] * const) + # total_capacity is the best we can do for a limitless cpg + total_capacity = int( + (cpg['SDUsage']['usedMiB'] + + cpg['UsrUsage']['usedMiB'] + + cpg_avail_space['usableFreeMiB']) * const) else: total_capacity = int(cpg['SDGrowth']['limitMiB'] * const) free_capacity = int((cpg['SDGrowth']['limitMiB'] -