Debian Codegraph @

neutron_lib/api/definitions/logging_resource.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 firewall_v2
17 from neutron_lib.db import constants as db_const
18
19
20 # The alias of the extension.
21 ALIAS = 'logging-resource'
22
23 # Whether or not this extension is simply signaling behavior to the user
24 # or it actively modifies the attribute map.
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.
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.
36 NAME = 'Logging Resource Extension'
37
38 # A prefix for API resources. An empty prefix means that the API is going
39 # to be exposed at the v2/ level as any other core resource.
40 API_PREFIX = '/logging'
41
42 # The description of the extension.
43 DESCRIPTION = "The logging resource extension."
44
45 # A timestamp of when the extension was introduced.
46 UPDATED_TIMESTAMP = "2016-06-06T10:00:00-00:00"
47
48 # The name of the resource.
49 RESOURCE_NAME = 'logging_resource'
50
51 # The plural for the resource.
52 COLLECTION_NAME = 'logging_resources'
53
54 # Attributes
55 ENABLED = 'enabled'
56
57 # Sub resource
58 FIREWALL_LOGS = 'firewall_logs'
59
60
61 LOGGING_RESOURCE_ID = 'logging_resource_id'
62 FW_EVENT = 'fw_event'
63 FIREWALL_ID = 'firewall_id'
64
65
66 FW_EVENT_ACCEPT = 'ACCEPT'
67 FW_EVENT_DROP = 'DROP'
68 FW_EVENT_ALL = 'ALL'
69 FW_EVENTS = [FW_EVENT_ACCEPT, FW_EVENT_DROP, FW_EVENT_ALL]
70 LOG_COMMON_FIELDS = {
71 'id': {'allow_post': False, 'allow_put': False,
72 'validate': {'type:uuid': None},
73 'is_visible': True, 'primary_key': True},
74 'tenant_id': {'allow_post': True, 'allow_put': False,
75 'required_by_policy': True, 'is_visible': True},
76 LOGGING_RESOURCE_ID: {'allow_post': False, 'allow_put': False,
77 'is_visible': True}
78 }
79
80 RESOURCE_ATTRIBUTE_MAP = {
81 COLLECTION_NAME: {
82 'id': {'allow_post': False, 'allow_put': False,
83 'validate': {'type:uuid': None}, 'is_visible': True,
84 'primary_key': True},
85 'tenant_id': {'allow_post': True, 'allow_put': False,
86 'required_by_policy': True, 'is_visible': True},
87 'name': {'allow_post': True, 'allow_put': True,
88 'validate': {'type:string': db_const.NAME_FIELD_SIZE},
89 'default': '', 'is_visible': True},
90 'description': {
91 'allow_post': True, 'allow_put': True,
92 'validate': {'type:string': db_const.LONG_DESCRIPTION_FIELD_SIZE},
93 'default': '', 'is_visible': True},
94 ENABLED: {'allow_post': True, 'allow_put': True,
95 'is_visible': True, 'default': False,
96 'convert_to': converters.convert_to_boolean},
97 FIREWALL_LOGS: {'allow_post': False, 'allow_put': False,
98 'is_visible': True}
99 }
100 }
101
102
103 SUB_RESOURCE_ATTRIBUTE_MAP = {
104 FIREWALL_LOGS: {
105 'parent': {'collection_name': COLLECTION_NAME,
106 'member_name': RESOURCE_NAME},
107 'parameters': dict((LOG_COMMON_FIELDS), **{
108 'description': {
109 'allow_post': True, 'allow_put': True,
110 'validate': {
111 'type:string': db_const.LONG_DESCRIPTION_FIELD_SIZE},
112 'default': '', 'is_visible': True},
113 FIREWALL_ID: {
114 'allow_post': True, 'allow_put': False,
115 'is_visible': True,
116 'validate': {'type:uuid': None}},
117 FW_EVENT: {
118 'allow_post': True, 'allow_put': True,
119 'is_visible': True,
120 'validate': {'type:values': FW_EVENTS},
121 'default': FW_EVENT_ALL}
122 }),
123 },
124 }
125
126 # The action map.
127 ACTION_MAP = {}
128
129 # The action status.
130 ACTION_STATUS = {
131 }
132
133 # The list of required extensions.
134 REQUIRED_EXTENSIONS = [
135 firewall_v2.ALIAS,
136 ]
137
138 # The list of optional extensions.
139 OPTIONAL_EXTENSIONS = []