Debian Codegraph @

neutron_lib/api/definitions/bgpvpn.py

raw
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 l3
17 from neutron_lib.db import constants as db_const
18
19 # Regular expression to validate 32 bits unsigned int
20 UINT32_REGEX = (r'(0|[1-9]\d{0,8}|[1-3]\d{9}|4[01]\d{8}|42[0-8]\d{7}'
21 r'|429[0-3]\d{6}|4294[0-8]\d{5}|42949[0-5]\d{4}'
22 r'|429496[0-6]\d{3}|4294967[0-1]\d{2}|42949672[0-8]\d'
23 r'|429496729[0-5])')
24 # Regular expression to validate 16 bits unsigned int
25 UINT16_REGEX = (r'(0|[1-9]\d{0,3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}'
26 r'|655[0-2]\d|6553[0-5])')
27 # Regular expression to validate 8 bits unsigned int
28 UINT8_REGEX = (r'(0|[1-9]\d{0,1}|1\d{2}|2[0-4]\d|25[0-5])')
29 # Regular expression to validate IPv4 address
30 IP4_REGEX = (rf'({UINT8_REGEX}\.{UINT8_REGEX}\.{UINT8_REGEX}\.{UINT8_REGEX})')
31 # Regular expression to validate Route Target list format
32 # Support of the Type 0, Type 1 and Type 2, cf. chapter 4.2 in RFC 4364
33 # Also validates Route Distinguisher list format
34 RTRD_REGEX = (
35 rf'^({UINT16_REGEX}:{UINT32_REGEX}|{IP4_REGEX}:'
36 rf'{UINT16_REGEX}|{UINT32_REGEX}:{UINT16_REGEX})$')
37
38 # The alias of the extension.
39 ALIAS = 'bgpvpn'
40
41 # Whether or not this extension is simply signaling behavior to the user
42 # or it actively modifies the attribute map.
43 IS_SHIM_EXTENSION = False
44
45 # Whether the extension is marking the adoption of standardattr model for
46 # legacy resources, or introducing new standardattr attributes. False or
47 # None if the standardattr model is adopted since the introduction of
48 # resource extension.
49 # If this is True, the alias for the extension should be prefixed with
50 # 'standard-attr-'.
51 IS_STANDARD_ATTR_EXTENSION = False
52
53 # The name of the extension.
54 NAME = 'BGPVPN Extension'
55
56 # The description of the extension.
57 DESCRIPTION = "Provides support for BGP VPN interconnections"
58
59 # A timestamp of when the extension was introduced.
60 UPDATED_TIMESTAMP = "2014-06-10T17:00:00-00:00"
61
62 API_PREFIX = '/bgpvpn'
63
64
65 # The specific resources and/or attributes for the extension (optional).
66 RESOURCE_NAME = 'bgpvpn'
67 COLLECTION_NAME = 'bgpvpns'
68 BGPVPN_L2 = 'l2'
69 BGPVPN_L3 = 'l3'
70 BGPVPN_RES = "bgpvpns"
71 BGPVPN_TYPES = [BGPVPN_L3, BGPVPN_L2]
72 NETWORK_ASSOCIATION = 'network_association'
73 NETWORK_ASSOCIATIONS = 'network_associations'
74 ROUTER_ASSOCIATION = 'router_association'
75 ROUTER_ASSOCIATIONS = 'router_associations'
76
77 # The resource attribute map for the extension.
78 RESOURCE_ATTRIBUTE_MAP = {
79 COLLECTION_NAME: {
80 'id': {'allow_post': False, 'allow_put': False,
81 'validate': {'type:uuid': None},
82 'is_visible': True,
83 'primary_key': True,
84 'enforce_policy': True},
85 'tenant_id': {'allow_post': True, 'allow_put': False,
86 'validate': {
87 'type:string': db_const.PROJECT_ID_FIELD_SIZE},
88 'required_by_policy': True,
89 'is_visible': True,
90 'enforce_policy': True},
91 'name': {'allow_post': True, 'allow_put': True,
92 'default': '',
93 'validate': {'type:string': db_const.NAME_FIELD_SIZE},
94 'is_visible': True,
95 'enforce_policy': True},
96 'type': {'allow_post': True, 'allow_put': False,
97 'default': BGPVPN_L3,
98 'validate': {'type:values': BGPVPN_TYPES},
99 'is_visible': True,
100 'enforce_policy': True},
101 'route_targets': {'allow_post': True, 'allow_put': True,
102 'default': [],
103 'convert_to': converters.convert_to_list,
104 'validate': {'type:list_of_regex_or_none':
105 RTRD_REGEX},
106 'is_visible': True,
107 'enforce_policy': True},
108 'import_targets': {'allow_post': True, 'allow_put': True,
109 'default': [],
110 'convert_to': converters.convert_to_list,
111 'validate': {'type:list_of_regex_or_none':
112 RTRD_REGEX},
113 'is_visible': True,
114 'enforce_policy': True},
115 'export_targets': {'allow_post': True, 'allow_put': True,
116 'default': [],
117 'convert_to': converters.convert_to_list,
118 'validate': {'type:list_of_regex_or_none':
119 RTRD_REGEX},
120 'is_visible': True,
121 'enforce_policy': True},
122 'route_distinguishers': {'allow_post': True, 'allow_put': True,
123 'default': [],
124 'convert_to': converters.convert_to_list,
125 'validate': {'type:list_of_regex_or_none':
126 RTRD_REGEX},
127 'is_visible': True,
128 'enforce_policy': True},
129 'networks': {'allow_post': False, 'allow_put': False,
130 'is_visible': True,
131 'enforce_policy': True},
132 'routers': {'allow_post': False, 'allow_put': False,
133 'is_visible': True,
134 'enforce_policy': True},
135 },
136 }
137
138 SUB_RESOURCE_ATTRIBUTE_MAP = {
139 NETWORK_ASSOCIATIONS: {
140 'parent': {'collection_name': COLLECTION_NAME,
141 'member_name': RESOURCE_NAME},
142 'parameters': {
143 'id': {'allow_post': False, 'allow_put': False,
144 'validate': {'type:uuid': None},
145 'is_visible': True,
146 'primary_key': True},
147 'tenant_id': {'allow_post': True, 'allow_put': False,
148 'validate': {
149 'type:string': db_const.PROJECT_ID_FIELD_SIZE},
150 'required_by_policy': True,
151 'is_visible': True,
152 'enforce_policy': True},
153 'network_id': {'allow_post': True, 'allow_put': False,
154 'validate': {'type:uuid': None},
155 'is_visible': True,
156 'enforce_policy': True}
157 }
158 },
159 ROUTER_ASSOCIATIONS: {
160 'parent': {'collection_name': COLLECTION_NAME,
161 'member_name': RESOURCE_NAME},
162 'parameters': {
163 'id': {'allow_post': False, 'allow_put': False,
164 'validate': {'type:uuid': None},
165 'is_visible': True,
166 'primary_key': True},
167 'tenant_id': {'allow_post': True, 'allow_put': False,
168 'validate': {
169 'type:string': db_const.PROJECT_ID_FIELD_SIZE},
170 'required_by_policy': True,
171 'is_visible': True,
172 'enforce_policy': True},
173 'router_id': {'allow_post': True, 'allow_put': False,
174 'validate': {'type:uuid': None},
175 'is_visible': True,
176 'enforce_policy': True}
177 }
178 }
179 }
180
181 ACTION_MAP = {
182 }
183
184 # The action status.
185 ACTION_STATUS = {
186 }
187
188 # The list of required extensions.
189 REQUIRED_EXTENSIONS = [l3.ALIAS]
190
191 # The list of optional extensions.
192 OPTIONAL_EXTENSIONS = [
193 ]