Merge pull request #21024 from s0nea/wip-dashboard-return-features-list

mgr/dashboard: Convert the RBD feature names to a list of strings

Reviewed-by: Ricardo Dias <rdias@suse.com>
Reviewed-by: Ricardo Marques <rimarques@suse.com>
Reviewed-by: Stephan Müller <smueller@suse.com>
This commit is contained in:
Lenz Grimmer 2018-03-27 11:45:54 +02:00 committed by GitHub
commit d5e54fda5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 7 deletions

View File

@ -40,7 +40,7 @@ class RbdTest(DashboardTestCase):
self.assertEqual(img1['num_objs'], 256)
self.assertEqual(img1['obj_size'], 4194304)
self.assertEqual(img1['features_name'],
'deep-flatten, exclusive-lock, fast-diff, layering, object-map')
['deep-flatten', 'exclusive-lock', 'fast-diff', 'layering', 'object-map'])
img2 = data['value'][1]
self.assertEqual(img2['name'], 'img2')
@ -48,7 +48,7 @@ class RbdTest(DashboardTestCase):
self.assertEqual(img2['num_objs'], 512)
self.assertEqual(img2['obj_size'], 4194304)
self.assertEqual(img2['features_name'],
'deep-flatten, exclusive-lock, fast-diff, layering, object-map')
['deep-flatten', 'exclusive-lock', 'fast-diff', 'layering', 'object-map'])
@authenticate
def test_create(self):
@ -70,7 +70,8 @@ class RbdTest(DashboardTestCase):
self.assertEqual(rbd['num_objs'], 1)
self.assertEqual(rbd['obj_size'], 4194304)
self.assertEqual(rbd['features_name'],
'deep-flatten, exclusive-lock, fast-diff, layering, object-map')
['deep-flatten', 'exclusive-lock', 'fast-diff', 'layering',
'object-map'])
break
@authenticate
@ -100,8 +101,9 @@ class RbdTest(DashboardTestCase):
self.assertEqual(rbd['size'], 10240)
self.assertEqual(rbd['num_objs'], 1)
self.assertEqual(rbd['obj_size'], 4194304)
self.assertEqual(rbd['features_name'], 'data-pool, deep-flatten, exclusive-lock, '
'fast-diff, layering, object-map')
self.assertEqual(rbd['features_name'],
['data-pool', 'deep-flatten', 'exclusive-lock', 'fast-diff',
'layering', 'object-map'])
break
self._ceph_cmd(['osd', 'pool', 'delete', 'data_pool', 'data_pool',

View File

@ -34,11 +34,11 @@ class Rbd(RESTController):
Formats the bitmask:
>>> Rbd._format_bitmask(45)
'deep-flatten, exclusive-lock, layering, object-map'
['deep-flatten', 'exclusive-lock', 'layering', 'object-map']
"""
names = [val for key, val in Rbd.RBD_FEATURES_NAME_MAPPING.items()
if key & features == key]
return ', '.join(sorted(names))
return sorted(names)
@staticmethod
def _format_features(features):