def test_get_volume_stats(self):
self.flags(lock_path=self.tempdir)
+
+ def fake_safe_get(*args):
+ return "HP3PARFCDriver"
+
+ self.stubs.Set(self.driver.configuration, 'safe_get', fake_safe_get)
stats = self.driver.get_volume_stats(True)
self.assertEquals(stats['storage_protocol'], 'FC')
- self.assertEquals(stats['volume_backend_name'], 'HP3PARFCDriver')
+ self.assertEquals(stats['total_capacity_gb'], 'infinite')
+ self.assertEquals(stats['free_capacity_gb'], 'infinite')
class TestHP3PARISCSIDriver(HP3PARBaseDriver, test.TestCase):
def test_get_volume_stats(self):
self.flags(lock_path=self.tempdir)
+
+ def fake_safe_get(*args):
+ return "HP3PARFCDriver"
+
+ self.stubs.Set(self.driver.configuration, 'safe_get', fake_safe_get)
stats = self.driver.get_volume_stats(True)
self.assertEquals(stats['storage_protocol'], 'iSCSI')
- self.assertEquals(stats['volume_backend_name'], 'HP3PARISCSIDriver')
+ self.assertEquals(stats['total_capacity_gb'], 'infinite')
+ self.assertEquals(stats['free_capacity_gb'], 'infinite')
def test_update_volume_stats(self):
def fake_stats(*args):
return RADOS_DF_OUT, ''
+
+ def fake_safe_get(*args):
+ return "RBD"
+
self.stubs.Set(self.driver, '_execute', fake_stats)
+ self.stubs.Set(self.driver.configuration, 'safe_get', fake_safe_get)
expected = dict(
volume_backend_name='RBD',
vendor_name='Open Source',
def test_update_volume_stats_error(self):
def fake_exc(*args):
raise exception.ProcessExecutionError()
+
+ def fake_safe_get(*args):
+ return "RBD"
+
self.stubs.Set(self.driver, '_execute', fake_exc)
+ self.stubs.Set(self.driver.configuration, 'safe_get', fake_safe_get)
expected = dict(
volume_backend_name='RBD',
vendor_name='Open Source',
def get_volume_stats(self, refresh=False):
"""Return Volume Stats."""
- return {'driver_version': '1.0',
+ data = {'driver_version': '1.0',
'free_capacity_gb': 'unknown',
'reserved_percentage': 0,
'storage_protocol': 'aoe',
'total_capacity_gb': 'unknown',
- 'vendor_name': 'Coraid',
- 'volume_backend_name': 'EtherCloud ESM'}
+ 'vendor_name': 'Coraid'}
+ backend_name = self.configuration.safe_get('volume_backend_name')
+ data['volume_backend_name'] = backend_name or 'EtherCloud ESM'
+ return data
def local_path(self, volume):
pass
"""Retrieve status info from volume group."""
LOG.debug(_("Updating volume status"))
data = self.common.update_volume_status()
- data['volume_backend_name'] = 'EMCSMISISCSIDriver'
+ backend_name = self.configuration.safe_get('volume_backend_name')
+ data['volume_backend_name'] = backend_name or 'EMCSMISISCSIDriver'
data['storage_protocol'] = 'iSCSI'
self._stats = data
LOG.debug(_("Updating volume status"))
data = {}
- data['volume_backend_name'] = 'HuaweiISCSIDriver'
+ backend_name = self.configuration.safe_get('volume_backend_name')
+ data["volume_backend_name"] = backend_name or 'HuaweiISCSIDriver'
data['vendor_name'] = 'Huawei'
data['driver_version'] = '1.0'
data['storage_protocol'] = 'iSCSI'
LOG.debug(_("Updating volume status"))
data = {}
- data["volume_backend_name"] = self.__class__.__name__
+ backend_name = self.__class__.__name__
+ if self.configuration:
+ backend_name = self.configuration.safe_get('volume_backend_name')
+ data["volume_backend_name"] = backend_name or self.__class__.__name__
data["vendor_name"] = 'Nexenta'
data["driver_version"] = VERSION
data["storage_protocol"] = 'iSCSI'
def __init__(self, *args, **kwargs):
super(RBDDriver, self).__init__(*args, **kwargs)
self.configuration.append_config_values(rbd_opts)
- self._stats = dict(
- volume_backend_name='RBD',
- vendor_name='Open Source',
- driver_version=VERSION,
- storage_protocol='ceph',
- total_capacity_gb='unknown',
- free_capacity_gb='unknown',
- reserved_percentage=0)
+ self._stats = {}
def check_for_setup_error(self):
"""Returns an error if prerequisites aren't met"""
raise exception.VolumeBackendAPIException(data=exception_message)
def _update_volume_stats(self):
- stats = dict(
- total_capacity_gb='unknown',
- free_capacity_gb='unknown')
+ stats = {'vendor_name': 'Open Source',
+ 'driver_version': VERSION,
+ 'storage_protocol': 'ceph',
+ 'total_capacity_gb': 'unknown',
+ 'free_capacity_gb': 'unknown',
+ 'reserved_percentage': 0}
+ backend_name = self.configuration.safe_get('volume_backend_name')
+ stats['volume_backend_name'] = backend_name or 'RBD'
+
try:
stdout, _err = self._execute('rados', 'df', '--format', 'json')
new_stats = json.loads(stdout)
except exception.ProcessExecutionError:
# just log and return unknown capacities
LOG.exception(_('error refreshing volume stats'))
- self._stats.update(stats)
+ self._stats = stats
def get_volume_stats(self, refresh=False):
"""Return the current state of the volume service. If 'refresh' is
class HP3PARCommon():
- stats = {'driver_version': '1.0',
- 'free_capacity_gb': 'unknown',
- 'reserved_percentage': 0,
- 'storage_protocol': None,
- 'total_capacity_gb': 'unknown',
- 'vendor_name': 'Hewlett-Packard',
- 'volume_backend_name': None}
+ stats = {}
# Valid values for volume type extra specs
# The first value in the list is the default value
const = 0.0009765625
if refresh:
- try:
- cpg = client.getCPG(self.config.hp3par_cpg)
- if 'limitMiB' not in cpg['SDGrowth']:
- total_capacity = 'infinite'
- free_capacity = 'infinite'
- else:
- total_capacity = int(cpg['SDGrowth']['limitMiB'] * const)
- free_capacity = int((cpg['SDGrowth']['limitMiB'] -
- cpg['UsrUsage']['usedMiB']) * const)
-
- self.stats['total_capacity_gb'] = total_capacity
- self.stats['free_capacity_gb'] = free_capacity
- except hpexceptions.HTTPNotFound:
- err = (_("CPG (%s) doesn't exist on array")
- % self.config.hp3par_cpg)
- LOG.error(err)
- raise exception.InvalidInput(reason=err)
+ self._update_volume_stats(client)
return self.stats
+ def _update_volume_stats(self, client):
+
+ # storage_protocol and volume_backend_name are
+ # set in the child classes
+ stats = {'driver_version': '1.0',
+ 'free_capacity_gb': 'unknown',
+ 'reserved_percentage': 0,
+ 'storage_protocol': None,
+ 'total_capacity_gb': 'unknown',
+ 'vendor_name': 'Hewlett-Packard',
+ 'volume_backend_name': None}
+
+ try:
+ cpg = client.getCPG(self.config.hp3par_cpg)
+ if 'limitMiB' not in cpg['SDGrowth']:
+ total_capacity = 'infinite'
+ free_capacity = 'infinite'
+ else:
+ total_capacity = int(cpg['SDGrowth']['limitMiB'] * const)
+ free_capacity = int((cpg['SDGrowth']['limitMiB'] -
+ cpg['UsrUsage']['usedMiB']) * const)
+
+ stats['total_capacity_gb'] = total_capacity
+ stats['free_capacity_gb'] = free_capacity
+ except hpexceptions.HTTPNotFound:
+ err = (_("CPG (%s) doesn't exist on array")
+ % self.config.hp3par_cpg)
+ LOG.error(err)
+ raise exception.InvalidInput(reason=err)
+
+ self.stats = stats
+
def create_vlun(self, volume, host, client):
"""
In order to export a volume on a 3PAR box, we have to
def get_volume_stats(self, refresh):
stats = self.common.get_volume_stats(refresh, self.client)
stats['storage_protocol'] = 'FC'
- stats['volume_backend_name'] = 'HP3PARFCDriver'
+ backend_name = self.configuration.safe_get('volume_backend_name')
+ stats['volume_backend_name'] = backend_name or self.__class__.__name__
return stats
def do_setup(self, context):
def get_volume_stats(self, refresh):
stats = self.common.get_volume_stats(refresh, self.client)
stats['storage_protocol'] = 'iSCSI'
- stats['volume_backend_name'] = 'HP3PARISCSIDriver'
+ backend_name = self.configuration.safe_get('volume_backend_name')
+ stats['volume_backend_name'] = backend_name or self.__class__.__name__
return stats
def do_setup(self, context):
If 'refresh' is True, run the update first.
"""
stats = {
- 'volume_backend_name': 'Scality_SOFS',
'vendor_name': 'Scality',
'driver_version': '1.0',
'storage_protocol': 'scality',
'free_capacity_gb': 'infinite',
'reserved_percentage': 0,
}
+ backend_name = self.configuration.safe_get('volume_backend_name')
+ stats['volume_backend_name'] = backend_name or 'Scality_SOFS'
return stats
def copy_image_to_volume(self, context, volume, image_service, image_id):
def __init__(self, *args, **kwargs):
super(SheepdogDriver, self).__init__(*args, **kwargs)
- self._stats = dict(
- volume_backend_name='sheepdog',
- vendor_name='Open Source',
- dirver_version='1.0',
- storage_protocol='sheepdog',
- total_capacity_gb='unknown',
- free_capacity_gb='unknown',
- reserved_percentage=0,
- QoS_support=False)
self.stats_pattern = re.compile(r'[\w\s%]*Total\s(\d+)\s(\d+)*')
+ self._stats = {}
def check_for_setup_error(self):
"""Returns an error if prerequisites aren't met"""
def _update_volume_stats(self):
stats = {}
+
+ backend_name = "sheepdog"
+ if self.configuration:
+ backend_name = self.configuration.safe_get('volume_backend_name')
+ stats["volume_backend_name"] = backend_name or 'sheepdog'
+ stats['vendor_name'] = 'Open Source'
+ stats['dirver_version'] = '1.0'
+ stats['storage_protocol'] = 'sheepdog'
+ stats['total_capacity_gb'] = 'unknown'
+ stats['free_capacity_gb'] = 'unknown'
+ stats['reserved_percentage'] = 0
+ stats['QoS_support'] = False
+
try:
stdout, _err = self._execute('collie', 'node', 'info', '-r')
m = self.stats_pattern.match(stdout)
stats['free_capacity_gb'] = (total - used) / (1024 ** 3)
except exception.ProcessExecutionError:
LOG.exception(_('error refreshing volume stats'))
- self._stats.update(stats)
+
+ self._stats = stats
def get_volume_stats(self, refresh=False):
if refresh:
def get_volume_stats(self, refresh=False):
if refresh or not self._stats:
- self._stats = dict(
- volume_backend_name='XenAPINFS',
- vendor_name='Open Source',
- driver_version='1.0',
- storage_protocol='xensm',
- total_capacity_gb='unknown',
- free_capacity_gb='unknown',
- reserved_percentage=0)
+ data = {}
+
+ backend_name = self.configuration.safe_get('volume_backend_name')
+ data["volume_backend_name"] = backend_name or 'XenAPINFS',
+ data['vendor_name'] = 'Open Source',
+ data['driver_version'] = '1.0'
+ data['storage_protocol'] = 'xensm'
+ data['total_capacity_gb'] = 'unknown'
+ data['free_capacity_gb'] = 'unknown'
+ data['reserved_percentage'] = 0
+ self._stats = data
return self._stats