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
This commit is contained in:
John Griffith 2013-04-30 13:05:40 -06:00
parent 11a949c148
commit 006d673d24

View 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._update_backend_status()
self.stats['total_capacity_gb'] = int(total_capacity) / GB
self.stats['free_capacity_gb'] = int(free_capacity) / GB
return self.device_stats
return self.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