Merge "Added 'bootable volume' filter for non-admin user"
This commit is contained in:
commit
85e2ae3566
@ -38,12 +38,14 @@ from cinder.volume import volume_types
|
|||||||
|
|
||||||
query_volume_filters_opt = cfg.ListOpt('query_volume_filters',
|
query_volume_filters_opt = cfg.ListOpt('query_volume_filters',
|
||||||
default=['name', 'status', 'metadata',
|
default=['name', 'status', 'metadata',
|
||||||
'availability_zone'],
|
'availability_zone',
|
||||||
|
'bootable'],
|
||||||
help="Volume filter options which "
|
help="Volume filter options which "
|
||||||
"non-admin user could use to "
|
"non-admin user could use to "
|
||||||
"query volumes. Default values "
|
"query volumes. Default values "
|
||||||
"are: ['name', 'status', "
|
"are: ['name', 'status', "
|
||||||
"'metadata', 'availability_zone']")
|
"'metadata', 'availability_zone',"
|
||||||
|
"'bootable']")
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
CONF.register_opt(query_volume_filters_opt)
|
CONF.register_opt(query_volume_filters_opt)
|
||||||
|
@ -1472,6 +1472,20 @@ class VolumeApiTest(test.TestCase):
|
|||||||
filters={'availability_zone': 'nova'}, viewable_admin_meta=True,
|
filters={'availability_zone': 'nova'}, viewable_admin_meta=True,
|
||||||
offset=0)
|
offset=0)
|
||||||
|
|
||||||
|
@mock.patch('cinder.volume.api.API.get_all')
|
||||||
|
def test_get_volumes_filter_with_bootable(self, get_all):
|
||||||
|
req = mock.MagicMock()
|
||||||
|
ctxt = context.RequestContext('fake', 'fake', auth_token=True)
|
||||||
|
req.environ = {'cinder.context': ctxt}
|
||||||
|
req.params = {'bootable': 1}
|
||||||
|
self.controller._view_builder.detail_list = mock.Mock()
|
||||||
|
self.controller._get_volumes(req, True)
|
||||||
|
get_all.assert_called_once_with(
|
||||||
|
ctxt, None, CONF.osapi_max_limit,
|
||||||
|
sort_keys=['created_at'], sort_dirs=['desc'],
|
||||||
|
filters={'bootable': True}, viewable_admin_meta=True,
|
||||||
|
offset=0)
|
||||||
|
|
||||||
@mock.patch('cinder.volume.api.API.get_all')
|
@mock.patch('cinder.volume.api.API.get_all')
|
||||||
def test_get_volumes_filter_with_invalid_filter(self, get_all):
|
def test_get_volumes_filter_with_invalid_filter(self, get_all):
|
||||||
req = mock.MagicMock()
|
req = mock.MagicMock()
|
||||||
@ -1503,9 +1517,10 @@ class VolumeApiTest(test.TestCase):
|
|||||||
sort_keys=['display_name'], filters={}, offset=0)
|
sort_keys=['display_name'], filters={}, offset=0)
|
||||||
|
|
||||||
def test_get_volume_filter_options_using_config(self):
|
def test_get_volume_filter_options_using_config(self):
|
||||||
self.override_config('query_volume_filters', ['name', 'status',
|
filter_list = ['name', 'status', 'metadata', 'bootable',
|
||||||
'metadata'])
|
'availability_zone']
|
||||||
self.assertEqual(['name', 'status', 'metadata'],
|
self.override_config('query_volume_filters', filter_list)
|
||||||
|
self.assertEqual(filter_list,
|
||||||
self.controller._get_volume_filter_options())
|
self.controller._get_volume_filter_options())
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user