]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Minor optimization in create_volume in HpSanISCSIDriver
authorNirmal Ranganathan <rnirmal@gmail.com>
Fri, 2 Nov 2012 16:49:17 +0000 (11:49 -0500)
committerNirmal Ranganathan <rnirmal@gmail.com>
Fri, 2 Nov 2012 18:37:14 +0000 (13:37 -0500)
Removing extra call to getClusterInfo in HpSANISCSIDriver
on every create_volume call. The cluster info is now
being lazily stored in a local variable.

Fixes bug 1074201

Change-Id: Iadf8383dbf87a8e82c649c312c67978c7dd3df71

cinder/volume/san/hp_lefthand.py

index 0f27150b1a73974cbd0fe1e83120296769520e13..e2ec46ccec9c2e0ee5ce74ffcb6eb5106e8e200f 100644 (file)
@@ -54,6 +54,10 @@ class HpSanISCSIDriver(SanISCSIDriver):
     compute layer.
     """
 
+    def __init__(self, *args, **kwargs):
+        super(HpSanISCSIDriver, self).__init__(*args, **kwargs)
+        self.cluster_vip = None
+
     def _cliq_run(self, verb, cliq_args):
         """Runs a CLIQ command over SSH, without doing any result parsing"""
         cliq_arg_strings = []
@@ -173,7 +177,6 @@ class HpSanISCSIDriver(SanISCSIDriver):
         """Creates a volume."""
         cliq_args = {}
         cliq_args['clusterName'] = FLAGS.san_clustername
-        #TODO(justinsb): Should we default to inheriting thinProvision?
         cliq_args['thinProvision'] = '1' if FLAGS.san_thin_provision else '0'
         cliq_args['volumeName'] = volume['name']
         if int(volume['size']) == 0:
@@ -190,8 +193,9 @@ class HpSanISCSIDriver(SanISCSIDriver):
         #TODO(justinsb): Is this always 1? Does it matter?
         cluster_interface = '1'
 
-        cluster_vip = self._cliq_get_cluster_vip(cluster_name)
-        iscsi_portal = cluster_vip + ":3260," + cluster_interface
+        if not self.cluster_vip:
+            self.cluster_vip = self._cliq_get_cluster_vip(cluster_name)
+        iscsi_portal = self.cluster_vip + ":3260," + cluster_interface
 
         model_update = {}
 
@@ -220,7 +224,6 @@ class HpSanISCSIDriver(SanISCSIDriver):
         self._cliq_run_xml("deleteVolume", cliq_args)
 
     def local_path(self, volume):
-        # TODO(justinsb): Is this needed here?
         msg = _("local_path not supported")
         raise exception.VolumeBackendAPIException(data=msg)