From: John Griffith Date: Tue, 30 Apr 2013 19:05:40 +0000 (-0600) Subject: Fix LHN driver to allow backend name configuration X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=006d673d24778abe6c47e3ee7e1a19e163912440;p=openstack-build%2Fcinder-build.git Fix LHN driver to allow backend name configuration 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 --- diff --git a/cinder/volume/drivers/san/hp_lefthand.py b/cinder/volume/drivers/san/hp_lefthand.py index af184d0e0..6dff285a0 100644 --- a/cinder/volume/drivers/san/hp_lefthand.py +++ b/cinder/volume/drivers/san/hp_lefthand.py @@ -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