RBD: support to report backend state

This patch adds the ability to report backend state to RBD driver.

Partial-Implements: blueprint report-backend-state-in-service-list

Change-Id: Ib703786d77621ec139e4f3981506ed117b737524
This commit is contained in:
jeremy.zhang 2018-06-05 16:21:44 +08:00
parent 9d263f711d
commit 0062968568
3 changed files with 12 additions and 3 deletions

View File

@ -1201,7 +1201,8 @@ class RBDTestCase(test.TestCase):
provisioned_capacity_gb=mock.sentinel.provisioned_capacity_gb,
max_over_subscription_ratio=1.0,
multiattach=False,
location_info=expected_location_info)
location_info=expected_location_info,
backend_state='up')
if replication_enabled:
targets = [{'backend_id': 'secondary-backend'},
@ -1244,7 +1245,8 @@ class RBDTestCase(test.TestCase):
thin_provisioning_support=True,
max_over_subscription_ratio=1.0,
multiattach=False,
location_info=expected_location_info)
location_info=expected_location_info,
backend_state='up')
my_safe_get = MockDriverConfig(rbd_exclusive_cinder_pool=True)
self.mock_object(self.driver.configuration, 'safe_get',
@ -1280,7 +1282,8 @@ class RBDTestCase(test.TestCase):
multiattach=False,
max_over_subscription_ratio=1.0,
thin_provisioning_support=True,
location_info=expected_location_info)
location_info=expected_location_info,
backend_state='down')
with mock.patch.object(self.driver, '_get_fsid') as mock_get_fsid:
mock_get_fsid.return_value = expected_fsid

View File

@ -495,6 +495,7 @@ class RBDDriver(driver.CloneableImageVD, driver.MigrateVD,
'max_over_subscription_ratio': (
self.configuration.safe_get('max_over_subscription_ratio')),
'location_info': location_info,
'backend_state': 'down'
}
backend_name = self.configuration.safe_get('volume_backend_name')
@ -514,6 +515,8 @@ class RBDDriver(driver.CloneableImageVD, driver.MigrateVD,
if not self.configuration.safe_get('rbd_exclusive_cinder_pool'):
total_gbi = self._get_usage_info()
stats['provisioned_capacity_gb'] = total_gbi
stats['backend_state'] = 'up'
except self.rados.Error:
# just log and return unknown capacities and let scheduler set
# provisioned_capacity_gb = allocated_capacity_gb

View File

@ -0,0 +1,3 @@
---
features:
- Allow rbd driver to report backend state.