| 1 |
|
| 2 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 3 |
# not use this file except in compliance with the License. You may obtain |
| 4 |
# a copy of the License at |
| 5 |
# |
| 6 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 7 |
# |
| 8 |
# Unless required by applicable law or agreed to in writing, software |
| 9 |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 10 |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 11 |
# License for the specific language governing permissions and limitations |
| 12 |
# under the License. |
| 13 |
# |
| 14 |
|
| 15 |
|
| 16 |
import copy |
| 17 |
from neutron_lib.api.definitions import taas |
| 18 |
from neutron_lib.api.definitions import tap_mirror |
| 19 |
from neutron_lib.api import extensions as api_extensions |
| 20 |
|
| 21 |
ALIAS = 'tap-mirror-both-direction' |
| 22 |
IS_SHIM_EXTENSION = False |
| 23 |
IS_STANDARD_ATTR_EXTENSION = False |
| 24 |
NAME = "Tap as a Service mirror with BOTH direction support" |
| 25 |
DESCRIPTION = ("Neutron Tap as a Service extension mirroring with support " |
| 26 |
"for BOTH direction.") |
| 27 |
UPDATED_TIMESTAMP = "2025-12-15T11:45:00-00:00" |
| 28 |
DIRECTION_SPEC = copy.deepcopy(tap_mirror.DIRECTION_SPEC) |
| 29 |
DIRECTION_SPEC['type:dict'][taas.DIRECTION_BOTH] = { |
| 30 |
'type:integer': None, 'default': None, 'required': False |
| 31 |
} |
| 32 |
RESOURCE_ATTRIBUTE_MAP = { |
| 33 |
tap_mirror.COLLECTION_NAME: { |
| 34 |
'directions': { |
| 35 |
'allow_post': True, 'allow_put': False, |
| 36 |
'validate': DIRECTION_SPEC, |
| 37 |
'is_visible': True}, |
| 38 |
} |
| 39 |
} |
| 40 |
SUB_RESOURCE_ATTRIBUTE_MAP = None |
| 41 |
ACTION_MAP = {} |
| 42 |
ACTION_STATUS = {} |
| 43 |
REQUIRED_EXTENSIONS = [tap_mirror.ALIAS] |
| 44 |
OPTIONAL_EXTENSIONS = [] |
| 45 |
|
| 46 |
# TODO(egarciar): use api definition from neutron-lib once |
| 47 |
# https://review.opendev.org/c/openstack/neutron-lib/+/969962 |
| 48 |
# is merged and released |
| 49 |
|
| 50 |
|
| 51 |
class Tap_mirror_both_direction(api_extensions.ExtensionDescriptor): |
| 52 |
"""Extension class supporting tap mirror both direction.""" |
| 53 |
|
| 54 |
@classmethod |
| 55 |
def get_name(cls): |
| 56 |
return NAME |
| 57 |
|
| 58 |
@classmethod |
| 59 |
def get_alias(cls): |
| 60 |
return ALIAS |
| 61 |
|
| 62 |
@classmethod |
| 63 |
def get_description(cls): |
| 64 |
return DESCRIPTION |
| 65 |
|
| 66 |
@classmethod |
| 67 |
def get_updated(cls): |
| 68 |
return UPDATED_TIMESTAMP |
| 69 |
|
| 70 |
def get_required_extensions(self): |
| 71 |
return REQUIRED_EXTENSIONS |
| 72 |
|
| 73 |
def get_extended_resources(self, version): |
| 74 |
return RESOURCE_ATTRIBUTE_MAP |