34 changed files with 324 additions and 30 deletions
@ -0,0 +1,30 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
||||
# not use this file except in compliance with the License. You may obtain |
||||
# a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
||||
# License for the specific language governing permissions and limitations |
||||
# under the License. |
||||
|
||||
""" |
||||
This module should be deleted once neutron-lib containing |
||||
https://review.openstack.org/#/c/580190/ change is released. |
||||
""" |
||||
|
||||
|
||||
ALIAS = 'filter-validation' |
||||
IS_SHIM_EXTENSION = True |
||||
IS_STANDARD_ATTR_EXTENSION = False |
||||
NAME = 'Filter parameters validation' |
||||
DESCRIPTION = 'Provides validation on filter parameters.' |
||||
UPDATED_TIMESTAMP = '2018-03-21T10:00:00-00:00' |
||||
RESOURCE_ATTRIBUTE_MAP = {} |
||||
SUB_RESOURCE_ATTRIBUTE_MAP = {} |
||||
ACTION_MAP = {} |
||||
REQUIRED_EXTENSIONS = [] |
||||
OPTIONAL_EXTENSIONS = [] |
||||
ACTION_STATUS = {} |
@ -0,0 +1,35 @@
|
||||
# Copyright (c) 2017 Huawei Technology, Inc. All rights reserved. |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
||||
# not use this file except in compliance with the License. You may obtain |
||||
# a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
||||
# License for the specific language governing permissions and limitations |
||||
# under the License. |
||||
|
||||
from neutron_lib.api import extensions |
||||
from oslo_config import cfg |
||||
from oslo_log import log as logging |
||||
|
||||
from neutron.extensions import _filter_validation_lib as apidef |
||||
|
||||
|
||||
LOG = logging.getLogger(__name__) |
||||
|
||||
|
||||
def _disable_extension_by_config(aliases): |
||||
if not cfg.CONF.filter_validation: |
||||
if 'filter-validation' in aliases: |
||||
aliases.remove('filter-validation') |
||||
LOG.info('Disabled filter validation extension.') |
||||
|
||||
|
||||
class Filter_validation(extensions.APIExtensionDescriptor): |
||||
"""Extension class supporting filter validation.""" |
||||
|
||||
api_definition = apidef |
@ -0,0 +1,38 @@
|
||||
--- |
||||
prelude: > |
||||
Perform validation on filter parameters on listing resources. |
||||
features: |
||||
- | |
||||
Starting from this release, neutron server will perform validation on |
||||
filter parameters on list requests. Neutron will return a 400 response |
||||
if the request contains invalid filter parameters. |
||||
The list of valid parameters is documented in the neutron API reference. |
||||
|
||||
Add an API extension ``filter-validation`` to indicate this new API |
||||
behavior. This extension can be disabled by operators via a config option. |
||||
upgrade: |
||||
- | |
||||
Prior to the upgrade, if a request contains an unknown or unsupported |
||||
parameter, the server will silently ignore the invalid input. |
||||
After the upgrade, the server will return a 400 Bad Request response |
||||
instead. |
||||
|
||||
API users might observe that requests that received a successful response |
||||
now receive a failure response. If they encounter such experience, |
||||
they are suggested to confirm if the API extension ``filter-validation`` |
||||
is present and validate filter parameters in their requests. |
||||
|
||||
Operators can disable this feature if they want to maintain |
||||
backward-compatibility. If they choose to do that, the API extension |
||||
``filter-validation`` will not be present and the API behavior is |
||||
unchanged. |
||||
other: |
||||
- | |
||||
Each plugin can decide if it wants to support filter validation by |
||||
setting ``__filter_validation_support`` to True or False. If this field is |
||||
not set, the default value is False. |
||||
Right now, the ML2 plugin and all the in-tree service plugins support |
||||
filter validation. Out-of-tree plugins will have filter validation |
||||
disabled by default but they can turn it on if they choose to. |
||||
For filter validation to be supported, the core plugin and all the |
||||
services plugins in a deployment must support it. |
Loading…
Reference in new issue