Debian Codegraph @

neutron_lib/api/definitions/bgpvpn_routes_control.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 bgpvpn
17 from neutron_lib.db import constants as db_const
18
19
20 # The alias of the extension.
21 ALIAS = 'bgpvpn-routes-control'
22
23 # Whether or not this extension is simply signaling behavior to the user
24 # or it actively modifies the attribute map (mandatory).
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 (mandatory).
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 (mandatory).
36 NAME = 'BGPVPN Routes Control Extension'
37
38 # The description of the extension (mandatory).
39 DESCRIPTION = "Provides support for controlling routes advertised to a BGPVPN"
40
41 # A timestamp of when the extension was introduced (mandatory).
42 UPDATED_TIMESTAMP = "2017-05-20T00:00:00-00:00"
43
44 # The specific resources and/or attributes for the extension (optional).
45 # In case of simple extensions, with single resource, the string constants
46 # RESOURCE_NAME and COLLECTION_NAME can be used, otherwise string literals
47 # can be used instead.
48
49 # The name of the resource introduced or being extended (later case)
50 RESOURCE_NAME = bgpvpn.RESOURCE_NAME
51
52 # The plural for the resource introduced or being extended (later case)
53 COLLECTION_NAME = bgpvpn.COLLECTION_NAME
54
55 LOCAL_PREF_KEY = 'local_pref'
56 LOCAL_PREF_RANGE = [0, 2**32 - 1] # RFC 4271, section 4.3 (p.18)
57
58 RESOURCE_ATTRIBUTE_MAP = {
59 COLLECTION_NAME: {
60 'ports': {'allow_post': False, 'allow_put': False,
61 'is_visible': True,
62 'enforce_policy': True},
63 LOCAL_PREF_KEY: {
64 'allow_post': True, 'allow_put': True,
65 'is_visible': True,
66 'default': None,
67 'validate': {'type:range_or_none': LOCAL_PREF_RANGE},
68 'enforce_policy': True}
69 }
70 }
71
72 PORT_ASSOCIATION = 'port_association'
73 PORT_ASSOCIATIONS = 'port_associations'
74
75 ROUTES = 'routes'
76
77 PREFIX_TYPE = 'prefix'
78 BGPVPN_TYPE = 'bgpvpn'
79 ROUTE_TYPES = [PREFIX_TYPE, BGPVPN_TYPE]
80
81 ADV_FIXED_IPS = 'advertise_fixed_ips'
82
83 TYPE = 'type'
84
85 PREFIX = 'prefix'
86 BGPVPN_ID = 'bgpvpn_id'
87
88 ADV_EXTRA_ROUTES = 'advertise_extra_routes'
89
90 LOCAL_PREF_KEY_SPEC = {'type:range': LOCAL_PREF_RANGE,
91 'required': False}
92
93 ROUTE_SPECS = [
94 {'type': {'type:values': [PREFIX_TYPE],
95 'required': True},
96 'prefix': {'type:subnet': None,
97 'required': True},
98 LOCAL_PREF_KEY: LOCAL_PREF_KEY_SPEC,
99 },
100 {'type': {'type:values': [BGPVPN_TYPE],
101 'required': True},
102 'bgpvpn_id': {'type:uuid': None,
103 'required': True},
104 LOCAL_PREF_KEY: LOCAL_PREF_KEY_SPEC,
105 },
106 ]
107
108 SUB_RESOURCE_ATTRIBUTE_MAP = {
109 PORT_ASSOCIATIONS: {
110 'parent': {
111 'collection_name': COLLECTION_NAME,
112 'member_name': RESOURCE_NAME},
113 'parameters': {
114 'id': {'allow_post': False, 'allow_put': False,
115 'validate': {'type:uuid': None},
116 'is_visible': True,
117 'primary_key': True},
118 'project_id': {'allow_post': True, 'allow_put': False,
119 'validate': {
120 'type:string': db_const.PROJECT_ID_FIELD_SIZE},
121 'required_by_policy': True,
122 'is_visible': True,
123 'enforce_policy': True},
124 'port_id': {'allow_post': True, 'allow_put': False,
125 'validate': {'type:uuid': None},
126 'is_visible': True,
127 'enforce_policy': True},
128 ROUTES: {'allow_post': True, 'allow_put': True,
129 'default': [],
130 'convert_list_to': converters.convert_kvp_list_to_dict,
131 'validate': {
132 'type:list_of_any_key_specs_or_none': ROUTE_SPECS
133 },
134 'enforce_policy': True,
135 'is_visible': True},
136 ADV_FIXED_IPS: {'allow_post': True, 'allow_put': True,
137 'default': True,
138 'convert_to': converters.convert_to_boolean,
139 'is_visible': True},
140 },
141 },
142 bgpvpn.ROUTER_ASSOCIATIONS: {
143 'parent': {'collection_name': COLLECTION_NAME,
144 'member_name': RESOURCE_NAME},
145 'parameters': {
146 ADV_EXTRA_ROUTES: {'allow_post': True, 'allow_put': True,
147 'default': True,
148 'convert_to': converters.convert_to_boolean,
149 'is_visible': True},
150 }
151 }
152 }
153
154
155 ACTION_MAP = {
156 }
157
158 ACTION_STATUS = {}
159
160 REQUIRED_EXTENSIONS = [
161 bgpvpn.ALIAS
162 ]
163
164 OPTIONAL_EXTENSIONS = []