Debian Codegraph @

neutron_lib/api/definitions/portbindings_extended.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.definitions import port
16 from neutron_lib.api.definitions import portbindings
17 from neutron_lib import constants
18 from neutron_lib.db import constants as db_const
19
20 # Plural of the resource
21 COLLECTION_NAME = 'bindings'
22
23 # Name of the resource
24 RESOURCE_NAME = 'binding'
25
26 # Parent
27 PARENT_RESOURCE_NAME = port.RESOURCE_NAME
28 PARENT_COLLECTION_NAME = port.COLLECTION_NAME
29
30 # Whether or not this extension is simply signaling behavior to the user
31 # or it actively modifies the attribute map.
32 IS_SHIM_EXTENSION = False
33
34 # Whether the extension is marking the adoption of standardattr model for
35 # legacy resources, or introducing new standardattr attributes. False or
36 # None if the standardattr model is adopted since the introduction of
37 # resource extension.
38 # If this is True, the alias for the extension should be prefixed with
39 # 'standard-attr-'.
40 IS_STANDARD_ATTR_EXTENSION = False
41
42 # Name of the extension
43 NAME = "Port Bindings Extended"
44
45 # Extension alias
46 ALIAS = 'binding-extended'
47
48 # Extension description
49 DESCRIPTION = "Expose port bindings of a virtual port to external application"
50
51 # Action name for activating a port binding
52 ACTIVATE_BINDING = 'activate'
53
54 # Timestamp of last update of this extension
55 UPDATED_TIMESTAMP = "2017-07-17T10:00:00-00:00"
56
57 # Extension attributes
58 HOST = 'host'
59 VIF_TYPE = 'vif_type'
60 VIF_DETAILS = 'vif_details'
61 VNIC_TYPE = 'vnic_type'
62 PROFILE = 'profile'
63 STATUS = 'status'
64 PROJECT_ID = 'project_id'
65
66 # No attribute map, this extension defines only sub resource
67 RESOURCE_ATTRIBUTE_MAP = {}
68
69 # Attribute map of bindings
70 SUB_RESOURCE_ATTRIBUTE_MAP = {
71 COLLECTION_NAME: {
72 'parent': {
73 'collection_name': PARENT_COLLECTION_NAME,
74 'member_name': PARENT_RESOURCE_NAME},
75 'parameters': {
76 HOST: {'allow_post': True, 'allow_put': True,
77 'is_visible': True, 'primary_key': True,
78 'is_filter': True},
79 VIF_TYPE: {'allow_post': False, 'allow_put': False,
80 'default': constants.ATTR_NOT_SPECIFIED,
81 'enforce_policy': True,
82 'is_visible': True, 'is_filter': True},
83 VIF_DETAILS: {'allow_post': False, 'allow_put': False,
84 'default': constants.ATTR_NOT_SPECIFIED,
85 'enforce_policy': True,
86 'is_visible': True},
87 VNIC_TYPE: {'allow_post': True, 'allow_put': True,
88 'default': portbindings.VNIC_NORMAL,
89 'is_visible': True,
90 'is_filter': True,
91 'validate': {'type:values': portbindings.VNIC_TYPES},
92 'enforce_policy': True},
93 PROFILE: {'allow_post': True, 'allow_put': True,
94 'default': constants.ATTR_NOT_SPECIFIED,
95 'enforce_policy': True,
96 'validate': {'type:dict_or_none': None},
97 'is_visible': True},
98 STATUS: {'allow_post': False, 'allow_put': False,
99 'is_visible': True, 'is_filter': True},
100 PROJECT_ID: {'allow_post': True, 'allow_put': False,
101 'required_by_policy': True,
102 'validate': {
103 'type:string': db_const.PROJECT_ID_FIELD_SIZE},
104 'is_visible': True},
105 }
106 }
107 }
108
109 # activate is an action
110 ACTION_MAP = {
111 RESOURCE_NAME: {
112 ACTIVATE_BINDING: 'PUT',
113 },
114 }
115
116 # No action statuses are required
117 ACTION_STATUS = {
118 }
119
120 # The list of required extensions
121 REQUIRED_EXTENSIONS = [
122 portbindings.ALIAS,
123 ]
124
125 # The list of optional extensions
126 OPTIONAL_EXTENSIONS = []