Merge "Add `fsid` to RBD store properties"

This commit is contained in:
Zuul 2024-12-04 21:58:29 +00:00 committed by Gerrit Code Review
commit e0f5bb97c2
5 changed files with 36 additions and 4 deletions

View File

@ -9,7 +9,8 @@
"properties": {
"pool": "pool1",
"chunk_size": 65536,
"thin_provisioning": false
"thin_provisioning": false,
"fsid": "ddf1b25f-1907-449e-89f6-cd30a679c8dc",
}
},
{

View File

@ -92,12 +92,34 @@ class InfoController(object):
return {'stores': backends}
@staticmethod
def _get_fsid_from_url(store_detail):
fsid = None
prefix = 'rbd://'
url_prefix = store_detail.url_prefix
# When fsid and pool info are not available,
# url_prefix is same as prefix
if url_prefix and url_prefix.startswith(
prefix) and len(url_prefix) > len(prefix):
# Remove last trailing forward slash
url_prefix = (
url_prefix[:-1] if url_prefix.endswith('/') else url_prefix)
pieces = url_prefix[len(prefix):].split('/')
# We expect the rbd store's url format to look like 'rbd://%s/%s/'
# where the fsid is in the first position; if there are more than
# 2 pieces, then something has changed in the driver code, so we
# won't set the fsid
if len(pieces) == 2:
fsid = pieces[0]
return fsid
@staticmethod
def _get_rbd_properties(store_detail):
return {
'chunk_size': store_detail.chunk_size,
'pool': store_detail.pool,
'thin_provisioning': store_detail.thin_provisioning
'thin_provisioning': store_detail.thin_provisioning,
'fsid': InfoController._get_fsid_from_url(store_detail),
}
@staticmethod

View File

@ -73,9 +73,12 @@ class MultiStoreClearingUnitTest(test_utils.BaseTestCase):
:param passing_config: making store driver passes basic configurations.
:returns: the number of how many store drivers been loaded.
"""
fake_fsid = "db437934-7e1c-445b-a4f5-7cc5bc44ba1b"
rbd_store.rados = mock.MagicMock()
rbd_store.rbd = mock.MagicMock()
rbd_store.Store._set_url_prefix = mock.MagicMock()
rbd_store.Store.get_connection = mock.MagicMock()
conn_mock = rbd_store.Store.get_connection.return_value.__enter__()
conn_mock.get_fsid.return_value = fake_fsid
cinder.cinderclient = mock.MagicMock()
cinder.Store.get_cinderclient = mock.MagicMock()
swift.swiftclient = mock.MagicMock()

View File

@ -93,7 +93,8 @@ class TestInfoControllers(base.MultiStoreClearingUnitTest):
self.assertIsNotNone(stores['properties'])
def test_get_stores_detail_properties(self):
store_attributes = {'rbd': ['chunk_size', 'pool', 'thin_provisioning'],
store_attributes = {'rbd': ['chunk_size', 'pool', 'thin_provisioning',
'fsid'],
'file': ['data_dir', 'chunk_size',
'thin_provisioning'],
'cinder': ['volume_type', 'use_multipath'],

View File

@ -0,0 +1,5 @@
---
other:
- |
Updated the stores detail API response to include
``fsid`` field in RBD store properties.