| 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.api.definitions import flowclassifier as fc_api |
| 17 |
from neutron_lib import constants |
| 18 |
from neutron_lib.db import constants as db_const |
| 19 |
|
| 20 |
# The alias of the extension. |
| 21 |
ALIAS = 'sfc' |
| 22 |
|
| 23 |
# Whether or not this extension is simply signaling behavior to the user |
| 24 |
# or it actively modifies the attribute map. |
| 25 |
IS_SHIM_EXTENSION = False |
| 26 |
|
| 27 |
# Whether the extension is marking the adoption of standardattr model for |
| 28 |
# legacy resources, or introducing new standardattr attributes. False or |
| 29 |
# None if the standardattr model is adopted since the introduction of |
| 30 |
# resource extension. |
| 31 |
# If this is True, the alias for the extension should be prefixed with |
| 32 |
# 'standard-attr-'. |
| 33 |
IS_STANDARD_ATTR_EXTENSION = False |
| 34 |
|
| 35 |
# The name of the extension. |
| 36 |
NAME = 'Service Function Chaining' |
| 37 |
|
| 38 |
# The description of the extension. |
| 39 |
DESCRIPTION = "Provides support for Service Function Chaining" |
| 40 |
|
| 41 |
# A timestamp of when the extension was last updated. |
| 42 |
UPDATED_TIMESTAMP = "2015-10-05T10:00:00-00:00" |
| 43 |
|
| 44 |
API_PREFIX = '/sfc' |
| 45 |
|
| 46 |
# Service Function Chaining constants |
| 47 |
PORT_PAIRS = 'port_pairs' |
| 48 |
PORT_PAIR_GROUPS = 'port_pair_groups' |
| 49 |
PORT_CHAINS = 'port_chains' |
| 50 |
MAX_CHAIN_ID = 65535 |
| 51 |
|
| 52 |
MPLS = 'mpls' |
| 53 |
NSH = 'nsh' |
| 54 |
|
| 55 |
PPG_N_TUPLE_DICT_SPEC = { |
| 56 |
'source_ip_prefix': { |
| 57 |
'default': None, |
| 58 |
'type:subnet_or_none': None |
| 59 |
}, |
| 60 |
'destination_ip_prefix': { |
| 61 |
'default': None, |
| 62 |
'type:subnet_or_none': None |
| 63 |
}, |
| 64 |
'source_port_range_min': { |
| 65 |
'default': None, |
| 66 |
'convert_to': converters.convert_to_int_if_not_none, |
| 67 |
'type:range_or_none': [0, constants.PORT_MAX] |
| 68 |
}, |
| 69 |
'source_port_range_max': { |
| 70 |
'default': None, |
| 71 |
'convert_to': converters.convert_to_int_if_not_none, |
| 72 |
'type:range_or_none': [0, constants.PORT_MAX] |
| 73 |
}, |
| 74 |
'destination_port_range_min': { |
| 75 |
'default': None, |
| 76 |
'convert_to': converters.convert_to_int_if_not_none, |
| 77 |
'type:range_or_none': [0, constants.PORT_MAX] |
| 78 |
}, |
| 79 |
'destination_port_range_max': { |
| 80 |
'default': None, |
| 81 |
'convert_to': converters.convert_to_int_if_not_none, |
| 82 |
'type:range_or_none': [0, constants.PORT_MAX] |
| 83 |
} |
| 84 |
} |
| 85 |
|
| 86 |
# The resource attribute map for the extension. |
| 87 |
RESOURCE_ATTRIBUTE_MAP = { |
| 88 |
PORT_PAIRS: { |
| 89 |
'id': { |
| 90 |
'allow_post': False, 'allow_put': False, |
| 91 |
'is_visible': True, |
| 92 |
'validate': {'type:uuid': None}, |
| 93 |
'primary_key': True |
| 94 |
}, |
| 95 |
'name': { |
| 96 |
'allow_post': True, 'allow_put': True, |
| 97 |
'is_visible': True, 'default': '', |
| 98 |
'validate': {'type:string': db_const.NAME_FIELD_SIZE}, |
| 99 |
}, |
| 100 |
'description': { |
| 101 |
'allow_post': True, 'allow_put': True, |
| 102 |
'is_visible': True, 'default': '', |
| 103 |
'validate': {'type:string': db_const.DESCRIPTION_FIELD_SIZE}, |
| 104 |
}, |
| 105 |
'tenant_id': { |
| 106 |
'allow_post': True, 'allow_put': False, |
| 107 |
'is_visible': True, |
| 108 |
'validate': {'type:string': db_const.PROJECT_ID_FIELD_SIZE}, |
| 109 |
'required_by_policy': True |
| 110 |
}, |
| 111 |
'ingress': { |
| 112 |
'allow_post': True, 'allow_put': False, |
| 113 |
'is_visible': True, |
| 114 |
'validate': {'type:uuid': None} |
| 115 |
}, |
| 116 |
'egress': { |
| 117 |
'allow_post': True, 'allow_put': False, |
| 118 |
'is_visible': True, |
| 119 |
'validate': {'type:uuid': None} |
| 120 |
}, |
| 121 |
'service_function_parameters': { |
| 122 |
'allow_post': True, 'allow_put': False, |
| 123 |
'is_visible': True, |
| 124 |
'dict_populate_defaults': True, |
| 125 |
'validate': { |
| 126 |
'type:dict': { |
| 127 |
'correlation': { |
| 128 |
'type:values': [None, MPLS, NSH], |
| 129 |
'default': None |
| 130 |
}, |
| 131 |
'weight': { |
| 132 |
'type:non_negative': None, |
| 133 |
'default': 1, |
| 134 |
'convert_to': converters.convert_to_int |
| 135 |
} |
| 136 |
} |
| 137 |
} |
| 138 |
} |
| 139 |
}, |
| 140 |
PORT_PAIR_GROUPS: { |
| 141 |
'id': { |
| 142 |
'allow_post': False, 'allow_put': False, |
| 143 |
'is_visible': True, |
| 144 |
'validate': {'type:uuid': None}, |
| 145 |
'primary_key': True}, |
| 146 |
'group_id': { |
| 147 |
'allow_post': False, 'allow_put': False, |
| 148 |
'is_visible': True |
| 149 |
}, |
| 150 |
'name': { |
| 151 |
'allow_post': True, 'allow_put': True, |
| 152 |
'is_visible': True, 'default': '', |
| 153 |
'validate': {'type:string': db_const.NAME_FIELD_SIZE}, |
| 154 |
}, |
| 155 |
'description': { |
| 156 |
'allow_post': True, 'allow_put': True, |
| 157 |
'is_visible': True, 'default': '', |
| 158 |
'validate': {'type:string': db_const.DESCRIPTION_FIELD_SIZE}, |
| 159 |
}, |
| 160 |
'tenant_id': { |
| 161 |
'allow_post': True, 'allow_put': False, |
| 162 |
'is_visible': True, |
| 163 |
'validate': {'type:string': db_const.PROJECT_ID_FIELD_SIZE}, |
| 164 |
'required_by_policy': True |
| 165 |
}, |
| 166 |
'port_pairs': { |
| 167 |
'allow_post': True, 'allow_put': True, |
| 168 |
'is_visible': True, 'default': None, |
| 169 |
'validate': {'type:uuid_list': None}, |
| 170 |
'convert_to': converters.convert_none_to_empty_list |
| 171 |
}, |
| 172 |
'port_pair_group_parameters': { |
| 173 |
'allow_post': True, 'allow_put': False, |
| 174 |
'is_visible': True, |
| 175 |
'dict_populate_defaults': True, |
| 176 |
'validate': { |
| 177 |
'type:dict': { |
| 178 |
'lb_fields': { |
| 179 |
'type:list_of_regex_or_none': |
| 180 |
'eth|ip|tcp|udp)_(src|dst)', |
| 181 |
'default': [] |
| 182 |
}, |
| 183 |
'ppg_n_tuple_mapping': { |
| 184 |
'dict_populate_defaults': True, |
| 185 |
'type:dict': { |
| 186 |
'ingress_n_tuple': { |
| 187 |
'type:dict': PPG_N_TUPLE_DICT_SPEC, |
| 188 |
'default': {} |
| 189 |
}, |
| 190 |
'egress_n_tuple': { |
| 191 |
'type:dict': PPG_N_TUPLE_DICT_SPEC, |
| 192 |
'default': {} |
| 193 |
} |
| 194 |
} |
| 195 |
} |
| 196 |
} |
| 197 |
} |
| 198 |
} |
| 199 |
}, |
| 200 |
PORT_CHAINS: { |
| 201 |
'id': { |
| 202 |
'allow_post': False, 'allow_put': False, |
| 203 |
'is_visible': True, |
| 204 |
'validate': {'type:uuid': None}, |
| 205 |
'primary_key': True |
| 206 |
}, |
| 207 |
'chain_id': { |
| 208 |
'allow_post': True, 'allow_put': False, |
| 209 |
'is_visible': True, 'default': 0, |
| 210 |
'validate': {'type:range': (0, MAX_CHAIN_ID)}, |
| 211 |
'convert_to': converters.convert_to_int |
| 212 |
}, |
| 213 |
'name': { |
| 214 |
'allow_post': True, 'allow_put': True, |
| 215 |
'is_visible': True, 'default': '', |
| 216 |
'validate': {'type:string': db_const.NAME_FIELD_SIZE}, |
| 217 |
}, |
| 218 |
'description': { |
| 219 |
'allow_post': True, 'allow_put': True, |
| 220 |
'is_visible': True, 'default': '', |
| 221 |
'validate': {'type:string': db_const.DESCRIPTION_FIELD_SIZE}, |
| 222 |
}, |
| 223 |
'tenant_id': { |
| 224 |
'allow_post': True, 'allow_put': False, |
| 225 |
'is_visible': True, |
| 226 |
'validate': {'type:string': db_const.PROJECT_ID_FIELD_SIZE}, |
| 227 |
'required_by_policy': True |
| 228 |
}, |
| 229 |
'port_pair_groups': { |
| 230 |
'allow_post': True, 'allow_put': True, |
| 231 |
'is_visible': True, |
| 232 |
'validate': {'type:uuid_list_non_empty': None}, |
| 233 |
'default': None |
| 234 |
}, |
| 235 |
'flow_classifiers': { |
| 236 |
'allow_post': True, 'allow_put': True, |
| 237 |
'is_visible': True, 'default': None, |
| 238 |
'validate': {'type:uuid_list': None}, |
| 239 |
'convert_to': converters.convert_to_list |
| 240 |
}, |
| 241 |
'chain_parameters': { |
| 242 |
'allow_post': True, 'allow_put': False, |
| 243 |
'is_visible': True, |
| 244 |
'dict_populate_defaults': True, |
| 245 |
'validate': { |
| 246 |
'type:dict': { |
| 247 |
'correlation': { |
| 248 |
'type:values': [MPLS, NSH], |
| 249 |
'default': MPLS |
| 250 |
}, |
| 251 |
'symmetric': { |
| 252 |
'type:boolean': None, |
| 253 |
'default': False, |
| 254 |
'convert_to': converters.convert_to_boolean |
| 255 |
} |
| 256 |
} |
| 257 |
}, |
| 258 |
} |
| 259 |
} |
| 260 |
} |
| 261 |
|
| 262 |
# The subresource attribute map for the extension. It adds child resources |
| 263 |
# to main extension's resource. The subresource map must have a parent and |
| 264 |
# a parameters entry. If an extension does not need such a map, None can |
| 265 |
# be specified (mandatory). |
| 266 |
SUB_RESOURCE_ATTRIBUTE_MAP = None |
| 267 |
|
| 268 |
# The action map. |
| 269 |
ACTION_MAP = { |
| 270 |
} |
| 271 |
|
| 272 |
ACTION_STATUS = { |
| 273 |
} |
| 274 |
# The list of required extensions. |
| 275 |
REQUIRED_EXTENSIONS = [ |
| 276 |
fc_api.ALIAS, |
| 277 |
] |
| 278 |
|
| 279 |
# The list of optional extensions. |
| 280 |
OPTIONAL_EXTENSIONS = [ |
| 281 |
] |