From ee1ac541253c42e3d94c907cb5b49a1172d68817 Mon Sep 17 00:00:00 2001 From: Ivan Kolodyazhny Date: Wed, 28 Nov 2018 17:34:02 +0200 Subject: [PATCH] Remove deprecated query_volume_filters config option query_volume_filters was deprecated in Pike with Icee6c22621489f93614f4adf071329d8d2115637 and it should be safe to remove it now. Change-Id: Icd311db7f88c3c274d9a362eb96519e46c7e4d17 --- cinder/api/common.py | 14 +------------- cinder/api/v2/volumes.py | 2 +- cinder/tests/unit/api/v2/test_volumes.py | 7 ++++--- cinder/tests/unit/api/v3/test_volumes.py | 6 ++++-- doc/source/admin/generalized_filters.rst | 6 ++---- ...move-query-volume-filters-b59958fc68d3abb4.yaml | 6 ++++++ 6 files changed, 18 insertions(+), 23 deletions(-) create mode 100644 releasenotes/notes/remove-query-volume-filters-b59958fc68d3abb4.yaml diff --git a/cinder/api/common.py b/cinder/api/common.py index 98fab59dc72..d01602cc5a9 100644 --- a/cinder/api/common.py +++ b/cinder/api/common.py @@ -39,19 +39,7 @@ api_common_opts = [ cfg.StrOpt('resource_query_filters_file', default='/etc/cinder/resource_filters.json', help="Json file indicating user visible filter " - "parameters for list queries.", - deprecated_name='query_volume_filters'), - cfg.ListOpt('query_volume_filters', - default=['name', 'status', 'metadata', - 'availability_zone', - 'bootable', 'group_id'], - deprecated_for_removal=True, - help="Volume filter options which " - "non-admin user could use to " - "query volumes. Default values " - "are: ['name', 'status', " - "'metadata', 'availability_zone' ," - "'bootable', 'group_id']") + "parameters for list queries."), ] CONF = cfg.CONF diff --git a/cinder/api/v2/volumes.py b/cinder/api/v2/volumes.py index b8dbedb3c44..67244b90ca1 100644 --- a/cinder/api/v2/volumes.py +++ b/cinder/api/v2/volumes.py @@ -274,7 +274,7 @@ class VolumeController(wsgi.Controller): def _get_volume_filter_options(self): """Return volume search options allowed by non-admin.""" - return CONF.query_volume_filters + return common.get_enabled_resource_filters('volume')['volume'] @validation.schema(volumes.update, mv.V2_BASE_VERSION, mv.get_prior_version(mv.SUPPORT_VOLUME_SCHEMA_CHANGES)) diff --git a/cinder/tests/unit/api/v2/test_volumes.py b/cinder/tests/unit/api/v2/test_volumes.py index da001e4c092..73c50e19c29 100644 --- a/cinder/tests/unit/api/v2/test_volumes.py +++ b/cinder/tests/unit/api/v2/test_volumes.py @@ -1675,8 +1675,9 @@ class VolumeApiTest(test.TestCase): sort_keys=['display_name'], filters={}, offset=0) def test_get_volume_filter_options_using_config(self): - filter_list = ['name', 'status', 'metadata', 'bootable', - 'availability_zone'] - self.override_config('query_volume_filters', filter_list) + filter_list = ["name", "status", "metadata", "bootable", + "migration_status", "availability_zone", "group_id"] + self.override_config('resource_query_filters_file', + {'volume': filter_list}) self.assertEqual(filter_list, self.controller._get_volume_filter_options()) diff --git a/cinder/tests/unit/api/v3/test_volumes.py b/cinder/tests/unit/api/v3/test_volumes.py index 94fcdd85b05..23d0a9bcae4 100644 --- a/cinder/tests/unit/api/v3/test_volumes.py +++ b/cinder/tests/unit/api/v3/test_volumes.py @@ -68,7 +68,8 @@ class VolumeApiTest(test.TestCase): req.headers = mv.get_mv_header(mv.BASE_VERSION) req.environ['cinder.context'].is_admin = True - self.override_config('query_volume_filters', 'bootable') + self.override_config('resource_query_filters_file', + {'volume': ['bootable']}) self.controller.index(req) filters = req.params.copy() @@ -86,7 +87,8 @@ class VolumeApiTest(test.TestCase): req.api_version_request = mv.get_api_version( mv.VOLUME_LIST_BOOTABLE) - self.override_config('query_volume_filters', 'bootable') + self.override_config('resource_query_filters_file', + {'volume': ['bootable']}) self.controller.index(req) filters = req.params.copy() diff --git a/doc/source/admin/generalized_filters.rst b/doc/source/admin/generalized_filters.rst index 711317023fd..cee4ff190df 100644 --- a/doc/source/admin/generalized_filters.rst +++ b/doc/source/admin/generalized_filters.rst @@ -5,10 +5,8 @@ Generalized filters Background ---------- -Cinder introduced generalized resource filters since Pike, it has the -same purpose as ``query_volume_filters`` option, but it's more convenient -and can be applied to more cinder resources, administrator can control the -allowed filter keys for **non-admin** user by editing the filter +Cinder introduced generalized resource filters since Pike. Administrator can +control the allowed filter keys for **non-admin** user by editing the filter configuration file. Also since this feature, cinder will raise ``400 BadRequest`` if any invalid query filter is specified. diff --git a/releasenotes/notes/remove-query-volume-filters-b59958fc68d3abb4.yaml b/releasenotes/notes/remove-query-volume-filters-b59958fc68d3abb4.yaml new file mode 100644 index 00000000000..4d38b38323e --- /dev/null +++ b/releasenotes/notes/remove-query-volume-filters-b59958fc68d3abb4.yaml @@ -0,0 +1,6 @@ +--- +upgrade: + - | + Deprecated config option `query_volume_filters` is removed now. Please, + use config file described in resource_query_filters_file to configure + allowed volume filters.