Use DB field sizes instead of _MAX_LEN constants

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: I038d6d32eefa57c5fc57b870a33d09bef1db296c
This commit is contained in:
Henry Gessau 2016-11-26 00:13:08 -05:00
parent 59d082e988
commit e1bf61996a
2 changed files with 9 additions and 8 deletions

View File

@ -27,7 +27,6 @@ from neutron_lib import constants as lib_consts
from neutron_lib.db import model_base
from neutron_lib import exceptions as n_exc
from neutron.api.v2 import attributes as attr
from neutron.db import common_db_mixin as common_db
from neutron.db import l3_attrs_db
from neutron.db import l3_db
@ -89,7 +88,7 @@ class BgpSpeaker(model_base.BASEV2,
__tablename__ = 'bgp_speakers'
name = sa.Column(sa.String(attr.NAME_MAX_LEN), nullable=False)
name = sa.Column(sa.String(255), nullable=False)
local_as = sa.Column(sa.Integer, nullable=False, autoincrement=False)
advertise_floating_ip_host_routes = sa.Column(sa.Boolean, nullable=False)
advertise_tenant_networks = sa.Column(sa.Boolean, nullable=False)
@ -112,7 +111,7 @@ class BgpPeer(model_base.BASEV2,
__tablename__ = 'bgp_peers'
name = sa.Column(sa.String(attr.NAME_MAX_LEN), nullable=False)
name = sa.Column(sa.String(255), nullable=False)
peer_ip = sa.Column(sa.String(64),
nullable=False)
remote_as = sa.Column(sa.Integer, nullable=False, autoincrement=False)

View File

@ -15,10 +15,10 @@
#
from neutron_lib.api import converters as n_conv
from neutron_lib.db import constants as db_const
from neutron_lib import exceptions as n_exc
from neutron.api import extensions
from neutron.api.v2 import attributes as attr
from neutron.api.v2 import resource_helper as rh
from neutron_dynamic_routing._i18n import _
@ -36,7 +36,7 @@ RESOURCE_ATTRIBUTE_MAP = {
'validate': {'type:uuid': None},
'is_visible': True, 'primary_key': True},
'name': {'allow_post': True, 'allow_put': True,
'validate': {'type:string': attr.NAME_MAX_LEN},
'validate': {'type:string': db_const.NAME_FIELD_SIZE},
'is_visible': True, 'default': ''},
'local_as': {'allow_post': True, 'allow_put': False,
'validate': {'type:range': (bgp_consts.MIN_ASNUM,
@ -51,7 +51,8 @@ RESOURCE_ATTRIBUTE_MAP = {
'enforce_policy': False},
'tenant_id': {'allow_post': True, 'allow_put': False,
'required_by_policy': False,
'validate': {'type:string': attr.TENANT_ID_MAX_LEN},
'validate': {
'type:string': db_const.PROJECT_ID_FIELD_SIZE},
'is_visible': True},
'peers': {'allow_post': False, 'allow_put': False,
'validate': {'type:uuid_list': None},
@ -85,7 +86,7 @@ RESOURCE_ATTRIBUTE_MAP = {
'validate': {'type:uuid': None},
'is_visible': True, 'primary_key': True},
'name': {'allow_post': True, 'allow_put': True,
'validate': {'type:string': attr.NAME_MAX_LEN},
'validate': {'type:string': db_const.NAME_FIELD_SIZE},
'is_visible': True, 'default': ''},
'peer_ip': {'allow_post': True, 'allow_put': False,
'required_by_policy': True,
@ -109,7 +110,8 @@ RESOURCE_ATTRIBUTE_MAP = {
'default': None},
'tenant_id': {'allow_post': True, 'allow_put': False,
'required_by_policy': False,
'validate': {'type:string': attr.TENANT_ID_MAX_LEN},
'validate': {
'type:string': db_const.PROJECT_ID_FIELD_SIZE},
'is_visible': True}
}
}