]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Optimize 3PAR array ID retrieval
authorAlex O'Rourke <alex.orourke@hpe.com>
Mon, 4 Jan 2016 17:06:10 +0000 (09:06 -0800)
committerAlex O'Rourke <alex.orourke@hpe.com>
Tue, 5 Jan 2016 17:14:51 +0000 (09:14 -0800)
Currently, we are making a call to the 3PAR array every time the
common driver is initialized, which is inefficient considering the
call is already made in get_volume_stats. Instead of making the call
every time, we can pass in the driver stats to common's do_setup and
use the array ID from there.

If the stats are not yet available, we will ask the array directly for
the ID.

Change-Id: Iff065cd9debfc899b1d88475c63c7b2cb1e5e1b6

cinder/tests/unit/test_hpe3par.py
cinder/volume/drivers/hpe/hpe_3par_common.py
cinder/volume/drivers/hpe/hpe_3par_fc.py
cinder/volume/drivers/hpe/hpe_3par_iscsi.py

index cb9f647516d5591ab961e582a77c90c9ecadc45b..87b5f0af5d499f814c27228728866fbaf09291ae 100644 (file)
@@ -5247,6 +5247,7 @@ class TestHPE3PARFCDriver(HPE3PARBaseDriver, test.TestCase):
             stats = self.driver.get_volume_stats(True)
             const = 0.0009765625
             self.assertEqual('FC', stats['storage_protocol'])
+            self.assertEqual('12345', stats['array_id'])
             self.assertTrue(stats['pools'][0]['thin_provisioning_support'])
             self.assertTrue(stats['pools'][0]['thick_provisioning_support'])
             self.assertFalse(stats['pools'][0]['QoS_support'])
@@ -5290,6 +5291,7 @@ class TestHPE3PARFCDriver(HPE3PARBaseDriver, test.TestCase):
                 self.standard_logout)
             stats = self.driver.get_volume_stats(True)
             self.assertEqual('FC', stats['storage_protocol'])
+            self.assertEqual('12345', stats['array_id'])
             self.assertTrue(stats['pools'][0]['thin_provisioning_support'])
             self.assertTrue(stats['pools'][0]['thick_provisioning_support'])
             self.assertFalse(stats['pools'][0]['QoS_support'])
@@ -5322,6 +5324,7 @@ class TestHPE3PARFCDriver(HPE3PARBaseDriver, test.TestCase):
 
             stats = self.driver.get_volume_stats(True)
             self.assertEqual('FC', stats['storage_protocol'])
+            self.assertEqual('12345', stats['array_id'])
             self.assertTrue(stats['pools'][0]['thin_provisioning_support'])
             self.assertTrue(stats['pools'][0]['thick_provisioning_support'])
             self.assertFalse(stats['pools'][0]['QoS_support'])
@@ -5399,6 +5402,7 @@ class TestHPE3PARFCDriver(HPE3PARBaseDriver, test.TestCase):
 
             stats = self.driver.get_volume_stats(True)
             self.assertEqual('FC', stats['storage_protocol'])
+            self.assertEqual('12345', stats['array_id'])
             self.assertFalse(stats['pools'][0]['thin_provisioning_support'])
             self.assertTrue(stats['pools'][0]['QoS_support'])
             self.assertEqual(24.0, stats['pools'][0]['total_capacity_gb'])
@@ -5459,6 +5463,7 @@ class TestHPE3PARFCDriver(HPE3PARBaseDriver, test.TestCase):
 
             stats = self.driver.get_volume_stats(True)
             self.assertEqual('FC', stats['storage_protocol'])
+            self.assertEqual('12345', stats['array_id'])
             self.assertEqual(24.0, stats['pools'][0]['total_capacity_gb'])
             self.assertEqual(3.0, stats['pools'][0]['free_capacity_gb'])
             self.assertEqual(87.5, stats['pools'][0]['capacity_utilization'])
@@ -6008,6 +6013,7 @@ class TestHPE3PARISCSIDriver(HPE3PARBaseDriver, test.TestCase):
             stats = self.driver.get_volume_stats(True)
             const = 0.0009765625
             self.assertEqual('iSCSI', stats['storage_protocol'])
+            self.assertEqual('12345', stats['array_id'])
             self.assertTrue(stats['pools'][0]['thin_provisioning_support'])
             self.assertTrue(stats['pools'][0]['thick_provisioning_support'])
             self.assertEqual(24.0, stats['pools'][0]['total_capacity_gb'])
@@ -6055,6 +6061,7 @@ class TestHPE3PARISCSIDriver(HPE3PARBaseDriver, test.TestCase):
 
             stats = self.driver.get_volume_stats(True)
             self.assertEqual('iSCSI', stats['storage_protocol'])
+            self.assertEqual('12345', stats['array_id'])
             self.assertTrue(stats['pools'][0]['thin_provisioning_support'])
             self.assertTrue(stats['pools'][0]['thick_provisioning_support'])
             total_capacity_gb = 8192 * const
@@ -6122,6 +6129,7 @@ class TestHPE3PARISCSIDriver(HPE3PARBaseDriver, test.TestCase):
 
             stats = self.driver.get_volume_stats(True)
             self.assertEqual('iSCSI', stats['storage_protocol'])
+            self.assertEqual('12345', stats['array_id'])
             self.assertEqual(24.0, stats['pools'][0]['total_capacity_gb'])
             self.assertEqual(3.0, stats['pools'][0]['free_capacity_gb'])
             self.assertEqual(87.5, stats['pools'][0]['capacity_utilization'])
@@ -6180,6 +6188,7 @@ class TestHPE3PARISCSIDriver(HPE3PARBaseDriver, test.TestCase):
 
             stats = self.driver.get_volume_stats(True)
             self.assertEqual('iSCSI', stats['storage_protocol'])
+            self.assertEqual('12345', stats['array_id'])
             self.assertEqual(24.0, stats['pools'][0]['total_capacity_gb'])
             self.assertEqual(3.0, stats['pools'][0]['free_capacity_gb'])
             self.assertEqual(87.5, stats['pools'][0]['capacity_utilization'])
index c3e63545f4d6b5f1a785eae6a98e8ddb78428194..2d0963a59baae0260479b154f516a41332e22165 100644 (file)
@@ -219,10 +219,11 @@ class HPE3PARCommon(object):
         3.0.5 - Adds v2 unmanaged replication support
         3.0.6 - Adding manage/unmanage snapshot support
         3.0.7 - Enable standard capabilities based on 3PAR licenses
+        3.0.8 - Optimize array ID retrieval
 
     """
 
-    VERSION = "3.0.7"
+    VERSION = "3.0.8"
 
     stats = {}
 
@@ -378,7 +379,7 @@ class HPE3PARCommon(object):
         if client is not None:
             client.logout()
 
-    def do_setup(self, context, volume=None, timeout=None):
+    def do_setup(self, context, volume=None, timeout=None, stats=None):
         if hpe3parclient is None:
             msg = _('You must install hpe3parclient before using 3PAR'
                     ' drivers. Run "pip install python-3parclient" to'
@@ -430,15 +431,19 @@ class HPE3PARCommon(object):
             LOG.error(msg)
             raise exception.InvalidInput(message=msg)
 
-        # get the client ID for provider_location
-        try:
-            self.client_login()
-            info = self.client.getStorageSystemInfo()
-            self.client.id = six.text_type(info['id'])
-        except Exception:
-            self.client.id = 0
-        finally:
-            self.client_logout()
+        # Get the client ID for provider_location. We only need to retrieve
+        # the ID directly from the array if the driver stats are not provided.
+        if not stats:
+            try:
+                self.client_login()
+                info = self.client.getStorageSystemInfo()
+                self.client.id = six.text_type(info['id'])
+            except Exception:
+                self.client.id = 0
+            finally:
+                self.client_logout()
+        else:
+            self.client.id = stats['array_id']
 
     def check_for_setup_error(self):
         if self.client:
@@ -1267,6 +1272,7 @@ class HPE3PARCommon(object):
                       'storage_protocol': None,
                       'vendor_name': 'Hewlett Packard Enterprise',
                       'volume_backend_name': None,
+                      'array_id': info['id'],
                       'pools': pools}
 
     def _check_license_enabled(self, valid_licenses,
index bd817fe89ed30e98e1e1b0beaee7029d535e8afd..42a422c5d9f8aa43775083e640e2fd379be452d4 100644 (file)
@@ -95,10 +95,11 @@ class HPE3PARFCDriver(driver.TransferVD,
         3.0.2 - Adds v2 managed replication support
         3.0.3 - Adds v2 unmanaged replication support
         3.0.4 - Adding manage/unmanage snapshot support
+        3.0.5 - Optimize array ID retrieval
 
     """
 
-    VERSION = "3.0.4"
+    VERSION = "3.0.5"
 
     def __init__(self, *args, **kwargs):
         super(HPE3PARFCDriver, self).__init__(*args, **kwargs)
@@ -114,7 +115,8 @@ class HPE3PARFCDriver(driver.TransferVD,
         # If replication is enabled and we cannot login, we do not want to
         # raise an exception so a failover can still be executed.
         try:
-            common.do_setup(None, volume, timeout=timeout)
+            common.do_setup(None, volume=volume, timeout=timeout,
+                            stats=self._stats)
             common.client_login()
         except Exception:
             if common._replication_enabled:
index d954c72e8dc7b783599d845e95c735a9a7392dbb..e9e487c42c26119a44d15b6341aaa3a32e6bc4fa 100644 (file)
@@ -107,10 +107,11 @@ class HPE3PARISCSIDriver(driver.TransferVD,
         3.0.4 - Adds v2 managed replication support
         3.0.5 - Adds v2 unmanaged replication support
         3.0.6 - Adding manage/unmanage snapshot support
+        3.0.7 - Optimize array ID retrieval
 
     """
 
-    VERSION = "3.0.6"
+    VERSION = "3.0.7"
 
     def __init__(self, *args, **kwargs):
         super(HPE3PARISCSIDriver, self).__init__(*args, **kwargs)
@@ -125,7 +126,8 @@ class HPE3PARISCSIDriver(driver.TransferVD,
         # If replication is enabled and we cannot login, we do not want to
         # raise an exception so a failover can still be executed.
         try:
-            common.do_setup(None, volume, timeout=timeout)
+            common.do_setup(None, volume=volume, timeout=timeout,
+                            stats=self._stats)
             common.client_login()
         except Exception:
             if common._replication_enabled: