| 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 import constants |
| 15 |
from neutron_lib.db import constants as db_const |
| 16 |
|
| 17 |
|
| 18 |
NAME = 'Neutron L3 Subnet' |
| 19 |
ALIAS = 'subnet' |
| 20 |
DESCRIPTION = "Layer 3 subnet abstraction" |
| 21 |
|
| 22 |
UPDATED_TIMESTAMP = "2012-01-01T10:00:00-00:00" |
| 23 |
|
| 24 |
RESOURCE_NAME = 'subnet' |
| 25 |
COLLECTION_NAME = 'subnets' |
| 26 |
|
| 27 |
RESOURCE_ATTRIBUTE_MAP = { |
| 28 |
COLLECTION_NAME: { |
| 29 |
'id': {'allow_post': False, 'allow_put': False, |
| 30 |
'validate': {'type:uuid': None}, |
| 31 |
'is_visible': True, |
| 32 |
'is_filter': True, |
| 33 |
'is_sort_key': True, |
| 34 |
'primary_key': True}, |
| 35 |
'name': {'allow_post': True, 'allow_put': True, 'default': '', |
| 36 |
'validate': { |
| 37 |
'type:string': db_const.NAME_FIELD_SIZE}, |
| 38 |
'is_filter': True, |
| 39 |
'is_sort_key': True, |
| 40 |
'is_visible': True}, |
| 41 |
'ip_version': {'allow_post': True, 'allow_put': False, |
| 42 |
'convert_to': converters.convert_to_int, |
| 43 |
'validate': {'type:values': [4, 6]}, |
| 44 |
'is_filter': True, |
| 45 |
'is_sort_key': True, |
| 46 |
'is_visible': True}, |
| 47 |
'network_id': {'allow_post': True, 'allow_put': False, |
| 48 |
'required_by_policy': True, |
| 49 |
'validate': {'type:uuid': None}, |
| 50 |
'is_filter': True, |
| 51 |
'is_sort_key': True, |
| 52 |
'is_visible': True}, |
| 53 |
'subnetpool_id': {'allow_post': True, |
| 54 |
'allow_put': False, |
| 55 |
'default': constants.ATTR_NOT_SPECIFIED, |
| 56 |
'required_by_policy': False, |
| 57 |
'validate': {'type:subnetpool_id_or_none': None}, |
| 58 |
'is_filter': True, |
| 59 |
'is_sort_key': True, |
| 60 |
'is_visible': True}, |
| 61 |
'prefixlen': {'allow_post': True, |
| 62 |
'allow_put': False, |
| 63 |
'validate': {'type:non_negative': None}, |
| 64 |
'convert_to': converters.convert_to_int, |
| 65 |
'default': constants.ATTR_NOT_SPECIFIED, |
| 66 |
'required_by_policy': False, |
| 67 |
'is_visible': False}, |
| 68 |
'cidr': {'allow_post': True, |
| 69 |
'allow_put': False, |
| 70 |
'default': constants.ATTR_NOT_SPECIFIED, |
| 71 |
'convert_to': converters.convert_cidr_to_canonical_format, |
| 72 |
'validate': {'type:subnet_or_none': None}, |
| 73 |
'required_by_policy': False, |
| 74 |
'is_filter': True, |
| 75 |
'is_sort_key': True, |
| 76 |
'is_visible': True}, |
| 77 |
'gateway_ip': {'allow_post': True, 'allow_put': True, |
| 78 |
'default': constants.ATTR_NOT_SPECIFIED, |
| 79 |
'convert_to': converters.convert_ip_to_canonical_format, |
| 80 |
'validate': {'type:ip_address_or_none': None}, |
| 81 |
'is_filter': True, |
| 82 |
'is_sort_key': True, |
| 83 |
'is_visible': True}, |
| 84 |
'allocation_pools': { |
| 85 |
'allow_post': True, 'allow_put': True, |
| 86 |
'default': constants.ATTR_NOT_SPECIFIED, |
| 87 |
'convert_to': ( |
| 88 |
converters.convert_allocation_pools_to_canonical_format |
| 89 |
), |
| 90 |
'validate': {'type:ip_pools': None}, |
| 91 |
'is_visible': True}, |
| 92 |
'dns_nameservers': {'allow_post': True, 'allow_put': True, |
| 93 |
'convert_to': |
| 94 |
converters.convert_none_to_empty_list, |
| 95 |
'default': constants.ATTR_NOT_SPECIFIED, |
| 96 |
'validate': {'type:nameservers': None}, |
| 97 |
'is_visible': True}, |
| 98 |
'host_routes': {'allow_post': True, 'allow_put': True, |
| 99 |
'convert_to': |
| 100 |
converters.convert_none_to_empty_list, |
| 101 |
'default': constants.ATTR_NOT_SPECIFIED, |
| 102 |
'validate': {'type:hostroutes': None}, |
| 103 |
'is_visible': True}, |
| 104 |
'tenant_id': {'allow_post': True, 'allow_put': False, |
| 105 |
'validate': { |
| 106 |
'type:string': db_const.PROJECT_ID_FIELD_SIZE}, |
| 107 |
'required_by_policy': True, |
| 108 |
'is_filter': True, |
| 109 |
'is_sort_key': True, |
| 110 |
'is_visible': True}, |
| 111 |
'enable_dhcp': {'allow_post': True, 'allow_put': True, |
| 112 |
'default': True, |
| 113 |
'convert_to': converters.convert_to_boolean, |
| 114 |
'is_filter': True, |
| 115 |
'is_sort_key': True, |
| 116 |
'is_visible': True}, |
| 117 |
'ipv6_ra_mode': {'allow_post': True, 'allow_put': False, |
| 118 |
'default': constants.ATTR_NOT_SPECIFIED, |
| 119 |
'validate': { |
| 120 |
'type:values': constants.IPV6_MODES}, |
| 121 |
'is_filter': True, |
| 122 |
'is_sort_key': True, |
| 123 |
'is_visible': True}, |
| 124 |
'ipv6_address_mode': {'allow_post': True, 'allow_put': False, |
| 125 |
'default': constants.ATTR_NOT_SPECIFIED, |
| 126 |
'validate': { |
| 127 |
'type:values': constants.IPV6_MODES}, |
| 128 |
'is_filter': True, |
| 129 |
'is_sort_key': True, |
| 130 |
'is_visible': True}, |
| 131 |
constants.SHARED: { |
| 132 |
'allow_post': False, |
| 133 |
'allow_put': False, |
| 134 |
'default': False, |
| 135 |
'convert_to': converters.convert_to_boolean, |
| 136 |
'is_visible': False, |
| 137 |
'is_filter': True, |
| 138 |
'required_by_policy': True, |
| 139 |
'enforce_policy': True |
| 140 |
} |
| 141 |
} |
| 142 |
} |
| 143 |
|
| 144 |
# This is a core resource so the following are not applicable. |
| 145 |
IS_SHIM_EXTENSION = False |
| 146 |
IS_STANDARD_ATTR_EXTENSION = False |
| 147 |
SUB_RESOURCE_ATTRIBUTE_MAP = {} |
| 148 |
ACTION_MAP = {} |
| 149 |
REQUIRED_EXTENSIONS = [] |
| 150 |
OPTIONAL_EXTENSIONS = [] |
| 151 |
ACTION_STATUS = {} |