Debian Codegraph @

neutron_lib/api/definitions/flowclassifier.py

raw
1 # Copyright 2015 Futurewei. 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 import constants
17 from neutron_lib.db import constants as db_const
18
19 # The alias of the extension.
20 ALIAS = 'flow_classifier'
21
22 # Whether or not this extension is simply signaling behavior to the user
23 # or it actively modifies the attribute map.
24 IS_SHIM_EXTENSION = False
25
26 # Whether the extension is marking the adoption of standardattr model for
27 # legacy resources, or introducing new standardattr attributes. False or
28 # None if the standardattr model is adopted since the introduction of
29 # resource extension.
30 # If this is True, the alias for the extension should be prefixed with
31 # 'standard-attr-'.
32 IS_STANDARD_ATTR_EXTENSION = False
33
34 # The name of the extension.
35 NAME = 'Flow Classifier'
36
37 # A prefix for API resources. An empty prefix means that the API is going
38 # to be exposed at the v2/ level as any other core resource.
39 API_PREFIX = '/sfc'
40
41 # The description of the extension.
42 DESCRIPTION = ("API for selection of packets to direct through service "
43 "function chains")
44
45 # A timestamp of when the extension was last updated.
46 UPDATED_TIMESTAMP = "2015-10-05T10:00:00-00:00"
47
48
49 FC_SUPPORTED_ETHERTYPES = [constants.IPv4, constants.IPv6]
50
51
52 RESOURCE_NAME = 'flow_classifier'
53 COLLECTION_NAME = 'flow_classifiers'
54
55
56 # Attribute Map
57 RESOURCE_ATTRIBUTE_MAP = {
58 COLLECTION_NAME: {
59 'id': {
60 'allow_post': False, 'allow_put': False,
61 'is_visible': True,
62 'validate': {'type:uuid': None},
63 'primary_key': True},
64 'name': {
65 'allow_post': True, 'allow_put': True,
66 'is_visible': True, 'default': None,
67 'validate': {'type:string': db_const.NAME_FIELD_SIZE},
68 'convert_to': converters.convert_none_to_empty_string},
69 'description': {
70 'allow_post': True, 'allow_put': True,
71 'is_visible': True, 'default': None,
72 'validate': {'type:string': db_const.DESCRIPTION_FIELD_SIZE},
73 'convert_to': converters.convert_none_to_empty_string},
74 'tenant_id': {
75 'allow_post': True, 'allow_put': False,
76 'is_visible': True,
77 'validate': {'type:string': db_const.PROJECT_ID_FIELD_SIZE},
78 'required_by_policy': True},
79 'ethertype': {
80 'allow_post': True, 'allow_put': False,
81 'is_visible': True, 'default': "IPv4",
82 'default_overrides_none': True,
83 'validate': {'type:values': FC_SUPPORTED_ETHERTYPES},
84 'convert_to': converters.convert_uppercase_ip},
85 'protocol': {
86 'allow_post': True, 'allow_put': False,
87 'is_visible': True, 'default': None,
88 'convert_to': converters.convert_to_protocol},
89 'source_port_range_min': {
90 'allow_post': True, 'allow_put': False,
91 'is_visible': True, 'default': None,
92 'convert_to': converters.convert_to_int_if_not_none,
93 'validate': {'type:range_or_none': [0, constants.PORT_MAX]}},
94 'source_port_range_max': {
95 'allow_post': True, 'allow_put': False,
96 'is_visible': True, 'default': None,
97 'convert_to': converters.convert_to_int_if_not_none,
98 'validate': {'type:range_or_none': [0, constants.PORT_MAX]}},
99 'destination_port_range_min': {
100 'allow_post': True, 'allow_put': False,
101 'is_visible': True, 'default': None,
102 'convert_to': converters.convert_to_int_if_not_none,
103 'validate': {'type:range_or_none': [0, constants.PORT_MAX]}},
104 'destination_port_range_max': {
105 'allow_post': True, 'allow_put': False,
106 'is_visible': True, 'default': None,
107 'convert_to': converters.convert_to_int_if_not_none,
108 'validate': {'type:range_or_none': [0, constants.PORT_MAX]}},
109 'source_ip_prefix': {
110 'allow_post': True, 'allow_put': False,
111 'is_visible': True, 'default': None,
112 'validate': {'type:subnet_or_none': None}},
113 'destination_ip_prefix': {
114 'allow_post': True, 'allow_put': False,
115 'is_visible': True, 'default': None,
116 'validate': {'type:subnet_or_none': None}},
117 'logical_source_port': {
118 'allow_post': True, 'allow_put': False,
119 'is_visible': True, 'default': None,
120 'validate': {'type:uuid_or_none': None}},
121 'logical_destination_port': {
122 'allow_post': True, 'allow_put': False,
123 'is_visible': True, 'default': None,
124 'validate': {'type:uuid_or_none': None}},
125 'l7_parameters': {
126 # NOTE(tmorin): at this point, there is no clean way to extend
127 # this attribute; it seems only used by GBP (by monkeypatching it
128 # at runtime, see
129 # http://codesearch.openstack.org/?q=AIM_FLC_L7_PARAMS)
130 # So let's support the GBP fields by now, but consider that
131 # future additions will need to happen via proper API extensions
132 'allow_post': True, 'allow_put': False,
133 'is_visible': True,
134 'default': {}, 'default_overrides_none': True,
135 'convert_to': converters.convert_none_to_empty_dict,
136 'validate': {
137 'type:dict': {
138 'logical_source_network': {
139 'default': None,
140 'type:uuid_or_none': None
141 },
142 'logical_destination_network': {
143 'default': None,
144 'type:uuid_or_none': None
145 }
146 }
147 }
148 }
149 },
150 }
151
152 # The subresource attribute map for the extension. It adds child resources
153 # to main extension's resource. The subresource map must have a parent and
154 # a parameters entry. If an extension does not need such a map, None can
155 # be specified (mandatory).
156 SUB_RESOURCE_ATTRIBUTE_MAP = None
157
158 # The action map: it associates verbs with methods to be performed on
159 # the API resource.
160 ACTION_MAP = {
161 }
162
163 # The action status.
164 ACTION_STATUS = {
165 }
166
167 # The list of required extensions.
168 REQUIRED_EXTENSIONS = [
169 ]
170
171 # The list of optional extensions.
172 OPTIONAL_EXTENSIONS = [
173 ]