
The following _MAX_LEN constants are being removed from neutron/api/v2/attributes.py in [1]. The corresponding DB field size constants from neutron_lib.db.constants should be used instead. NAME_MAX_LEN --> NAME_FIELD_SIZE TENANT_ID_MAX_LEN --> PROJECT_ID_FIELD_SIZE DESCRIPTION_MAX_LEN --> DESCRIPTION_FIELD_SIZE LONG_DESCRIPTION_MAX_LEN --> LONG_DESCRIPTION_FIELD_SIZE DEVICE_ID_MAX_LEN --> DEVICE_ID_FIELD_SIZE DEVICE_OWNER_MAX_LEN --> DEVICE_NAME_FIELD_SIZE In alembic migration scripts, the raw numerical value shall be used. For more information, see [2]. [1] https://review.openstack.org/399891 [2] http://lists.openstack.org/pipermail/openstack-dev/2016-October/105789.html Change-Id: I7e53de4ceecfe37edc0cb0041c23ce131f5eeca1
90 lines
2.5 KiB
Python
90 lines
2.5 KiB
Python
# Copyright 2016 VMware, Inc.
|
|
#
|
|
# All Rights Reserved
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
#
|
|
|
|
from neutron_lib.db import constants as db_const
|
|
|
|
from neutron.api import extensions
|
|
|
|
|
|
# The attributes map is here for 2 reasons:
|
|
# 1) allow posting id for the different objects we are importing
|
|
# 2) make sure security-group named 'default' is also copied
|
|
|
|
ID_WITH_POST = {'allow_post': True, 'allow_put': False,
|
|
'validate': {'type:uuid': None},
|
|
'is_visible': True,
|
|
'primary_key': True}
|
|
|
|
RESOURCE_ATTRIBUTE_MAP = {
|
|
'ports': {
|
|
'id': ID_WITH_POST,
|
|
},
|
|
'networks': {
|
|
'id': ID_WITH_POST,
|
|
},
|
|
'security_groups': {
|
|
'id': ID_WITH_POST,
|
|
'name': {'allow_post': True, 'allow_put': True,
|
|
'is_visible': True, 'default': '',
|
|
'validate': {'type:string': db_const.NAME_FIELD_SIZE}},
|
|
},
|
|
'security_group_rules': {
|
|
'id': ID_WITH_POST,
|
|
},
|
|
'routers': {
|
|
'id': ID_WITH_POST,
|
|
},
|
|
'policies': { # QoS policies
|
|
'id': ID_WITH_POST,
|
|
},
|
|
}
|
|
|
|
|
|
class Api_replay(extensions.ExtensionDescriptor):
|
|
"""Extension for api replay which allows us to specify ids of resources."""
|
|
|
|
@classmethod
|
|
def get_name(cls):
|
|
return "Api Replay"
|
|
|
|
@classmethod
|
|
def get_alias(cls):
|
|
return 'api-replay'
|
|
|
|
@classmethod
|
|
def get_description(cls):
|
|
return "Enables mode to allow api to be replayed"
|
|
|
|
@classmethod
|
|
def get_updated(cls):
|
|
return "2016-05-05T10:00:00-00:00"
|
|
|
|
def get_extended_resources(self, version):
|
|
if version == "2.0":
|
|
return RESOURCE_ATTRIBUTE_MAP
|
|
else:
|
|
return {}
|
|
|
|
def get_required_extensions(self):
|
|
# make sure this extension is called after those, so our change
|
|
# will not be overridden
|
|
return ["security-group", "router"]
|
|
|
|
def get_optional_extensions(self):
|
|
# QoS is optional since it is not always enabled
|
|
return ["qos"]
|