Move API definitions of taas to neutron-lib
Move tap-as-a-srvice API definitions from taas repo to neutron-lib, under neutron_lib/api/definitions, add necessary unit tests and release notes. Change-Id: I295a4955bbf1604d4ae2b11adcb5522abe76bc75
This commit is contained in:
parent
8f066c491e
commit
901589c9a7
@ -139,10 +139,12 @@ from neutron_lib.api.definitions import subnet_segmentid_writable
|
||||
from neutron_lib.api.definitions import subnet_service_types
|
||||
from neutron_lib.api.definitions import subnetpool
|
||||
from neutron_lib.api.definitions import subnetpool_prefix_ops
|
||||
from neutron_lib.api.definitions import taas
|
||||
from neutron_lib.api.definitions import tag_ports_during_bulk_creation
|
||||
from neutron_lib.api.definitions import trunk
|
||||
from neutron_lib.api.definitions import trunk_details
|
||||
from neutron_lib.api.definitions import uplink_status_propagation
|
||||
from neutron_lib.api.definitions import vlan_filter
|
||||
from neutron_lib.api.definitions import vlantransparent
|
||||
from neutron_lib.api.definitions import vpn
|
||||
from neutron_lib.api.definitions import vpn_endpoint_groups
|
||||
@ -279,10 +281,12 @@ _ALL_API_DEFINITIONS = {
|
||||
subnet_service_types,
|
||||
subnetpool,
|
||||
subnetpool_prefix_ops,
|
||||
taas,
|
||||
tag_ports_during_bulk_creation,
|
||||
trunk,
|
||||
trunk_details,
|
||||
uplink_status_propagation,
|
||||
vlan_filter,
|
||||
vlantransparent,
|
||||
vpn,
|
||||
vpn_endpoint_groups,
|
||||
|
@ -196,6 +196,10 @@ KNOWN_EXTENSIONS = (
|
||||
# https://opendev.org/openstack/networking-sfc:
|
||||
'flow_classifier',
|
||||
'sfc',
|
||||
|
||||
# https://opendev.org/openstack/tap-as-a-service
|
||||
'taas',
|
||||
'taas-vlan-filter',
|
||||
)
|
||||
|
||||
KNOWN_KEYWORDS = (
|
||||
|
89
neutron_lib/api/definitions/taas.py
Normal file
89
neutron_lib/api/definitions/taas.py
Normal file
@ -0,0 +1,89 @@
|
||||
# Copyright (C) 2015 Ericsson AB
|
||||
# Copyright (c) 2015 Gigamon
|
||||
#
|
||||
# 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.
|
||||
|
||||
|
||||
direction_enum = ['IN', 'OUT', 'BOTH']
|
||||
|
||||
'''
|
||||
Resource Attribute Map:
|
||||
|
||||
Note:
|
||||
|
||||
'tap_services' data model refers to the Tap Service created.
|
||||
port_id specifies destination port to which the mirrored data is sent.
|
||||
'''
|
||||
|
||||
ALIAS = 'taas'
|
||||
IS_SHIM_EXTENSION = False
|
||||
IS_STANDARD_ATTR_EXTENSION = False
|
||||
NAME = "Neutron Tap as a Service"
|
||||
DESCRIPTION = "Neutron Tap as a Service Extension."
|
||||
UPDATED_TIMESTAMP = "2015-01-14T10:00:00-00:00"
|
||||
RESOURCE_NAME = 'tap_service'
|
||||
COLLECTION_NAME = 'tap_services'
|
||||
TAP_FLOW = 'tap_flow'
|
||||
TAP_FLOWS = 'tap_flows'
|
||||
|
||||
RESOURCE_ATTRIBUTE_MAP = {
|
||||
COLLECTION_NAME: {
|
||||
'id': {'allow_post': False, 'allow_put': False,
|
||||
'validate': {'type:uuid': None}, 'is_visible': True,
|
||||
'primary_key': True},
|
||||
'tenant_id': {'allow_post': True, 'allow_put': False,
|
||||
'validate': {'type:string': None},
|
||||
'required_by_policy': True, 'is_visible': True},
|
||||
'name': {'allow_post': True, 'allow_put': True,
|
||||
'validate': {'type:string': None},
|
||||
'is_visible': True, 'default': ''},
|
||||
'description': {'allow_post': True, 'allow_put': True,
|
||||
'validate': {'type:string': None},
|
||||
'is_visible': True, 'default': ''},
|
||||
'port_id': {'allow_post': True, 'allow_put': False,
|
||||
'validate': {'type:uuid': None},
|
||||
'is_visible': True},
|
||||
'status': {'allow_post': False, 'allow_put': False,
|
||||
'is_visible': True}
|
||||
},
|
||||
TAP_FLOWS: {
|
||||
'id': {'allow_post': False, 'allow_put': False,
|
||||
'validate': {'type:uuid': None}, 'is_visible': True,
|
||||
'primary_key': True},
|
||||
'tenant_id': {'allow_post': True, 'allow_put': False,
|
||||
'validate': {'type:string': None},
|
||||
'required_by_policy': True, 'is_visible': True},
|
||||
'name': {'allow_post': True, 'allow_put': True,
|
||||
'validate': {'type:string': None},
|
||||
'is_visible': True, 'default': ''},
|
||||
'description': {'allow_post': True, 'allow_put': True,
|
||||
'validate': {'type:string': None},
|
||||
'is_visible': True, 'default': ''},
|
||||
'tap_service_id': {'allow_post': True, 'allow_put': False,
|
||||
'validate': {'type:uuid': None},
|
||||
'required_by_policy': True, 'is_visible': True},
|
||||
'source_port': {'allow_post': True, 'allow_put': False,
|
||||
'validate': {'type:uuid': None},
|
||||
'required_by_policy': True, 'is_visible': True},
|
||||
'direction': {'allow_post': True, 'allow_put': False,
|
||||
'validate': {'type:values': direction_enum},
|
||||
'is_visible': True},
|
||||
'status': {'allow_post': False, 'allow_put': False,
|
||||
'is_visible': True}
|
||||
}
|
||||
}
|
||||
SUB_RESOURCE_ATTRIBUTE_MAP = None
|
||||
ACTION_MAP = {}
|
||||
ACTION_STATUS = {}
|
||||
REQUIRED_EXTENSIONS = []
|
||||
OPTIONAL_EXTENSIONS = []
|
45
neutron_lib/api/definitions/vlan_filter.py
Normal file
45
neutron_lib/api/definitions/vlan_filter.py
Normal file
@ -0,0 +1,45 @@
|
||||
# Copyright (C) 2018 AT&T
|
||||
#
|
||||
# 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 taas as taas_api_def
|
||||
|
||||
ALIAS = 'taas-vlan-filter'
|
||||
IS_SHIM_EXTENSION = False
|
||||
IS_STANDARD_ATTR_EXTENSION = False
|
||||
NAME = "VLAN filtering for Neutron Tap as a Service"
|
||||
DESCRIPTION = "Neutron Tap as a Service Extension for filtering VLANs."
|
||||
UPDATED_TIMESTAMP = "2018-01-14T10:00:00-00:00"
|
||||
API_PREFIX = '/taas'
|
||||
RESOURCE_NAME = 'tap_service'
|
||||
COLLECTION_NAME = 'tap_services'
|
||||
TAP_FLOW = 'tap_flow'
|
||||
TAP_FLOWS = 'tap_flows'
|
||||
|
||||
# Regex for a comma-seperate list of integer values (VLANs)
|
||||
# For ex. "9,18,27-36,45-54" or "0-4095" or "9,18,27,36"
|
||||
RANGE_REGEX = r"^([0-9]+(-[0-9]+)?)(,([0-9]+(-[0-9]+)?))*$"
|
||||
|
||||
RESOURCE_ATTRIBUTE_MAP = {
|
||||
taas_api_def.TAP_FLOWS: {
|
||||
'vlan_filter': {'allow_post': True, 'allow_put': False,
|
||||
'validate': {'type:regex_or_none': RANGE_REGEX},
|
||||
'is_visible': True, 'default': None}
|
||||
}
|
||||
}
|
||||
SUB_RESOURCE_ATTRIBUTE_MAP = None
|
||||
ACTION_MAP = {}
|
||||
ACTION_STATUS = {}
|
||||
REQUIRED_EXTENSIONS = [taas_api_def.ALIAS]
|
||||
OPTIONAL_EXTENSIONS = []
|
46
neutron_lib/exceptions/taas.py
Normal file
46
neutron_lib/exceptions/taas.py
Normal file
@ -0,0 +1,46 @@
|
||||
# Copyright 2011 VMware, 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._i18n import _
|
||||
from neutron_lib import exceptions as qexception
|
||||
|
||||
|
||||
class TapServiceNotFound(qexception.NotFound):
|
||||
message = _("Tap Service %(tap_id)s does not exist")
|
||||
|
||||
|
||||
class TapFlowNotFound(qexception.NotFound):
|
||||
message = _("Tap Flow %(flow_id)s does not exist")
|
||||
|
||||
|
||||
class InvalidDestinationPort(qexception.NotFound):
|
||||
message = _("Destination Port %(port)s does not exist")
|
||||
|
||||
|
||||
class InvalidSourcePort(qexception.NotFound):
|
||||
message = _("Source Port %(port)s does not exist")
|
||||
|
||||
|
||||
class PortDoesNotBelongToTenant(qexception.NotAuthorized):
|
||||
message = _("The specified port does not belong to the tenant")
|
||||
|
||||
|
||||
class TapServiceNotBelongToTenant(qexception.NotAuthorized):
|
||||
message = _("Specified Tap Service does not belong to the tenant")
|
||||
|
||||
|
||||
class TapServiceLimitReached(qexception.OverQuota):
|
||||
message = _("Reached the maximum quota for Tap Services")
|
23
neutron_lib/tests/unit/api/definitions/test_taas.py
Normal file
23
neutron_lib/tests/unit/api/definitions/test_taas.py
Normal file
@ -0,0 +1,23 @@
|
||||
# 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.definitions import taas
|
||||
from neutron_lib.tests.unit.api.definitions import base
|
||||
|
||||
|
||||
class TaasDefinitionTestCase(base.DefinitionBaseTestCase):
|
||||
extension_module = taas
|
||||
extension_resources = (taas.COLLECTION_NAME, taas.TAP_FLOWS,)
|
||||
extension_attributes = ('port_id', 'tap_service_id', 'source_port',
|
||||
'direction')
|
23
neutron_lib/tests/unit/api/definitions/test_vlan_filter.py
Normal file
23
neutron_lib/tests/unit/api/definitions/test_vlan_filter.py
Normal file
@ -0,0 +1,23 @@
|
||||
# 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.definitions import taas
|
||||
from neutron_lib.api.definitions import vlan_filter
|
||||
from neutron_lib.tests.unit.api.definitions import base
|
||||
|
||||
|
||||
class TaasVlanFilterDefinitionTestCase(base.DefinitionBaseTestCase):
|
||||
extension_module = vlan_filter
|
||||
extension_resources = (taas.TAP_FLOWS,)
|
||||
extension_attributes = ('vlan_filter',)
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
features:
|
||||
- The API definitions of ``tap-as-a-service``, ``taas`` and ``vlan_filter``,
|
||||
are now available in ``neutron_lib.api.definitions``.
|
||||
This includes ``tap_services``, ``tap_flows`` and ``vlan_filter``
|
||||
extension to tap_flows.
|
Loading…
x
Reference in New Issue
Block a user