]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Report better capacity info for a limitless 3par cpg
authorGloria Gu <gloria.gu@hp.com>
Wed, 10 Dec 2014 01:56:09 +0000 (17:56 -0800)
committerGloria Gu <gloria.gu@hp.com>
Thu, 11 Dec 2014 01:28:19 +0000 (17:28 -0800)
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

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

index f944f67f91e3d01a46321a49a64c8e48c4cd7321..d95df7c6a997a24a2e3045cc76415bdd96a87e99 100644 (file)
@@ -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 +
index 26f7beb747d26e97b8cbff5b8455d496bbbc66f6..3782894d37de029191ac4a2c21710d55adcf656c 100644 (file)
@@ -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'] -