Start using security-groups-shared-filtering from neutron-lib

Remove security_groups_shared_filtering_lib extension and
use security-groups-shared-filtering from neutron-lib as
it is available since version 2.17.0 [0].

[0] https://review.opendev.org/c/openstack/neutron-lib/+/812617

Change-Id: Ife9b1ae47f5b447898bce0d8b44500f91f6dfbfb
Related-Bug: #1942615
This commit is contained in:
Brian Haley 2022-05-19 12:44:22 -04:00
parent 5c6eff7e15
commit 6012ba074f
6 changed files with 11 additions and 78 deletions

View File

@ -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__)

View File

@ -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,

View File

@ -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

View File

@ -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 = [
]

View File

@ -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,

View File

@ -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