| 1 |
# Copyright (c) 2018 Intel Corporation. |
| 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 provider_net as providernet |
| 17 |
from neutron_lib import constants |
| 18 |
from neutron_lib.db import constants as db_const |
| 19 |
|
| 20 |
# The name of the extension. |
| 21 |
NAME = 'Neutron Network Segment Range' |
| 22 |
# The alias of the extension. |
| 23 |
ALIAS = 'network-segment-range' |
| 24 |
# The description of the extension. |
| 25 |
DESCRIPTION = "Provides support for the network segment range management" |
| 26 |
|
| 27 |
# A timestamp of when the extension was introduced. |
| 28 |
UPDATED_TIMESTAMP = "2018-11-29T00:00:00-00:00" |
| 29 |
|
| 30 |
# The name of the resource. |
| 31 |
RESOURCE_NAME = 'network_segment_range' |
| 32 |
# The plural for the resource. |
| 33 |
COLLECTION_NAME = 'network_segment_ranges' |
| 34 |
|
| 35 |
# Min ID for VLAN, VXLAN, GRE and GENEVE all equal to 1; Max ID for them are |
| 36 |
# 4094, 2 ** 24 - 1, 2 ** 32 - 1 and 2 ** 24 - 1 respectively. |
| 37 |
# Take the largest range: [MIN_GRE_ID, MAX_GRE_ID] as the limit for validation. |
| 38 |
NETWORK_SEGMENT_RANGE_LIMIT = [constants.MIN_GRE_ID, constants.MAX_GRE_ID] |
| 39 |
|
| 40 |
RESOURCE_ATTRIBUTE_MAP = { |
| 41 |
COLLECTION_NAME: { |
| 42 |
'id': {'allow_post': False, |
| 43 |
'allow_put': False, |
| 44 |
'validate': {'type:uuid': None}, |
| 45 |
'is_filter': True, |
| 46 |
'is_sort_key': True, |
| 47 |
'primary_key': True, |
| 48 |
'is_visible': True}, |
| 49 |
'name': {'allow_post': True, |
| 50 |
'allow_put': True, |
| 51 |
'validate': {'type:string': db_const.NAME_FIELD_SIZE}, |
| 52 |
'default': '', |
| 53 |
'is_filter': True, |
| 54 |
'is_sort_key': True, |
| 55 |
'is_visible': True}, |
| 56 |
'default': {'allow_post': False, |
| 57 |
'allow_put': False, |
| 58 |
'convert_to': converters.convert_to_boolean, |
| 59 |
'default': False, |
| 60 |
'is_visible': True}, |
| 61 |
constants.SHARED: {'allow_post': True, |
| 62 |
'allow_put': False, |
| 63 |
'convert_to': converters.convert_to_boolean, |
| 64 |
'default': True, |
| 65 |
'is_visible': True}, |
| 66 |
'project_id': {'allow_post': True, |
| 67 |
'allow_put': False, |
| 68 |
'validate': { |
| 69 |
'type:string': db_const.PROJECT_ID_FIELD_SIZE}, |
| 70 |
'required_by_policy': True, |
| 71 |
'is_filter': True, |
| 72 |
'is_sort_key': True, |
| 73 |
'is_visible': True}, |
| 74 |
'network_type': {'allow_post': True, |
| 75 |
'allow_put': False, |
| 76 |
'validate': { |
| 77 |
'type:values': |
| 78 |
constants.NETWORK_SEGMENT_RANGE_TYPES}, |
| 79 |
'default': constants.ATTR_NOT_SPECIFIED, |
| 80 |
'is_filter': True, |
| 81 |
'is_visible': True}, |
| 82 |
'physical_network': {'allow_post': True, |
| 83 |
'allow_put': False, |
| 84 |
'validate': { |
| 85 |
'type:string': |
| 86 |
providernet.PHYSICAL_NETWORK_MAX_LEN}, |
| 87 |
'default': constants.ATTR_NOT_SPECIFIED, |
| 88 |
'is_filter': True, |
| 89 |
'is_visible': True}, |
| 90 |
'minimum': {'allow_post': True, |
| 91 |
'allow_put': True, |
| 92 |
'convert_to': converters.convert_to_int, |
| 93 |
'validate': {'type:range': NETWORK_SEGMENT_RANGE_LIMIT}, |
| 94 |
'is_visible': True}, |
| 95 |
'maximum': {'allow_post': True, |
| 96 |
'allow_put': True, |
| 97 |
'convert_to': converters.convert_to_int, |
| 98 |
'validate': {'type:range': NETWORK_SEGMENT_RANGE_LIMIT}, |
| 99 |
'is_visible': True}, |
| 100 |
'used': {'allow_post': False, |
| 101 |
'allow_put': False, |
| 102 |
'is_visible': True}, |
| 103 |
'available': {'allow_post': False, |
| 104 |
'allow_put': False, |
| 105 |
'convert_to': converters.convert_none_to_empty_list, |
| 106 |
'is_visible': True} |
| 107 |
} |
| 108 |
} |
| 109 |
|
| 110 |
# Whether or not this extension is simply signaling behavior to the user |
| 111 |
# or it actively modifies the attribute map. |
| 112 |
IS_SHIM_EXTENSION = False |
| 113 |
|
| 114 |
# Whether the extension is marking the adoption of standardattr model for |
| 115 |
# legacy resources, or introducing new standardattr attributes. False or |
| 116 |
# None if the standardattr model is adopted since the introduction of |
| 117 |
# resource extension. |
| 118 |
# If this is True, the alias for the extension should be prefixed with |
| 119 |
# 'standard-attr-'. |
| 120 |
IS_STANDARD_ATTR_EXTENSION = False |
| 121 |
|
| 122 |
# The subresource attribute map for the extension. It adds child resources |
| 123 |
# to main extension's resource. The subresource map must have a parent and |
| 124 |
# a parameters entry. If an extension does not need such a map, None can |
| 125 |
# be specified (mandatory). |
| 126 |
SUB_RESOURCE_ATTRIBUTE_MAP = {} |
| 127 |
|
| 128 |
# The action map: it associates verbs with methods to be performed on |
| 129 |
# the API resource. |
| 130 |
ACTION_MAP = {} |
| 131 |
|
| 132 |
# The list of required extensions. |
| 133 |
REQUIRED_EXTENSIONS = [providernet.ALIAS] |
| 134 |
|
| 135 |
# The list of optional extensions. |
| 136 |
OPTIONAL_EXTENSIONS = [] |
| 137 |
|
| 138 |
# The action status. |
| 139 |
ACTION_STATUS = {} |