| 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 Port' |
| 19 |
ALIAS = 'port' |
| 20 |
DESCRIPTION = "Network port abstraction" |
| 21 |
|
| 22 |
UPDATED_TIMESTAMP = "2012-01-01T10:00:00-00:00" |
| 23 |
|
| 24 |
RESOURCE_NAME = 'port' |
| 25 |
COLLECTION_NAME = 'ports' |
| 26 |
COLLECTION_NAME_BULK = 'ports_bulk' |
| 27 |
|
| 28 |
PORT_MAC_ADDRESS = 'mac_address' |
| 29 |
|
| 30 |
RESOURCE_ATTRIBUTE_MAP = { |
| 31 |
COLLECTION_NAME: { |
| 32 |
'id': {'allow_post': False, 'allow_put': False, |
| 33 |
'validate': {'type:uuid': None}, |
| 34 |
'is_filter': True, |
| 35 |
'is_sort_key': True, |
| 36 |
'is_visible': True, |
| 37 |
'primary_key': True}, |
| 38 |
'name': {'allow_post': True, 'allow_put': True, 'default': '', |
| 39 |
'validate': { |
| 40 |
'type:string': db_const.NAME_FIELD_SIZE}, |
| 41 |
'is_filter': True, |
| 42 |
'is_sort_key': True, |
| 43 |
'is_visible': True}, |
| 44 |
'network_id': {'allow_post': True, 'allow_put': False, |
| 45 |
'required_by_policy': True, |
| 46 |
'validate': {'type:uuid': None}, |
| 47 |
'is_filter': True, |
| 48 |
'is_sort_key': True, |
| 49 |
'is_visible': True}, |
| 50 |
'admin_state_up': {'allow_post': True, 'allow_put': True, |
| 51 |
'default': True, |
| 52 |
'convert_to': converters.convert_to_boolean, |
| 53 |
'is_filter': True, |
| 54 |
'is_sort_key': True, |
| 55 |
'is_visible': True}, |
| 56 |
PORT_MAC_ADDRESS: {'allow_post': True, 'allow_put': True, |
| 57 |
'default': constants.ATTR_NOT_SPECIFIED, |
| 58 |
'convert_to': |
| 59 |
converters.convert_to_sanitized_mac_address, |
| 60 |
'validate': {'type:mac_address': None}, |
| 61 |
'enforce_policy': True, |
| 62 |
'is_filter': True, |
| 63 |
'is_sort_key': True, |
| 64 |
'is_visible': True}, |
| 65 |
'fixed_ips': {'allow_post': True, 'allow_put': True, |
| 66 |
'default': constants.ATTR_NOT_SPECIFIED, |
| 67 |
'convert_list_to': |
| 68 |
converters.convert_kvp_list_to_dict, |
| 69 |
'validate': {'type:fixed_ips': None}, |
| 70 |
'enforce_policy': True, |
| 71 |
'is_filter': True, |
| 72 |
'is_visible': True}, |
| 73 |
'device_id': {'allow_post': True, 'allow_put': True, |
| 74 |
'validate': { |
| 75 |
'type:string': db_const.DEVICE_ID_FIELD_SIZE}, |
| 76 |
'default': '', |
| 77 |
'enforce_policy': True, |
| 78 |
'is_filter': True, |
| 79 |
'is_sort_key': True, |
| 80 |
'is_visible': True}, |
| 81 |
'device_owner': {'allow_post': True, 'allow_put': True, |
| 82 |
'validate': { |
| 83 |
'type:string': db_const.DEVICE_OWNER_FIELD_SIZE}, |
| 84 |
'default': '', 'enforce_policy': True, |
| 85 |
'is_filter': True, |
| 86 |
'is_sort_key': True, |
| 87 |
'is_visible': True}, |
| 88 |
'tenant_id': {'allow_post': True, 'allow_put': False, |
| 89 |
'validate': { |
| 90 |
'type:string': db_const.PROJECT_ID_FIELD_SIZE}, |
| 91 |
'required_by_policy': True, |
| 92 |
'is_filter': True, |
| 93 |
'is_sort_key': True, |
| 94 |
'is_visible': True}, |
| 95 |
'status': {'allow_post': False, 'allow_put': False, |
| 96 |
'is_filter': True, |
| 97 |
'is_sort_key': True, |
| 98 |
'is_visible': True}, |
| 99 |
} |
| 100 |
} |
| 101 |
|
| 102 |
# This is a core resource so the following are not applicable. |
| 103 |
IS_SHIM_EXTENSION = False |
| 104 |
IS_STANDARD_ATTR_EXTENSION = False |
| 105 |
SUB_RESOURCE_ATTRIBUTE_MAP = {} |
| 106 |
ACTION_MAP = {} |
| 107 |
REQUIRED_EXTENSIONS = [] |
| 108 |
OPTIONAL_EXTENSIONS = [] |
| 109 |
ACTION_STATUS = {} |