Remove allow_pagination and allow_sorting config options
They were deprecated in Newton. This patch cleans them up. Note: it does not mean that the features will not work anymore. On the contrary, now API will consistently sort and paginate for plugins that honour the relevant sorting/pagination parameters. Note2: base resource controller still allows to pass allow_pagination=False and allow_sorting=False parameters to disable the features if a registered plugin does not support the features yet. Change-Id: I5fd30b20f645846d9366740372c4815c4b33e2eb Related-Bug: #1566514
This commit is contained in:
parent
8e27076b32
commit
61eb74af31
@ -15,7 +15,6 @@
|
||||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
||||
from neutron.api import extensions
|
||||
@ -89,8 +88,8 @@ def build_resource_info(plural_mappings, resource_map, which_service,
|
||||
collection_name, resource_name, plugin, params,
|
||||
member_actions=member_actions,
|
||||
allow_bulk=allow_bulk,
|
||||
allow_pagination=cfg.CONF.allow_pagination,
|
||||
allow_sorting=cfg.CONF.allow_sorting)
|
||||
allow_pagination=True,
|
||||
allow_sorting=True)
|
||||
resource = extensions.ResourceExtension(
|
||||
collection_name,
|
||||
controller,
|
||||
|
@ -84,12 +84,10 @@ class APIRouter(base_wsgi.Router):
|
||||
|
||||
def _map_resource(collection, resource, params, parent=None):
|
||||
allow_bulk = cfg.CONF.allow_bulk
|
||||
allow_pagination = cfg.CONF.allow_pagination
|
||||
allow_sorting = cfg.CONF.allow_sorting
|
||||
controller = base.create_resource(
|
||||
collection, resource, plugin, params, allow_bulk=allow_bulk,
|
||||
parent=parent, allow_pagination=allow_pagination,
|
||||
allow_sorting=allow_sorting)
|
||||
parent=parent, allow_pagination=True,
|
||||
allow_sorting=True)
|
||||
path_prefix = None
|
||||
if parent:
|
||||
path_prefix = "/%s/{%s_id}/%s" % (parent['collection_name'],
|
||||
|
@ -47,15 +47,6 @@ core_opts = [
|
||||
"will be randomly generated.")),
|
||||
cfg.BoolOpt('allow_bulk', default=True,
|
||||
help=_("Allow the usage of the bulk API")),
|
||||
cfg.BoolOpt('allow_pagination', default=True,
|
||||
deprecated_for_removal=True,
|
||||
help=_("Allow the usage of the pagination. This option has "
|
||||
"been deprecated and will now be enabled "
|
||||
"unconditionally.")),
|
||||
cfg.BoolOpt('allow_sorting', default=True,
|
||||
deprecated_for_removal=True,
|
||||
help=_("Allow the usage of the sorting. This option has been "
|
||||
"deprecated and will now be enabled unconditionally.")),
|
||||
cfg.StrOpt('pagination_max_limit', default="-1",
|
||||
help=_("The maximum number of items returned in a single "
|
||||
"response, value was 'infinite' or negative integer "
|
||||
|
@ -11,8 +11,6 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from neutron.api import extensions
|
||||
|
||||
|
||||
@ -23,7 +21,7 @@ class Pagination(extensions.ExtensionDescriptor):
|
||||
"""Fake extension that indicates that pagination is enabled."""
|
||||
|
||||
extensions.register_custom_supported_check(
|
||||
_ALIAS, lambda: cfg.CONF.allow_pagination, plugin_agnostic=True
|
||||
_ALIAS, lambda: True, plugin_agnostic=True
|
||||
)
|
||||
|
||||
@classmethod
|
||||
|
@ -11,8 +11,6 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from neutron.api import extensions
|
||||
|
||||
|
||||
@ -23,7 +21,7 @@ class Sorting(extensions.ExtensionDescriptor):
|
||||
"""Fake extension that indicates that sorting is enabled."""
|
||||
|
||||
extensions.register_custom_supported_check(
|
||||
_ALIAS, lambda: cfg.CONF.allow_sorting, plugin_agnostic=True
|
||||
_ALIAS, lambda: True, plugin_agnostic=True
|
||||
)
|
||||
|
||||
@classmethod
|
||||
|
@ -17,7 +17,6 @@ import copy
|
||||
import functools
|
||||
|
||||
from neutron_lib import constants
|
||||
from oslo_config import cfg
|
||||
import pecan
|
||||
from pecan import request
|
||||
import six
|
||||
@ -115,10 +114,10 @@ class NeutronPecanController(object):
|
||||
self._mandatory_fields = set()
|
||||
self.allow_pagination = allow_pagination
|
||||
if self.allow_pagination is None:
|
||||
self.allow_pagination = cfg.CONF.allow_pagination
|
||||
self.allow_pagination = True
|
||||
self.allow_sorting = allow_sorting
|
||||
if self.allow_sorting is None:
|
||||
self.allow_sorting = cfg.CONF.allow_sorting
|
||||
self.allow_sorting = True
|
||||
self.native_pagination = api_common.is_native_pagination_supported(
|
||||
self.plugin)
|
||||
self.native_sorting = api_common.is_native_sorting_supported(
|
||||
|
@ -435,8 +435,6 @@ class TestPaginationAndSorting(test_functional.PecanFunctionalTest):
|
||||
RESOURCE_COUNT = 6
|
||||
|
||||
def setUp(self):
|
||||
cfg.CONF.set_override('allow_pagination', True)
|
||||
cfg.CONF.set_override('allow_sorting', True)
|
||||
super(TestPaginationAndSorting, self).setUp()
|
||||
self.plugin = directory.get_plugin()
|
||||
self.ctx = context.get_admin_context()
|
||||
|
@ -102,8 +102,6 @@ class APIv2TestBase(base.BaseTestCase):
|
||||
self.config_parse()
|
||||
# Update the plugin
|
||||
self.setup_coreplugin(plugin, load_plugins=False)
|
||||
cfg.CONF.set_override('allow_pagination', True)
|
||||
cfg.CONF.set_override('allow_sorting', True)
|
||||
self._plugin_patcher = mock.patch(plugin, autospec=True)
|
||||
self.plugin = self._plugin_patcher.start()
|
||||
instance = self.plugin.return_value
|
||||
@ -518,19 +516,6 @@ class APIv2TestCase(APIv2TestBase):
|
||||
instance._NeutronPluginBaseV2__native_sorting_support = False
|
||||
self.assertRaises(n_exc.Invalid, router.APIRouter)
|
||||
|
||||
def test_native_pagination_without_allow_sorting(self):
|
||||
cfg.CONF.set_override('allow_sorting', False)
|
||||
instance = self.plugin.return_value
|
||||
instance.get_networks.return_value = []
|
||||
api = webtest.TestApp(router.APIRouter())
|
||||
api.get(_get_path('networks'),
|
||||
{'sort_key': ['name', 'admin_state_up'],
|
||||
'sort_dir': ['desc', 'asc']})
|
||||
kwargs = self._get_collection_kwargs(sorts=[('name', False),
|
||||
('admin_state_up', True),
|
||||
('id', True)])
|
||||
instance.get_networks.assert_called_once_with(mock.ANY, **kwargs)
|
||||
|
||||
|
||||
# Note: since all resources use the same controller and validation
|
||||
# logic, we actually get really good coverage from testing just networks.
|
||||
|
@ -130,8 +130,6 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase):
|
||||
cfg.CONF.set_override('base_mac', "12:34:56:78:90:ab")
|
||||
cfg.CONF.set_override('max_dns_nameservers', 2)
|
||||
cfg.CONF.set_override('max_subnet_host_routes', 2)
|
||||
cfg.CONF.set_override('allow_pagination', True)
|
||||
cfg.CONF.set_override('allow_sorting', True)
|
||||
self.api = router.APIRouter()
|
||||
# Set the default status
|
||||
self.net_create_status = 'ACTIVE'
|
||||
@ -149,9 +147,8 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase):
|
||||
native_pagination_attr_name = (
|
||||
"_%s__native_pagination_support" %
|
||||
directory.get_plugin().__class__.__name__)
|
||||
return (cfg.CONF.allow_pagination and
|
||||
getattr(directory.get_plugin(),
|
||||
native_pagination_attr_name, False))
|
||||
return getattr(directory.get_plugin(),
|
||||
native_pagination_attr_name, False)
|
||||
|
||||
self._skip_native_pagination = not _is_native_pagination_support()
|
||||
|
||||
@ -159,9 +156,8 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase):
|
||||
native_sorting_attr_name = (
|
||||
"_%s__native_sorting_support" %
|
||||
directory.get_plugin().__class__.__name__)
|
||||
return (cfg.CONF.allow_sorting and
|
||||
getattr(directory.get_plugin(),
|
||||
native_sorting_attr_name, False))
|
||||
return getattr(directory.get_plugin(),
|
||||
native_sorting_attr_name, False)
|
||||
|
||||
self.plugin = directory.get_plugin()
|
||||
self._skip_native_sorting = not _is_native_sorting_support()
|
||||
|
@ -72,13 +72,11 @@ class ExtensionTestCase(testlib_api.WebTestCase):
|
||||
if supported_extension_aliases is not None:
|
||||
instance.supported_extension_aliases = supported_extension_aliases
|
||||
if allow_pagination:
|
||||
cfg.CONF.set_override('allow_pagination', True)
|
||||
# instance.__native_pagination_support = True
|
||||
native_pagination_attr_name = ("_%s__native_pagination_support"
|
||||
% instance.__class__.__name__)
|
||||
setattr(instance, native_pagination_attr_name, True)
|
||||
if allow_sorting:
|
||||
cfg.CONF.set_override('allow_sorting', True)
|
||||
# instance.__native_sorting_support = True
|
||||
native_sorting_attr_name = ("_%s__native_sorting_support"
|
||||
% instance.__class__.__name__)
|
||||
|
@ -62,8 +62,6 @@ class ProvidernetExtensionTestCase(testlib_api.WebTestCase):
|
||||
|
||||
# Update the plugin and extensions path
|
||||
self.setup_coreplugin(plugin, load_plugins=False)
|
||||
cfg.CONF.set_override('allow_pagination', True)
|
||||
cfg.CONF.set_override('allow_sorting', True)
|
||||
self._plugin_patcher = mock.patch(plugin, autospec=True)
|
||||
self.plugin = self._plugin_patcher.start()
|
||||
# Ensure Quota checks never fail because of mock
|
||||
|
@ -72,8 +72,6 @@ class VlanTransparentExtensionTestCase(test_db_base_plugin_v2.TestNetworksV2):
|
||||
self.saved_attr_map[res] = attrs.copy()
|
||||
|
||||
# Update the plugin and extensions path
|
||||
cfg.CONF.set_override('allow_pagination', True)
|
||||
cfg.CONF.set_override('allow_sorting', True)
|
||||
ext_mgr = VlanTransparentExtensionManager()
|
||||
self.addCleanup(self._restore_attribute_map)
|
||||
super(VlanTransparentExtensionTestCase, self).setUp(plugin=plugin,
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
other:
|
||||
- The ``allow_pagination`` and ``allow_sorting`` configuration options are
|
||||
now removed. Now, sorting and pagination are always enabled for plugins
|
||||
that support the features.
|
Loading…
x
Reference in New Issue
Block a user