]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
HP 3PAR drivers should not claim to have 'infinite' space
authorMark Sturdevant <mark.sturdevant@hp.com>
Sun, 14 Sep 2014 00:04:27 +0000 (17:04 -0700)
committerMark Sturdevant <mark.sturdevant@hp.com>
Thu, 18 Sep 2014 21:35:18 +0000 (21:35 +0000)
The HP 3PAR drivers report 'infinite' space when there is not a limit
set on the CPG. In this case, it would be better to at least use the
free space estimate of the array instead of 'infinite'.

Change-Id: I8c34ea3982fe61a1b6fa01245ca6da23ca5b8b7b
Closes-Bug: 1369057

cinder/tests/test_hp3par.py
cinder/volume/drivers/san/hp/hp_3par_common.py

index 6756a8b9d4a3fbf516d65833f469192d83c0bc54..3861a168a1b82408f706a30ee14f7499609d7fb0 100644 (file)
@@ -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
index 1ff175081fd1c065a5cb78564e383f1ca66e65bb..9d3d976253ed1df19d1616f522ab4b0a334fa27d 100644 (file)
@@ -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(