diff --git a/cinder/tests/test_hp3par.py b/cinder/tests/test_hp3par.py index 6756a8b9d..3861a168a 100644 --- a/cinder/tests/test_hp3par.py +++ b/cinder/tests/test_hp3par.py @@ -2256,30 +2256,35 @@ class TestHP3PARFCDriver(HP3PARBaseDriver, test.TestCase): # and return the mock HTTP 3PAR client mock_client = self.setup_driver() mock_client.getCPG.return_value = self.cpgs[0] - mock_client.getStorageSystemInfo.return_value = {'serialNumber': - '1234'} + totalCapacityMiB = 8000 + freeCapacityMiB = 4000 + mock_client.getStorageSystemInfo.return_value = { + 'serialNumber': '1234', + 'totalCapacityMiB': totalCapacityMiB, + 'freeCapacityMiB': freeCapacityMiB + } stats = self.driver.get_volume_stats(True) + const = 0.0009765625 self.assertEqual(stats['storage_protocol'], 'FC') - self.assertEqual(stats['total_capacity_gb'], 'infinite') - self.assertEqual(stats['free_capacity_gb'], 'infinite') + self.assertEqual(stats['total_capacity_gb'], totalCapacityMiB * const) + self.assertEqual(stats['free_capacity_gb'], freeCapacityMiB * const) expected = [ mock.call.login(HP3PAR_USER_NAME, HP3PAR_USER_PASS), - mock.call.getCPG(HP3PAR_CPG), mock.call.getStorageSystemInfo(), + mock.call.getCPG(HP3PAR_CPG), mock.call.logout()] mock_client.assert_has_calls(expected) stats = self.driver.get_volume_stats(True) self.assertEqual(stats['storage_protocol'], 'FC') - self.assertEqual(stats['total_capacity_gb'], 'infinite') - self.assertEqual(stats['free_capacity_gb'], 'infinite') + self.assertEqual(stats['total_capacity_gb'], totalCapacityMiB * const) + self.assertEqual(stats['free_capacity_gb'], freeCapacityMiB * const) cpg2 = self.cpgs[0].copy() cpg2.update({'SDGrowth': {'limitMiB': 8192}}) mock_client.getCPG.return_value = cpg2 - const = 0.0009765625 stats = self.driver.get_volume_stats(True) self.assertEqual(stats['storage_protocol'], 'FC') total_capacity_gb = 8192 * const @@ -2544,30 +2549,31 @@ class TestHP3PARISCSIDriver(HP3PARBaseDriver, test.TestCase): # and return the mock HTTP 3PAR client mock_client = self.setup_driver() mock_client.getCPG.return_value = self.cpgs[0] - mock_client.getStorageSystemInfo.return_value = {'serialNumber': - '1234'} + totalCapacityMiB = 8000 + freeCapacityMiB = 4000 + mock_client.getStorageSystemInfo.return_value = { + 'serialNumber': '1234', + 'totalCapacityMiB': totalCapacityMiB, + 'freeCapacityMiB': freeCapacityMiB + } stats = self.driver.get_volume_stats(True) + const = 0.0009765625 self.assertEqual(stats['storage_protocol'], 'iSCSI') - self.assertEqual(stats['total_capacity_gb'], 'infinite') - self.assertEqual(stats['free_capacity_gb'], 'infinite') + self.assertEqual(stats['total_capacity_gb'], totalCapacityMiB * const) + self.assertEqual(stats['free_capacity_gb'], freeCapacityMiB * const) expected = [ mock.call.login(HP3PAR_USER_NAME, HP3PAR_USER_PASS), - mock.call.getCPG(HP3PAR_CPG), mock.call.getStorageSystemInfo(), + mock.call.getCPG(HP3PAR_CPG), mock.call.logout()] mock_client.assert_has_calls(expected) - self.assertEqual(stats['storage_protocol'], 'iSCSI') - self.assertEqual(stats['total_capacity_gb'], 'infinite') - self.assertEqual(stats['free_capacity_gb'], 'infinite') - cpg2 = self.cpgs[0].copy() cpg2.update({'SDGrowth': {'limitMiB': 8192}}) mock_client.getCPG.return_value = cpg2 - const = 0.0009765625 stats = self.driver.get_volume_stats(True) self.assertEqual(stats['storage_protocol'], 'iSCSI') total_capacity_gb = 8192 * const diff --git a/cinder/volume/drivers/san/hp/hp_3par_common.py b/cinder/volume/drivers/san/hp/hp_3par_common.py index 1ff175081..9d3d97625 100644 --- a/cinder/volume/drivers/san/hp/hp_3par_common.py +++ b/cinder/volume/drivers/san/hp/hp_3par_common.py @@ -149,10 +149,11 @@ class HP3PARCommon(object): 2.0.19 - Update default persona from Generic to Generic-ALUA 2.0.20 - Configurable SSH missing key policy and known hosts file 2.0.21 - Remove bogus invalid snapCPG=None exception + 2.0.22 - HP 3PAR drivers should not claim to have 'infinite' space """ - VERSION = "2.0.21" + VERSION = "2.0.22" stats = {} @@ -623,11 +624,13 @@ class HP3PARCommon(object): 'vendor_name': 'Hewlett-Packard', 'volume_backend_name': None} + info = self.client.getStorageSystemInfo() try: cpg = self.client.getCPG(self.config.hp3par_cpg) if 'limitMiB' not in cpg['SDGrowth']: - total_capacity = 'infinite' - free_capacity = 'infinite' + # System capacity is best we can do for now. + total_capacity = info['totalCapacityMiB'] * const + free_capacity = info['freeCapacityMiB'] * const else: total_capacity = int(cpg['SDGrowth']['limitMiB'] * const) free_capacity = int((cpg['SDGrowth']['limitMiB'] - @@ -641,7 +644,6 @@ class HP3PARCommon(object): LOG.error(err) raise exception.InvalidInput(reason=err) - info = self.client.getStorageSystemInfo() stats['location_info'] = ('HP3PARDriver:%(sys_id)s:%(dest_cpg)s' % {'sys_id': info['serialNumber'], 'dest_cpg': self.config.safe_get(