| 1 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 2 |
# not use this file except in compliance with the License. You may obtain |
| 3 |
# a copy of the License at |
| 4 |
# |
| 5 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 6 |
# |
| 7 |
# Unless required by applicable law or agreed to in writing, software |
| 8 |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 9 |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 10 |
# License for the specific language governing permissions and limitations |
| 11 |
# under the License. |
| 12 |
|
| 13 |
from neutron_lib.api import converters |
| 14 |
from neutron_lib.api.definitions import constants as api_const |
| 15 |
from neutron_lib.api.definitions import port |
| 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 = 'fwaas_v2' |
| 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 = 'FWaaS v2' |
| 36 |
|
| 37 |
# The description of the extension. |
| 38 |
DESCRIPTION = "Provides support for firewall-as-a-service version 2" |
| 39 |
|
| 40 |
# A timestamp of when the extension was introduced. |
| 41 |
UPDATED_TIMESTAMP = "2016-10-06T10:00:00-00:00" |
| 42 |
|
| 43 |
# Base for the API calls |
| 44 |
API_PREFIX = '/fwaas' |
| 45 |
|
| 46 |
RESOURCE_ATTRIBUTE_MAP = { |
| 47 |
api_const.FIREWALL_RULES: { |
| 48 |
'id': {'allow_post': False, 'allow_put': False, |
| 49 |
'validate': {'type:uuid': None}, |
| 50 |
'is_visible': True, 'primary_key': True}, |
| 51 |
'tenant_id': {'allow_post': True, 'allow_put': False, |
| 52 |
'required_by_policy': True, |
| 53 |
'validate': {'type:string': |
| 54 |
db_const.UUID_FIELD_SIZE}, |
| 55 |
'is_visible': True}, |
| 56 |
'name': {'allow_post': True, 'allow_put': True, |
| 57 |
'validate': {'type:string': db_const.NAME_FIELD_SIZE}, |
| 58 |
'is_visible': True, 'default': ''}, |
| 59 |
'description': {'allow_post': True, 'allow_put': True, |
| 60 |
'validate': {'type:string': |
| 61 |
db_const.DESCRIPTION_FIELD_SIZE}, |
| 62 |
'is_visible': True, 'default': ''}, |
| 63 |
'firewall_policy_id': {'allow_post': False, 'allow_put': False, |
| 64 |
'validate': {'type:uuid_or_none': None}, |
| 65 |
'is_visible': True}, |
| 66 |
constants.SHARED: { |
| 67 |
'allow_post': True, 'allow_put': True, |
| 68 |
'default': False, 'is_visible': True, |
| 69 |
'convert_to': converters.convert_to_boolean, |
| 70 |
'required_by_policy': True, 'enforce_policy': True |
| 71 |
}, |
| 72 |
'protocol': { |
| 73 |
'allow_post': True, 'allow_put': True, |
| 74 |
'is_visible': True, 'default': None, |
| 75 |
'convert_to': converters.convert_to_protocol, |
| 76 |
'validate': {'type:values': api_const.FW_PROTOCOL_VALUES}}, |
| 77 |
'ip_version': {'allow_post': True, 'allow_put': True, |
| 78 |
'default': 4, 'convert_to': converters.convert_to_int, |
| 79 |
'validate': {'type:values': [4, 6]}, |
| 80 |
'is_visible': True}, |
| 81 |
'source_ip_address': {'allow_post': True, 'allow_put': True, |
| 82 |
'validate': {'type:ip_or_subnet_or_none': None}, |
| 83 |
'is_visible': True, 'default': None}, |
| 84 |
'destination_ip_address': {'allow_post': True, 'allow_put': True, |
| 85 |
'validate': {'type:ip_or_subnet_or_none': |
| 86 |
None}, |
| 87 |
'is_visible': True, 'default': None}, |
| 88 |
'source_port': {'allow_post': True, 'allow_put': True, |
| 89 |
'validate': {'type:port_range': None}, |
| 90 |
'convert_to': converters.convert_to_string, |
| 91 |
'default': None, 'is_visible': True}, |
| 92 |
'destination_port': {'allow_post': True, 'allow_put': True, |
| 93 |
'validate': {'type:port_range': None}, |
| 94 |
'convert_to': converters.convert_to_string, |
| 95 |
'default': None, 'is_visible': True}, |
| 96 |
'position': {'allow_post': False, 'allow_put': False, |
| 97 |
'default': None, 'is_visible': True}, |
| 98 |
'action': {'allow_post': True, 'allow_put': True, |
| 99 |
'convert_to': converters.convert_string_to_case_insensitive, |
| 100 |
'validate': {'type:values': |
| 101 |
api_const.FW_VALID_ACTION_VALUES}, |
| 102 |
'is_visible': True, 'default': 'deny'}, |
| 103 |
'enabled': {'allow_post': True, 'allow_put': True, |
| 104 |
'convert_to': converters.convert_to_boolean, |
| 105 |
'default': True, 'is_visible': True}, |
| 106 |
'source_firewall_group_id': {'allow_post': True, 'allow_put': True, |
| 107 |
'validate': {'type:uuid_or_none': None}, |
| 108 |
'is_visible': True, 'default': None}, |
| 109 |
'destination_firewall_group_id': {'allow_post': True, |
| 110 |
'allow_put': True, |
| 111 |
'validate': |
| 112 |
{'type:uuid_or_none': None}, |
| 113 |
'is_visible': True, 'default': None}, |
| 114 |
}, |
| 115 |
api_const.FIREWALL_GROUPS: { |
| 116 |
'id': {'allow_post': False, 'allow_put': False, |
| 117 |
'validate': {'type:uuid': None}, |
| 118 |
'is_visible': True, |
| 119 |
'primary_key': True}, |
| 120 |
'name': {'allow_post': True, 'allow_put': True, |
| 121 |
'validate': {'type:string': db_const.NAME_FIELD_SIZE}, |
| 122 |
'is_visible': True, 'default': ''}, |
| 123 |
'description': {'allow_post': True, 'allow_put': True, |
| 124 |
'validate': {'type:string': |
| 125 |
db_const.DESCRIPTION_FIELD_SIZE}, |
| 126 |
'is_visible': True, 'default': ''}, |
| 127 |
'admin_state_up': {'allow_post': True, 'allow_put': True, |
| 128 |
'default': True, 'is_visible': True, |
| 129 |
'convert_to': converters.convert_to_boolean}, |
| 130 |
'status': {'allow_post': False, 'allow_put': False, |
| 131 |
'is_visible': True}, |
| 132 |
constants.SHARED: { |
| 133 |
'allow_post': True, 'allow_put': True, 'default': False, |
| 134 |
'convert_to': converters.convert_to_boolean, |
| 135 |
'is_visible': True, 'required_by_policy': True, |
| 136 |
'enforce_policy': True |
| 137 |
}, |
| 138 |
port.COLLECTION_NAME: {'allow_post': True, 'allow_put': True, |
| 139 |
'validate': {'type:uuid_list': None}, |
| 140 |
'convert_to': |
| 141 |
converters.convert_none_to_empty_list, |
| 142 |
'default': None, 'is_visible': True}, |
| 143 |
'tenant_id': {'allow_post': True, 'allow_put': False, |
| 144 |
'required_by_policy': True, |
| 145 |
'validate': {'type:string': |
| 146 |
db_const.UUID_FIELD_SIZE}, |
| 147 |
'is_visible': True}, |
| 148 |
'ingress_firewall_policy_id': {'allow_post': True, |
| 149 |
'allow_put': True, |
| 150 |
'validate': {'type:uuid_or_none': |
| 151 |
None}, |
| 152 |
'default': None, 'is_visible': True}, |
| 153 |
'egress_firewall_policy_id': {'allow_post': True, |
| 154 |
'allow_put': True, |
| 155 |
'validate': {'type:uuid_or_none': |
| 156 |
None}, |
| 157 |
'default': None, 'is_visible': True}, |
| 158 |
}, |
| 159 |
api_const.FIREWALL_POLICIES: { |
| 160 |
'id': {'allow_post': False, 'allow_put': False, |
| 161 |
'validate': {'type:uuid': None}, |
| 162 |
'is_visible': True, |
| 163 |
'primary_key': True}, |
| 164 |
'tenant_id': {'allow_post': True, 'allow_put': False, |
| 165 |
'required_by_policy': True, |
| 166 |
'validate': {'type:string': |
| 167 |
db_const.UUID_FIELD_SIZE}, |
| 168 |
'is_visible': True}, |
| 169 |
'name': {'allow_post': True, 'allow_put': True, |
| 170 |
'validate': {'type:string': db_const.NAME_FIELD_SIZE}, |
| 171 |
'is_visible': True, 'default': ''}, |
| 172 |
'description': {'allow_post': True, 'allow_put': True, |
| 173 |
'validate': {'type:string': |
| 174 |
db_const.DESCRIPTION_FIELD_SIZE}, |
| 175 |
'is_visible': True, 'default': ''}, |
| 176 |
constants.SHARED: { |
| 177 |
'allow_post': True, 'allow_put': True, 'default': False, |
| 178 |
'convert_to': converters.convert_to_boolean, |
| 179 |
'is_visible': True, 'required_by_policy': True, |
| 180 |
'enforce_policy': True |
| 181 |
}, |
| 182 |
api_const.FIREWALL_RULES: {'allow_post': True, 'allow_put': True, |
| 183 |
'validate': {'type:uuid_list': None}, |
| 184 |
'convert_to': |
| 185 |
converters.convert_none_to_empty_list, |
| 186 |
'default': None, 'is_visible': True}, |
| 187 |
'audited': {'allow_post': True, 'allow_put': True, 'default': False, |
| 188 |
'convert_to': converters.convert_to_boolean, |
| 189 |
'is_visible': True}, |
| 190 |
|
| 191 |
}, |
| 192 |
} |
| 193 |
|
| 194 |
# The subresource attribute map for the extension. This extension has only |
| 195 |
# top level resources, not child resources, so this is set to an empty dict. |
| 196 |
SUB_RESOURCE_ATTRIBUTE_MAP = { |
| 197 |
} |
| 198 |
|
| 199 |
# The action map. |
| 200 |
ACTION_MAP = { |
| 201 |
'firewall_policy': {'insert_rule': 'PUT', 'remove_rule': 'PUT'}, |
| 202 |
} |
| 203 |
|
| 204 |
# The action status. |
| 205 |
ACTION_STATUS = { |
| 206 |
} |
| 207 |
|
| 208 |
# The list of required extensions. |
| 209 |
REQUIRED_EXTENSIONS = [ |
| 210 |
] |
| 211 |
|
| 212 |
# The list of optional extensions. |
| 213 |
OPTIONAL_EXTENSIONS = [ |
| 214 |
] |