| 1 |
# All rights reserved. |
| 2 |
# |
| 3 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 |
# not use this file except in compliance with the License. You may obtain |
| 5 |
# a copy of the License at |
| 6 |
# |
| 7 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
# |
| 9 |
# Unless required by applicable law or agreed to in writing, software |
| 10 |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 |
# License for the specific language governing permissions and limitations |
| 13 |
# under the License. |
| 14 |
|
| 15 |
from neutron_lib.api import converters |
| 16 |
from neutron_lib.db import constants as db_const |
| 17 |
|
| 18 |
|
| 19 |
# The alias of the extension. |
| 20 |
ALIAS = 'trunk' |
| 21 |
|
| 22 |
# Whether or not this extension is simply signaling behavior to the user |
| 23 |
# or it actively modifies the attribute map. |
| 24 |
IS_SHIM_EXTENSION = False |
| 25 |
|
| 26 |
# Whether the extension is marking the adoption of standardattr model for |
| 27 |
# legacy resources, or introducing new standardattr attributes. False or |
| 28 |
# None if the standardattr model is adopted since the introduction of |
| 29 |
# resource extension. |
| 30 |
# If this is True, the alias for the extension should be prefixed with |
| 31 |
# 'standard-attr-'. |
| 32 |
IS_STANDARD_ATTR_EXTENSION = False |
| 33 |
|
| 34 |
# The name of the extension. |
| 35 |
NAME = 'Trunk Extension' |
| 36 |
|
| 37 |
# The description of the extension. |
| 38 |
DESCRIPTION = "Provides support for trunk ports" |
| 39 |
|
| 40 |
# A timestamp of when the extension was introduced. |
| 41 |
UPDATED_TIMESTAMP = "2016-01-01T10:00:00-00:00" |
| 42 |
|
| 43 |
# The specific resources and/or attributes for the extension (optional). |
| 44 |
TRUNK = 'trunk' |
| 45 |
TRUNKS = 'trunks' |
| 46 |
SUB_PORTS = 'sub_ports' |
| 47 |
|
| 48 |
# The resource attribute map for the extension. |
| 49 |
RESOURCE_ATTRIBUTE_MAP = { |
| 50 |
TRUNKS: { |
| 51 |
'admin_state_up': {'allow_post': True, 'allow_put': True, |
| 52 |
'default': True, |
| 53 |
'convert_to': converters.convert_to_boolean, |
| 54 |
'is_filter': True, |
| 55 |
'is_sort_key': True, |
| 56 |
'is_visible': True}, |
| 57 |
'id': {'allow_post': False, 'allow_put': False, |
| 58 |
'validate': {'type:uuid': None}, |
| 59 |
'is_filter': True, |
| 60 |
'is_sort_key': True, |
| 61 |
'is_visible': True, 'primary_key': True}, |
| 62 |
'name': {'allow_post': True, 'allow_put': True, |
| 63 |
'validate': {'type:string': db_const.NAME_FIELD_SIZE}, |
| 64 |
'is_filter': True, |
| 65 |
'is_sort_key': True, |
| 66 |
'default': '', 'is_visible': True}, |
| 67 |
'tenant_id': {'allow_post': True, 'allow_put': False, |
| 68 |
'required_by_policy': True, |
| 69 |
'validate': |
| 70 |
{'type:string': db_const.PROJECT_ID_FIELD_SIZE}, |
| 71 |
'is_filter': True, |
| 72 |
'is_sort_key': True, |
| 73 |
'is_visible': True}, |
| 74 |
'port_id': {'allow_post': True, 'allow_put': False, |
| 75 |
'required_by_policy': True, |
| 76 |
'validate': {'type:uuid': None}, |
| 77 |
'is_filter': True, |
| 78 |
'is_sort_key': True, |
| 79 |
'is_visible': True}, |
| 80 |
'status': {'allow_post': False, 'allow_put': False, |
| 81 |
'is_sort_key': True, |
| 82 |
'is_visible': True, |
| 83 |
'is_filter': True}, |
| 84 |
SUB_PORTS: {'allow_post': True, 'allow_put': False, |
| 85 |
'default': [], |
| 86 |
'convert_list_to': converters.convert_kvp_list_to_dict, |
| 87 |
'validate': {'type:subports': None}, |
| 88 |
'enforce_policy': True, |
| 89 |
'is_visible': True} |
| 90 |
}, |
| 91 |
} |
| 92 |
|
| 93 |
# The subresource attribute map for the extension. |
| 94 |
SUB_RESOURCE_ATTRIBUTE_MAP = None |
| 95 |
|
| 96 |
# The action map. |
| 97 |
ACTION_MAP = { |
| 98 |
TRUNK: { |
| 99 |
'add_subports': 'PUT', |
| 100 |
'remove_subports': 'PUT', |
| 101 |
'get_subports': 'GET' |
| 102 |
} |
| 103 |
} |
| 104 |
|
| 105 |
# The action status. |
| 106 |
ACTION_STATUS = { |
| 107 |
} |
| 108 |
|
| 109 |
# The list of required extensions. |
| 110 |
REQUIRED_EXTENSIONS = [ |
| 111 |
"binding", |
| 112 |
] |
| 113 |
|
| 114 |
# The list of optional extensions. |
| 115 |
OPTIONAL_EXTENSIONS = [ |
| 116 |
"provider", # needed to learn about network segmentation details. |
| 117 |
] |
| 118 |
|
| 119 |
# TODO(armax): add support for modeling custom queries |