Merge "Added 'bootable volume' filter for non-admin user"

This commit is contained in:
Jenkins 2016-01-21 23:58:36 +00:00 committed by Gerrit Code Review
commit 85e2ae3566
2 changed files with 22 additions and 5 deletions

View File

@ -38,12 +38,14 @@ from cinder.volume import volume_types
query_volume_filters_opt = cfg.ListOpt('query_volume_filters',
default=['name', 'status', 'metadata',
'availability_zone'],
'availability_zone',
'bootable'],
help="Volume filter options which "
"non-admin user could use to "
"query volumes. Default values "
"are: ['name', 'status', "
"'metadata', 'availability_zone']")
"'metadata', 'availability_zone',"
"'bootable']")
CONF = cfg.CONF
CONF.register_opt(query_volume_filters_opt)

View File

@ -1472,6 +1472,20 @@ class VolumeApiTest(test.TestCase):
filters={'availability_zone': 'nova'}, viewable_admin_meta=True,
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')
def test_get_volumes_filter_with_invalid_filter(self, get_all):
req = mock.MagicMock()
@ -1503,9 +1517,10 @@ class VolumeApiTest(test.TestCase):
sort_keys=['display_name'], filters={}, offset=0)
def test_get_volume_filter_options_using_config(self):
self.override_config('query_volume_filters', ['name', 'status',
'metadata'])
self.assertEqual(['name', 'status', 'metadata'],
filter_list = ['name', 'status', 'metadata', 'bootable',
'availability_zone']
self.override_config('query_volume_filters', filter_list)
self.assertEqual(filter_list,
self.controller._get_volume_filter_options())