Skip to content

Commit

Permalink
Fix LHN driver to allow backend name configuration
Browse files Browse the repository at this point in the history
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
  • Loading branch information
j-griffith committed May 1, 2013
1 parent 11a949c commit 006d673
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions cinder/volume/drivers/san/hp_lefthand.py
Expand Up @@ -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)
Expand Down Expand Up @@ -296,14 +290,25 @@ def terminate_connection(self, volume, connector, **kwargs):

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

0 comments on commit 006d673

Please sign in to comment.