]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix LHN driver to allow backend name configuration
authorJohn Griffith <john.griffith@solidfire.com>
Tue, 30 Apr 2013 19:05:40 +0000 (13:05 -0600)
committerJohn Griffith <john.griffith@solidfire.com>
Wed, 1 May 2013 04:06:44 +0000 (22:06 -0600)
The LHN driver wasn't allowing custom volume_backend_name to be set
via multi-backend configuration input.  In addition there were some
issues with the updating that are also addressed in this patch.

There are other drivers that are going to need updated/fixed for
this same problem, but those will be addressed in a separate patch/bug.

Fixes bug: 1173037

Change-Id: Iae247a500739d02e145511ebe96dddaff8966419

cinder/volume/drivers/san/hp_lefthand.py

index af184d0e0e55129504bebcad1277287133df357f..6dff285a0af0250c9e5d323d740e81201802c07a 100644 (file)
@@ -51,13 +51,7 @@ class HpSanISCSIDriver(SanISCSIDriver):
     compute layer.
     """
 
-    stats = {'driver_version': '1.0',
-             'free_capacity_gb': 'unknown',
-             'reserved_percentage': 0,
-             'storage_protocol': 'iSCSI',
-             'total_capacity_gb': 'unknown',
-             'vendor_name': 'Hewlett-Packard',
-             'volume_backend_name': 'HpSanISCSIDriver'}
+    device_stats = {}
 
     def __init__(self, *args, **kwargs):
         super(HpSanISCSIDriver, self).__init__(*args, **kwargs)
@@ -296,14 +290,25 @@ class HpSanISCSIDriver(SanISCSIDriver):
 
     def get_volume_stats(self, refresh):
         if refresh:
-            cliq_args = {}
-            result_xml = self._cliq_run_xml("getClusterInfo", cliq_args)
-            cluster_node = result_xml.find("response/cluster")
-            total_capacity = cluster_node.attrib.get("spaceTotal")
-            free_capacity = cluster_node.attrib.get("unprovisionedSpace")
-            GB = 1073741824
-
-            self.stats['total_capacity_gb'] = int(total_capacity) / GB
-            self.stats['free_capacity_gb'] = int(free_capacity) / GB
-
-        return self.stats
+            self._update_backend_status()
+
+        return self.device_stats
+
+    def _update_backend_status(self):
+        data = {}
+        backend_name = self.configuration.safe_get('volume_backend_name')
+        data['volume_backend_name'] = backend_name or self.__class__.__name__
+        data['driver_version'] = '1.0'
+        data['reserved_percentage'] = 0
+        data['storage_protocol'] = 'iSCSI'
+        data['vendor_name'] = 'Hewlett-Packard'
+
+        result_xml = self._cliq_run_xml("getClusterInfo", {})
+        cluster_node = result_xml.find("response/cluster")
+        total_capacity = cluster_node.attrib.get("spaceTotal")
+        free_capacity = cluster_node.attrib.get("unprovisionedSpace")
+        GB = 1073741824
+
+        data['total_capacity_gb'] = int(total_capacity) / GB
+        data['free_capacity_gb'] = int(free_capacity) / GB
+        self.device_stats = data