diff --git a/neutron/agent/securitygroups_rpc.py b/neutron/agent/securitygroups_rpc.py index 2f7c4a3d922..19f6acdff67 100644 --- a/neutron/agent/securitygroups_rpc.py +++ b/neutron/agent/securitygroups_rpc.py @@ -21,6 +21,8 @@ from neutron_lib.api.definitions import rbac_security_groups as rbac_sg_apidef from neutron_lib.api.definitions import security_groups_normalized_cidr from neutron_lib.api.definitions import security_groups_remote_address_group \ as sgag_def +from neutron_lib.api.definitions import security_groups_shared_filtering \ + as sg_shared_filtering from neutron_lib.api.definitions import stateful_security_group as stateful_sg from oslo_concurrency import lockutils from oslo_config import cfg @@ -28,8 +30,6 @@ from oslo_log import log as logging from neutron.agent import firewall from neutron.conf.agent import securitygroups_rpc as sc_cfg -from neutron.extensions import security_groups_shared_filtering_lib \ - as sg_shared_filtering LOG = logging.getLogger(__name__) diff --git a/neutron/common/ovn/extensions.py b/neutron/common/ovn/extensions.py index 46a2fe4b59b..3fc8ad77149 100644 --- a/neutron/common/ovn/extensions.py +++ b/neutron/common/ovn/extensions.py @@ -62,6 +62,7 @@ from neutron_lib.api.definitions import rbac_security_groups from neutron_lib.api.definitions import router_availability_zone as raz_def from neutron_lib.api.definitions import security_groups_normalized_cidr from neutron_lib.api.definitions import security_groups_remote_address_group +from neutron_lib.api.definitions import security_groups_shared_filtering from neutron_lib.api.definitions import segment as seg_def from neutron_lib.api.definitions import sorting from neutron_lib.api.definitions import stateful_security_group @@ -72,7 +73,6 @@ from neutron_lib.api.definitions import vlantransparent from neutron_lib import constants from neutron.extensions import quotasv2_detail -from neutron.extensions import security_groups_shared_filtering_lib # NOTE(russellb) This remains in its own file (vs constants.py) because we want # to be able to easily import it and export the info without any dependencies @@ -140,7 +140,7 @@ ML2_SUPPORTED_API_EXTENSIONS = [ 'security-group', security_groups_normalized_cidr.ALIAS, security_groups_remote_address_group.ALIAS, - security_groups_shared_filtering_lib.ALIAS, + security_groups_shared_filtering.ALIAS, stateful_security_group.ALIAS, 'standard-attr-description', constants.SUBNET_ALLOCATION_EXT_ALIAS, diff --git a/neutron/extensions/security_groups_shared_filtering.py b/neutron/extensions/security_groups_shared_filtering.py index 0a00516b555..3c4efbe2307 100644 --- a/neutron/extensions/security_groups_shared_filtering.py +++ b/neutron/extensions/security_groups_shared_filtering.py @@ -10,12 +10,12 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib.api.definitions import security_groups_shared_filtering \ + as apidef from neutron_lib.api import extensions -from neutron.extensions import security_groups_shared_filtering_lib - class Security_groups_shared_filtering(extensions.APIExtensionDescriptor): """Extension class supporting filtering SGs depend on the shared field.""" - api_definition = security_groups_shared_filtering_lib + api_definition = apidef diff --git a/neutron/extensions/security_groups_shared_filtering_lib.py b/neutron/extensions/security_groups_shared_filtering_lib.py deleted file mode 100644 index 67862e62607..00000000000 --- a/neutron/extensions/security_groups_shared_filtering_lib.py +++ /dev/null @@ -1,67 +0,0 @@ -# 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. - -# NOTE(hangyang): This file can be removed once the api def is merged -# to neutron-lib https://review.opendev.org/c/openstack/neutron-lib/+/812617 - -from neutron_lib.api import converters -from neutron_lib import constants - - -# The alias of the extension. -ALIAS = 'security-groups-shared-filtering' - -IS_SHIM_EXTENSION = False - -IS_STANDARD_ATTR_EXTENSION = False - -# The name of the extension. -NAME = 'Security group filtering on the shared field' - -# The description of the extension. -DESCRIPTION = "Support filtering security groups on the shared field" - -# A timestamp of when the extension was introduced. -UPDATED_TIMESTAMP = "2021-10-05T09:00:00-00:00" - -# The resource attribute map for the extension. -RESOURCE_ATTRIBUTE_MAP = { - 'security_groups': { - constants.SHARED: { - 'allow_post': False, - 'allow_put': False, - 'convert_to': converters.convert_to_boolean, - 'is_visible': True, - 'is_filter': True, - 'required_by_policy': True, - 'enforce_policy': True} - } -} - -# 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 = ['rbac-security-groups'] - -# The list of optional extensions. -OPTIONAL_EXTENSIONS = [ -] diff --git a/neutron/plugins/ml2/plugin.py b/neutron/plugins/ml2/plugin.py index 509469b9775..42349df3105 100644 --- a/neutron/plugins/ml2/plugin.py +++ b/neutron/plugins/ml2/plugin.py @@ -54,6 +54,7 @@ from neutron_lib.api.definitions import rbac_subnetpool from neutron_lib.api.definitions import security_groups_normalized_cidr from neutron_lib.api.definitions import security_groups_port_filtering from neutron_lib.api.definitions import security_groups_remote_address_group +from neutron_lib.api.definitions import security_groups_shared_filtering from neutron_lib.api.definitions import stateful_security_group from neutron_lib.api.definitions import subnet as subnet_def from neutron_lib.api.definitions import subnet_onboard as subnet_onboard_def @@ -129,7 +130,6 @@ from neutron.extensions import ( ) from neutron.extensions import dhcpagentscheduler as dhcp_ext from neutron.extensions import filter_validation -from neutron.extensions import security_groups_shared_filtering_lib from neutron.extensions import vlantransparent from neutron.ipam import exceptions as ipam_exc from neutron.objects import base as base_obj @@ -226,7 +226,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2, security_groups_normalized_cidr.ALIAS, security_groups_port_filtering.ALIAS, security_groups_remote_address_group.ALIAS, - security_groups_shared_filtering_lib.ALIAS, + security_groups_shared_filtering.ALIAS, empty_string_filtering.ALIAS, filter_apidef.ALIAS, port_mac_address_regenerate.ALIAS, diff --git a/neutron/tests/unit/extensions/test_securitygroup.py b/neutron/tests/unit/extensions/test_securitygroup.py index e1aff3ebfbd..d0ca88b81ab 100644 --- a/neutron/tests/unit/extensions/test_securitygroup.py +++ b/neutron/tests/unit/extensions/test_securitygroup.py @@ -20,6 +20,8 @@ from unittest import mock from neutron_lib.api.definitions import rbac_security_groups as rbac_sg_def from neutron_lib.api.definitions import security_groups_remote_address_group \ as sgag_def +from neutron_lib.api.definitions import security_groups_shared_filtering \ + as sg_shared_filter_def from neutron_lib.api import validators from neutron_lib import constants as const from neutron_lib import context @@ -36,8 +38,6 @@ from neutron.db import address_group_db from neutron.db import db_base_plugin_v2 from neutron.db import securitygroups_db from neutron.extensions import address_group as ext_ag -from neutron.extensions import security_groups_shared_filtering_lib \ - as sg_shared_filter_def from neutron.extensions import securitygroup as ext_sg from neutron.extensions import standardattrdescription from neutron.tests import base