From 7b43461c7abd8ecd486b01b1575b1c9ee7b264a6 Mon Sep 17 00:00:00 2001 From: Hongbin Lu Date: Mon, 4 Dec 2017 19:18:09 +0000 Subject: [PATCH] Add the IP substring filter extension Change-Id: I97259b85a2dce5a54bb6ea2cb9d9779ec0a25504 Related-Bug: #1718605 --- api-ref/source/v2/ports.inc | 12 ++++ neutron_lib/api/definitions/__init__.py | 2 + neutron_lib/api/definitions/base.py | 1 + .../ip_substring_port_filtering.py | 60 +++++++++++++++++++ .../test_ip_substring_filtering.py | 18 ++++++ ...-filtering-extension-06bb0c1f738ee330.yaml | 5 ++ 6 files changed, 98 insertions(+) create mode 100644 neutron_lib/api/definitions/ip_substring_port_filtering.py create mode 100644 neutron_lib/tests/unit/api/definitions/test_ip_substring_filtering.py create mode 100644 releasenotes/notes/add-ip-substring-filtering-extension-06bb0c1f738ee330.yaml diff --git a/api-ref/source/v2/ports.inc b/api-ref/source/v2/ports.inc index 462557a01..e35e22d3e 100644 --- a/api-ref/source/v2/ports.inc +++ b/api-ref/source/v2/ports.inc @@ -64,6 +64,12 @@ that the port can use when sending packets if ``port_security_enabled`` is ``ip_address`` is required in each allowed address pair, the ``mac_address`` is optional and will be taken from the port if not specified. +IP Substring Filtering +====================== + +The ``ip-substring-filtering`` extension adds support for filtering ports by +using part of an IP address. + Show port details ================= @@ -295,6 +301,12 @@ by using query string parameters. For information, see `Filtering and Column Selection `__. +If the ``ip-substring-filtering`` extension is enabled, the Neutron API +supports IP address substring filtering on the ``fixed_ips`` attribute. +If you specify an IP address substring (``ip_address_substr``) in +an entry of the ``fixed_ips`` attribute, the Neutron API will list all +ports that have an IP address matching the substring. + Normal response codes: 200 Error response codes: 401 diff --git a/neutron_lib/api/definitions/__init__.py b/neutron_lib/api/definitions/__init__.py index 7cc26d195..9590a8716 100644 --- a/neutron_lib/api/definitions/__init__.py +++ b/neutron_lib/api/definitions/__init__.py @@ -32,6 +32,7 @@ from neutron_lib.api.definitions import firewall_v2 from neutron_lib.api.definitions import firewallrouterinsertion from neutron_lib.api.definitions import flavors from neutron_lib.api.definitions import ip_allocation +from neutron_lib.api.definitions import ip_substring_port_filtering from neutron_lib.api.definitions import l2_adjacency from neutron_lib.api.definitions import l3 from neutron_lib.api.definitions import l3_ext_gw_mode @@ -86,6 +87,7 @@ _ALL_API_DEFINITIONS = { firewallrouterinsertion, flavors, ip_allocation, + ip_substring_port_filtering, l2_adjacency, l3, l3_ext_gw_mode, diff --git a/neutron_lib/api/definitions/base.py b/neutron_lib/api/definitions/base.py index 77a9929e7..9cdd1e416 100644 --- a/neutron_lib/api/definitions/base.py +++ b/neutron_lib/api/definitions/base.py @@ -88,6 +88,7 @@ KNOWN_EXTENSIONS = ( 'extra_dhcp_opt', 'extraroute', 'flavors', + 'ip-substring-filtering', 'l3-ha', 'l3_agent_scheduler', 'logging', diff --git a/neutron_lib/api/definitions/ip_substring_port_filtering.py b/neutron_lib/api/definitions/ip_substring_port_filtering.py new file mode 100644 index 000000000..0beb0e628 --- /dev/null +++ b/neutron_lib/api/definitions/ip_substring_port_filtering.py @@ -0,0 +1,60 @@ +# 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. + + +# The alias of the extension. +ALIAS = 'ip-substring-filtering' + +# Whether or not this extension is simply signaling behavior to the user +# or it actively modifies the attribute map. +IS_SHIM_EXTENSION = True + +# Whether the extension is marking the adoption of standardattr model for +# legacy resources, or introducing new standardattr attributes. False or +# None if the standardattr model is adopted since the introduction of +# resource extension. +# If this is True, the alias for the extension should be prefixed with +# 'standard-attr-'. +IS_STANDARD_ATTR_EXTENSION = False + +# The name of the extension. +NAME = 'IP address substring filtering' + +# The description of the extension. +DESCRIPTION = "Provides IP address substring filtering when listing ports" + +# A timestamp of when the extension was introduced. +UPDATED_TIMESTAMP = "2017-11-28T09:00:00-00:00" + +# The resource attribute map for the extension. +RESOURCE_ATTRIBUTE_MAP = { +} + +# The subresource attribute map for the extension. +SUB_RESOURCE_ATTRIBUTE_MAP = { +} + +# The action map. +ACTION_MAP = { +} + +# The action status. +ACTION_STATUS = { +} + +# The list of required extensions. +REQUIRED_EXTENSIONS = [ +] + +# The list of optional extensions. +OPTIONAL_EXTENSIONS = [ +] diff --git a/neutron_lib/tests/unit/api/definitions/test_ip_substring_filtering.py b/neutron_lib/tests/unit/api/definitions/test_ip_substring_filtering.py new file mode 100644 index 000000000..a4218c39e --- /dev/null +++ b/neutron_lib/tests/unit/api/definitions/test_ip_substring_filtering.py @@ -0,0 +1,18 @@ +# 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.definitions import ip_substring_port_filtering +from neutron_lib.tests.unit.api.definitions import base + + +class IPSubstringFilteringDefinitionTestCase(base.DefinitionBaseTestCase): + extension_module = ip_substring_port_filtering diff --git a/releasenotes/notes/add-ip-substring-filtering-extension-06bb0c1f738ee330.yaml b/releasenotes/notes/add-ip-substring-filtering-extension-06bb0c1f738ee330.yaml new file mode 100644 index 000000000..42d90a515 --- /dev/null +++ b/releasenotes/notes/add-ip-substring-filtering-extension-06bb0c1f738ee330.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Add ``ip-substring-filtering`` API extension. This extension provides + the ability to filter ports with an IP address substring.