Block Device Driver: report pools in volume stats
Block Device Driver doesn't support pools so it will report only one pool like LVM implementation. Change-Id: I7be456c8076c672586a9b9b6aa5425d3a1476b19 Closes-Bug: #1592980
This commit is contained in:
parent
caee4d0459
commit
948ac4ab45
@ -153,16 +153,18 @@ class TestBlockDeviceDriver(cinder.test.TestCase):
|
||||
gud_mocked:
|
||||
self.drv._update_volume_stats()
|
||||
|
||||
self.assertEqual({'total_capacity_gb': 2,
|
||||
'free_capacity_gb': 2,
|
||||
'reserved_percentage':
|
||||
self.configuration.reserved_percentage,
|
||||
'QoS_support': False,
|
||||
'vendor_name': "Open Source",
|
||||
'driver_version': self.drv.VERSION,
|
||||
'storage_protocol': 'unknown',
|
||||
'volume_backend_name': 'BlockDeviceDriver',
|
||||
}, self.drv._stats)
|
||||
reserved_percentage = self.configuration.reserved_percentage
|
||||
self.assertEqual({
|
||||
'vendor_name': "Open Source",
|
||||
'driver_version': self.drv.VERSION,
|
||||
'volume_backend_name': 'BlockDev',
|
||||
'storage_protocol': 'unknown',
|
||||
'pools': [{
|
||||
'QoS_support': False,
|
||||
'total_capacity_gb': 2,
|
||||
'free_capacity_gb': 2,
|
||||
'reserved_percentage': reserved_percentage,
|
||||
'pool_name': 'BlockDev'}]}, self.drv._stats)
|
||||
gud_mocked.assert_called_once_with()
|
||||
ds_mocked.assert_called_once_with()
|
||||
|
||||
|
@ -44,7 +44,7 @@ CONF.register_opts(volume_opts)
|
||||
|
||||
class BlockDeviceDriver(driver.BaseVD, driver.LocalVD,
|
||||
driver.CloneableImageVD, driver.TransferVD):
|
||||
VERSION = '2.2.0'
|
||||
VERSION = '2.3.0'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(BlockDeviceDriver, self).__init__(*args, **kwargs)
|
||||
@ -62,12 +62,13 @@ class BlockDeviceDriver(driver.BaseVD, driver.LocalVD,
|
||||
def check_for_setup_error(self):
|
||||
pass
|
||||
|
||||
def _update_provider_location(self, object, device):
|
||||
def _update_provider_location(self, obj, device):
|
||||
# We update provider_location and host to mark device as used to
|
||||
# avoid race with other threads.
|
||||
# TODO(ynesenenko): need to remove DB access from driver
|
||||
object.update({'provider_location': device, 'host': self.host})
|
||||
object.save()
|
||||
host = '{host}#{pool}'.format(host=self.host, pool=self.get_pool(obj))
|
||||
obj.update({'provider_location': device, 'host': host})
|
||||
obj.save()
|
||||
|
||||
@utils.synchronized('block_device', external=True)
|
||||
def create_volume(self, volume):
|
||||
@ -153,18 +154,26 @@ class BlockDeviceDriver(driver.BaseVD, driver.LocalVD,
|
||||
total_size += size
|
||||
|
||||
LOG.debug("Updating volume stats.")
|
||||
backend_name = self.configuration.safe_get('volume_backend_name')
|
||||
data = {'total_capacity_gb': total_size / units.Ki,
|
||||
'free_capacity_gb': free_size / units.Ki,
|
||||
'reserved_percentage': self.configuration.reserved_percentage,
|
||||
'QoS_support': False,
|
||||
'volume_backend_name': backend_name or self.__class__.__name__,
|
||||
'vendor_name': "Open Source",
|
||||
'driver_version': self.VERSION,
|
||||
'storage_protocol': 'unknown'}
|
||||
data = {
|
||||
'volume_backend_name': self.backend_name,
|
||||
'vendor_name': "Open Source",
|
||||
'driver_version': self.VERSION,
|
||||
'storage_protocol': 'unknown',
|
||||
'pools': []}
|
||||
|
||||
single_pool = {
|
||||
'pool_name': data['volume_backend_name'],
|
||||
'total_capacity_gb': total_size / units.Ki,
|
||||
'free_capacity_gb': free_size / units.Ki,
|
||||
'reserved_percentage': self.configuration.reserved_percentage,
|
||||
'QoS_support': False}
|
||||
|
||||
data['pools'].append(single_pool)
|
||||
self._stats = data
|
||||
|
||||
def get_pool(self, volume):
|
||||
return self.backend_name
|
||||
|
||||
def _get_used_paths(self, lst):
|
||||
used_dev = set()
|
||||
for item in lst:
|
||||
|
3
releasenotes/notes/bdd-pools-stats-afb4398daa9248de.yaml
Normal file
3
releasenotes/notes/bdd-pools-stats-afb4398daa9248de.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
---
|
||||
features:
|
||||
- Report pools in volume stats for Block Device Driver.
|
Loading…
Reference in New Issue
Block a user