Debian Codegraph @

neutron_lib/api/definitions/extra_dhcp_opt.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 port
17
18
19 # Common definitions for maximum string field length
20 DHCP_OPT_NAME_MAX_LEN = 64
21 VALID_BLANK_EXTRA_DHCP_OPTS = ('router', 'classless-static-route')
22 DHCP_OPT_VALUE_MAX_LEN = 255
23
24
25 EXTRA_DHCP_OPT_KEY_SPECS = [
26 # key spec for opt_name in _VALID_BLANK_EXTRA_DHCP_OPTS
27 {'opt_name': {'type:values': VALID_BLANK_EXTRA_DHCP_OPTS,
28 'required': True},
29 'opt_value': {'type:string_or_none':
30 DHCP_OPT_VALUE_MAX_LEN,
31 'required': True},
32 'ip_version': {'convert_to': converters.convert_to_int,
33 'type:values': [4, 6],
34 'required': False}},
35 # key spec if opt_name not in _VALID_BLANK_EXTRA_DHCP_OPTS
36 {'opt_name': {'type:oneline_not_empty_string': DHCP_OPT_NAME_MAX_LEN,
37 'required': True},
38 'opt_value': {'type:oneline_not_empty_string_or_none':
39 DHCP_OPT_VALUE_MAX_LEN,
40 'required': True},
41 'ip_version': {'convert_to': converters.convert_to_int,
42 'type:values': [4, 6],
43 'required': False}}
44 ]
45
46 EXTRADHCPOPTS = 'extra_dhcp_opts'
47 DHCP_OPT_CLIENT_ID = "client-id"
48
49 # client-id option value as defined in RFC 4776
50 DHCP_OPT_CLIENT_ID_NUM = 61
51
52 # The alias of the extension.
53 ALIAS = 'extra_dhcp_opt'
54
55 # Whether or not this extension is simply signaling behavior to the user
56 # or it actively modifies the attribute map (mandatory).
57 IS_SHIM_EXTENSION = False
58
59 # Whether the extension is marking the adoption of standardattr model for
60 # legacy resources, or introducing new standardattr attributes. False or
61 # None if the standardattr model is adopted since the introduction of
62 # resource extension (mandatory).
63 # If this is True, the alias for the extension should be prefixed with
64 # 'standard-attr-'.
65 IS_STANDARD_ATTR_EXTENSION = False
66
67 # The name of the extension (mandatory).
68 NAME = 'Neutron Extra DHCP options'
69
70 # A prefix for API resources. An empty prefix means that the API is going
71 # to be exposed at the v2/ level as any other core resource (mandatory).
72 API_PREFIX = ''
73
74 # The description of the extension (mandatory).
75 DESCRIPTION = ("Extra options configuration for DHCP. "
76 "For example PXE boot options to DHCP clients can "
77 "be specified (e.g. tftp-server, server-ip-address, "
78 "bootfile-name)")
79
80 # A timestamp of when the extension was introduced (mandatory).
81 UPDATED_TIMESTAMP = "2013-03-17T12:00:00-00:00"
82
83 # The specific resources and/or attributes for the extension (optional).
84 # In case of simple extensions, with single resource, the string constants
85 # RESOURCE_NAME and COLLECTION_NAME can be used, otherwise string literals
86 # can be used instead.
87
88 # The name of the resource introduced or being extended
89 # (in case it is defined by another extension, or it is
90 # a core resource).
91 RESOURCE_NAME = port.RESOURCE_NAME
92
93 # The plural for the resource introduced or being extended
94 # (in case it is defined by another extension, or it is a
95 # core resource).
96 COLLECTION_NAME = port.COLLECTION_NAME
97
98 # The resource attribute map for the extension. It is effectively the
99 # bulk of the API contract alongside ACTION_MAP (mandatory).
100 RESOURCE_ATTRIBUTE_MAP = {
101 COLLECTION_NAME: {
102 EXTRADHCPOPTS: {
103 'allow_post': True,
104 'allow_put': True,
105 'is_visible': True,
106 'default': None,
107 'validate': {
108 'type:list_of_any_key_specs_or_none': EXTRA_DHCP_OPT_KEY_SPECS
109 }
110 }
111 }
112 }
113
114 # The subresource attribute map for the extension. It adds child resources
115 # to main extension's resource. The subresource map must have a parent and
116 # a parameters entry. If an extension does not need such a map, None can
117 # be specified (mandatory).
118 SUB_RESOURCE_ATTRIBUTE_MAP = {}
119
120 # The action map: it associates verbs with methods to be performed on
121 # the API resource (mandatory).
122 ACTION_MAP = {}
123
124 # The list of required extensions (mandatory).
125 REQUIRED_EXTENSIONS = []
126
127 # The list of optional extensions (mandatory).
128 OPTIONAL_EXTENSIONS = []
129
130 ACTION_STATUS = {}