Use DB field sizes instead of _MAX_LEN constants
Remove The following _MAX_LEN constants from neutron/api/v2/attributes.py and use the corresponding DB field size constants from neutron_lib.db.constants 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 is used. For more information, see: http://lists.openstack.org/pipermail/openstack-dev/2016-October/105789.html NeutronLibImpact Change-Id: I734890372584fe27e5d6ec38c0cad2de882ff11c
This commit is contained in:
parent
07dfea9a02
commit
1c5bf09a03
|
@ -16,6 +16,7 @@
|
|||
from neutron_lib.api import converters as lib_converters
|
||||
from neutron_lib.api import validators as lib_validators
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.db import constants as db_const
|
||||
import six
|
||||
import webob.exc
|
||||
|
||||
|
@ -25,14 +26,6 @@ from neutron._i18n import _
|
|||
# Defining a constant to avoid repeating string literal in several modules
|
||||
SHARED = 'shared'
|
||||
|
||||
# TODO(HenryG): use DB field sizes (neutron-lib 0.1.1)
|
||||
NAME_MAX_LEN = 255
|
||||
TENANT_ID_MAX_LEN = 255
|
||||
DESCRIPTION_MAX_LEN = 255
|
||||
LONG_DESCRIPTION_MAX_LEN = 1024
|
||||
DEVICE_ID_MAX_LEN = 255
|
||||
DEVICE_OWNER_MAX_LEN = 255
|
||||
|
||||
# Define constants for base resource name
|
||||
NETWORK = 'network'
|
||||
NETWORKS = '%ss' % NETWORK
|
||||
|
@ -72,7 +65,7 @@ RESOURCE_ATTRIBUTE_MAP = {
|
|||
'is_visible': True,
|
||||
'primary_key': True},
|
||||
'name': {'allow_post': True, 'allow_put': True,
|
||||
'validate': {'type:string': NAME_MAX_LEN},
|
||||
'validate': {'type:string': db_const.NAME_FIELD_SIZE},
|
||||
'default': '', 'is_visible': True},
|
||||
'subnets': {'allow_post': False, 'allow_put': False,
|
||||
'default': [],
|
||||
|
@ -84,7 +77,8 @@ RESOURCE_ATTRIBUTE_MAP = {
|
|||
'status': {'allow_post': False, 'allow_put': False,
|
||||
'is_visible': True},
|
||||
'tenant_id': {'allow_post': True, 'allow_put': False,
|
||||
'validate': {'type:string': TENANT_ID_MAX_LEN},
|
||||
'validate': {
|
||||
'type:string': db_const.PROJECT_ID_FIELD_SIZE},
|
||||
'required_by_policy': True,
|
||||
'is_visible': True},
|
||||
SHARED: {'allow_post': True,
|
||||
|
@ -101,7 +95,7 @@ RESOURCE_ATTRIBUTE_MAP = {
|
|||
'is_visible': True,
|
||||
'primary_key': True},
|
||||
'name': {'allow_post': True, 'allow_put': True, 'default': '',
|
||||
'validate': {'type:string': NAME_MAX_LEN},
|
||||
'validate': {'type:string': db_const.NAME_FIELD_SIZE},
|
||||
'is_visible': True},
|
||||
'network_id': {'allow_post': True, 'allow_put': False,
|
||||
'required_by_policy': True,
|
||||
|
@ -124,15 +118,18 @@ RESOURCE_ATTRIBUTE_MAP = {
|
|||
'enforce_policy': True,
|
||||
'is_visible': True},
|
||||
'device_id': {'allow_post': True, 'allow_put': True,
|
||||
'validate': {'type:string': DEVICE_ID_MAX_LEN},
|
||||
'validate': {
|
||||
'type:string': db_const.DEVICE_ID_FIELD_SIZE},
|
||||
'default': '',
|
||||
'is_visible': True},
|
||||
'device_owner': {'allow_post': True, 'allow_put': True,
|
||||
'validate': {'type:string': DEVICE_OWNER_MAX_LEN},
|
||||
'validate': {
|
||||
'type:string': db_const.DEVICE_OWNER_FIELD_SIZE},
|
||||
'default': '', 'enforce_policy': True,
|
||||
'is_visible': True},
|
||||
'tenant_id': {'allow_post': True, 'allow_put': False,
|
||||
'validate': {'type:string': TENANT_ID_MAX_LEN},
|
||||
'validate': {
|
||||
'type:string': db_const.PROJECT_ID_FIELD_SIZE},
|
||||
'required_by_policy': True,
|
||||
'is_visible': True},
|
||||
'status': {'allow_post': False, 'allow_put': False,
|
||||
|
@ -144,7 +141,7 @@ RESOURCE_ATTRIBUTE_MAP = {
|
|||
'is_visible': True,
|
||||
'primary_key': True},
|
||||
'name': {'allow_post': True, 'allow_put': True, 'default': '',
|
||||
'validate': {'type:string': NAME_MAX_LEN},
|
||||
'validate': {'type:string': db_const.NAME_FIELD_SIZE},
|
||||
'is_visible': True},
|
||||
'ip_version': {'allow_post': True, 'allow_put': False,
|
||||
'convert_to': lib_converters.convert_to_int,
|
||||
|
@ -194,7 +191,8 @@ RESOURCE_ATTRIBUTE_MAP = {
|
|||
'validate': {'type:hostroutes': None},
|
||||
'is_visible': True},
|
||||
'tenant_id': {'allow_post': True, 'allow_put': False,
|
||||
'validate': {'type:string': TENANT_ID_MAX_LEN},
|
||||
'validate': {
|
||||
'type:string': db_const.PROJECT_ID_FIELD_SIZE},
|
||||
'required_by_policy': True,
|
||||
'is_visible': True},
|
||||
'enable_dhcp': {'allow_post': True, 'allow_put': True,
|
||||
|
@ -230,7 +228,8 @@ RESOURCE_ATTRIBUTE_MAP = {
|
|||
'is_visible': True},
|
||||
'tenant_id': {'allow_post': True,
|
||||
'allow_put': False,
|
||||
'validate': {'type:string': TENANT_ID_MAX_LEN},
|
||||
'validate': {
|
||||
'type:string': db_const.PROJECT_ID_FIELD_SIZE},
|
||||
'required_by_policy': True,
|
||||
'is_visible': True},
|
||||
'prefixes': {'allow_post': True,
|
||||
|
|
|
@ -28,17 +28,15 @@ down_revision = '1b4c6e320f79'
|
|||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.api.v2 import attributes as attrs
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.create_table(
|
||||
'qos_policies',
|
||||
sa.Column('id', sa.String(length=36), primary_key=True),
|
||||
sa.Column('name', sa.String(length=attrs.NAME_MAX_LEN)),
|
||||
sa.Column('description', sa.String(length=attrs.DESCRIPTION_MAX_LEN)),
|
||||
sa.Column('name', sa.String(length=255)),
|
||||
sa.Column('description', sa.String(length=255)),
|
||||
sa.Column('shared', sa.Boolean(), nullable=False),
|
||||
sa.Column('tenant_id', sa.String(length=attrs.TENANT_ID_MAX_LEN),
|
||||
sa.Column('tenant_id', sa.String(length=255),
|
||||
index=True))
|
||||
|
||||
op.create_table(
|
||||
|
|
|
@ -30,26 +30,24 @@ from alembic import op
|
|||
from oslo_utils import uuidutils
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.api.v2 import attributes
|
||||
|
||||
|
||||
# A simple model of the external network table with only the fields needed for
|
||||
# the migration.
|
||||
external = sa.Table('externalnetworks', sa.MetaData(),
|
||||
sa.Column('network_id', sa.String(length=36),
|
||||
nullable=False))
|
||||
TENANT_ID_MAX_LEN = attributes.TENANT_ID_MAX_LEN
|
||||
|
||||
network = sa.Table('networks', sa.MetaData(),
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('tenant_id', sa.String(length=TENANT_ID_MAX_LEN)))
|
||||
sa.Column('tenant_id', sa.String(length=255)))
|
||||
|
||||
networkrbacs = sa.Table(
|
||||
'networkrbacs', sa.MetaData(),
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('object_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('tenant_id', sa.String(length=TENANT_ID_MAX_LEN), nullable=True,
|
||||
sa.Column('tenant_id', sa.String(length=255), nullable=True,
|
||||
index=True),
|
||||
sa.Column('target_tenant', sa.String(length=TENANT_ID_MAX_LEN),
|
||||
sa.Column('target_tenant', sa.String(length=255),
|
||||
nullable=False),
|
||||
sa.Column('action', sa.String(length=255), nullable=False))
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ from alembic import op
|
|||
from oslo_utils import uuidutils
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.api.v2 import attributes as attrs
|
||||
from neutron.db import rbac_db_models
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
|
@ -37,9 +36,9 @@ depends_on = ('15e43b934f81',)
|
|||
qos_rbacs = sa.Table(
|
||||
'qospolicyrbacs', sa.MetaData(),
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('tenant_id', sa.String(length=attrs.TENANT_ID_MAX_LEN),
|
||||
sa.Column('tenant_id', sa.String(length=255),
|
||||
nullable=True),
|
||||
sa.Column('target_tenant', sa.String(length=attrs.TENANT_ID_MAX_LEN),
|
||||
sa.Column('target_tenant', sa.String(length=255),
|
||||
nullable=False),
|
||||
sa.Column('action', sa.String(length=255), nullable=False),
|
||||
sa.Column('object_id', sa.String(length=36), nullable=False))
|
||||
|
@ -49,7 +48,7 @@ qos_rbacs = sa.Table(
|
|||
qos_policy = sa.Table('qos_policies', sa.MetaData(),
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('tenant_id',
|
||||
sa.String(length=attrs.TENANT_ID_MAX_LEN)),
|
||||
sa.String(length=255)),
|
||||
sa.Column('shared', sa.Boolean(), nullable=False))
|
||||
|
||||
|
||||
|
|
|
@ -24,8 +24,6 @@ Create Date: 2015-11-25 18:45:03.819115
|
|||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.api.v2 import attributes as attrs
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '15e43b934f81'
|
||||
down_revision = 'b4caf27aae4'
|
||||
|
@ -35,10 +33,10 @@ def upgrade():
|
|||
op.create_table('qospolicyrbacs',
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('tenant_id',
|
||||
sa.String(length=attrs.TENANT_ID_MAX_LEN),
|
||||
sa.String(length=255),
|
||||
nullable=True),
|
||||
sa.Column('target_tenant',
|
||||
sa.String(length=attrs.TENANT_ID_MAX_LEN),
|
||||
sa.String(length=255),
|
||||
nullable=False),
|
||||
sa.Column('action', sa.String(length=255), nullable=False),
|
||||
sa.Column('object_id', sa.String(length=36),
|
||||
|
|
|
@ -10,17 +10,16 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.db import constants as db_const
|
||||
from neutron_lib.db import model_base
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.api.v2 import attributes as attr
|
||||
|
||||
|
||||
class AddressScope(model_base.BASEV2, model_base.HasId, model_base.HasProject):
|
||||
"""Represents a neutron address scope."""
|
||||
|
||||
__tablename__ = "address_scopes"
|
||||
|
||||
name = sa.Column(sa.String(attr.NAME_MAX_LEN), nullable=False)
|
||||
name = sa.Column(sa.String(db_const.NAME_FIELD_SIZE), nullable=False)
|
||||
shared = sa.Column(sa.Boolean, nullable=False)
|
||||
ip_version = sa.Column(sa.Integer(), nullable=False)
|
||||
|
|
|
@ -10,12 +10,12 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.db import constants as db_const
|
||||
from neutron_lib.db import model_base
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import sql
|
||||
|
||||
from neutron.agent.common import utils
|
||||
from neutron.api.v2 import attributes
|
||||
|
||||
|
||||
class Agent(model_base.BASEV2, model_base.HasId):
|
||||
|
@ -44,7 +44,7 @@ class Agent(model_base.BASEV2, model_base.HasId):
|
|||
# updated when agents report
|
||||
heartbeat_timestamp = sa.Column(sa.DateTime, nullable=False)
|
||||
# description is note for admin user
|
||||
description = sa.Column(sa.String(attributes.DESCRIPTION_MAX_LEN))
|
||||
description = sa.Column(sa.String(db_const.DESCRIPTION_FIELD_SIZE))
|
||||
# configurations: a json dict string, I think 4095 is enough
|
||||
configurations = sa.Column(sa.String(4095), nullable=False)
|
||||
# resource_versions: json dict, 8191 allows for ~256 resource versions
|
||||
|
|
|
@ -10,16 +10,15 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.db import constants as db_const
|
||||
from neutron_lib.db import model_base
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import orm
|
||||
|
||||
from neutron.api.v2 import attributes as attr
|
||||
|
||||
|
||||
class Flavor(model_base.BASEV2, model_base.HasId):
|
||||
name = sa.Column(sa.String(attr.NAME_MAX_LEN))
|
||||
description = sa.Column(sa.String(attr.LONG_DESCRIPTION_MAX_LEN))
|
||||
name = sa.Column(sa.String(db_const.NAME_FIELD_SIZE))
|
||||
description = sa.Column(sa.String(db_const.LONG_DESCRIPTION_FIELD_SIZE))
|
||||
enabled = sa.Column(sa.Boolean, nullable=False, default=True,
|
||||
server_default=sa.sql.true())
|
||||
# Make it True for multi-type flavors
|
||||
|
@ -29,7 +28,7 @@ class Flavor(model_base.BASEV2, model_base.HasId):
|
|||
|
||||
|
||||
class ServiceProfile(model_base.BASEV2, model_base.HasId):
|
||||
description = sa.Column(sa.String(attr.LONG_DESCRIPTION_MAX_LEN))
|
||||
description = sa.Column(sa.String(db_const.LONG_DESCRIPTION_FIELD_SIZE))
|
||||
driver = sa.Column(sa.String(1024), nullable=False)
|
||||
enabled = sa.Column(sa.Boolean, nullable=False, default=True,
|
||||
server_default=sa.sql.true())
|
||||
|
|
|
@ -10,11 +10,11 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.db import constants as db_const
|
||||
from neutron_lib.db import model_base
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import orm
|
||||
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron.db.models import l3agent as rb_model
|
||||
from neutron.db import models_v2
|
||||
from neutron.db import standard_attr
|
||||
|
@ -37,7 +37,7 @@ class RouterPort(model_base.BASEV2):
|
|||
# queries on router ports, and also prevents potential error-prone
|
||||
# conditions which might originate from users altering the DEVICE_OWNER
|
||||
# property of router ports.
|
||||
port_type = sa.Column(sa.String(attributes.DEVICE_OWNER_MAX_LEN))
|
||||
port_type = sa.Column(sa.String(db_const.DEVICE_OWNER_FIELD_SIZE))
|
||||
port = orm.relationship(
|
||||
models_v2.Port,
|
||||
backref=orm.backref('routerport', uselist=False, cascade="all,delete"),
|
||||
|
@ -48,7 +48,7 @@ class Router(standard_attr.HasStandardAttributes, model_base.BASEV2,
|
|||
model_base.HasId, model_base.HasProject):
|
||||
"""Represents a v2 neutron router."""
|
||||
|
||||
name = sa.Column(sa.String(attributes.NAME_MAX_LEN))
|
||||
name = sa.Column(sa.String(db_const.NAME_FIELD_SIZE))
|
||||
status = sa.Column(sa.String(16))
|
||||
admin_state_up = sa.Column(sa.Boolean)
|
||||
gw_port_id = sa.Column(sa.String(36), sa.ForeignKey('ports.id'))
|
||||
|
|
|
@ -10,13 +10,12 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
from neutron_lib.db import constants as db_const
|
||||
from neutron_lib.db import model_base
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import orm
|
||||
from sqlalchemy import sql
|
||||
|
||||
from neutron.api.v2 import attributes as attr
|
||||
from neutron.db.models import l3 as l3_models
|
||||
|
||||
|
||||
|
@ -34,8 +33,8 @@ class MeteringLabelRule(model_base.BASEV2, model_base.HasId):
|
|||
class MeteringLabel(model_base.BASEV2,
|
||||
model_base.HasId,
|
||||
model_base.HasProject):
|
||||
name = sa.Column(sa.String(attr.NAME_MAX_LEN))
|
||||
description = sa.Column(sa.String(attr.LONG_DESCRIPTION_MAX_LEN))
|
||||
name = sa.Column(sa.String(db_const.NAME_FIELD_SIZE))
|
||||
description = sa.Column(sa.String(db_const.LONG_DESCRIPTION_FIELD_SIZE))
|
||||
rules = orm.relationship(MeteringLabelRule, backref="label",
|
||||
cascade="delete", lazy="joined")
|
||||
routers = orm.relationship(
|
||||
|
|
|
@ -12,11 +12,11 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.db import constants as db_const
|
||||
from neutron_lib.db import model_base
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import orm
|
||||
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron.db import models_v2
|
||||
from neutron.db import standard_attr
|
||||
from neutron.extensions import securitygroup as sg
|
||||
|
@ -26,7 +26,7 @@ class SecurityGroup(standard_attr.HasStandardAttributes, model_base.BASEV2,
|
|||
model_base.HasId, model_base.HasProject):
|
||||
"""Represents a v2 neutron security group."""
|
||||
|
||||
name = sa.Column(sa.String(attributes.NAME_MAX_LEN))
|
||||
name = sa.Column(sa.String(db_const.NAME_FIELD_SIZE))
|
||||
api_collections = [sg.SECURITYGROUPS]
|
||||
|
||||
|
||||
|
|
|
@ -14,12 +14,11 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
from neutron_lib.db import constants as db_const
|
||||
from neutron_lib.db import model_base
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import orm
|
||||
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron.db import models_v2
|
||||
from neutron.db import standard_attr
|
||||
from neutron.extensions import segment
|
||||
|
@ -46,7 +45,7 @@ class NetworkSegment(standard_attr.HasStandardAttributes,
|
|||
is_dynamic = sa.Column(sa.Boolean, default=False, nullable=False,
|
||||
server_default=sa.sql.false())
|
||||
segment_index = sa.Column(sa.Integer, nullable=False, server_default='0')
|
||||
name = sa.Column(sa.String(attributes.NAME_MAX_LEN),
|
||||
name = sa.Column(sa.String(db_const.NAME_FIELD_SIZE),
|
||||
nullable=True)
|
||||
network = orm.relationship(models_v2.Network,
|
||||
backref=orm.backref("segments",
|
||||
|
|
|
@ -13,14 +13,13 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.db import constants as db_const
|
||||
from neutron_lib.db import model_base
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.api.v2 import attributes as attr
|
||||
|
||||
|
||||
class ProviderResourceAssociation(model_base.BASEV2):
|
||||
provider_name = sa.Column(sa.String(attr.NAME_MAX_LEN),
|
||||
provider_name = sa.Column(sa.String(db_const.NAME_FIELD_SIZE),
|
||||
nullable=False, primary_key=True)
|
||||
# should be manually deleted on resource deletion
|
||||
resource_id = sa.Column(sa.String(36), nullable=False, primary_key=True,
|
||||
|
|
|
@ -13,11 +13,11 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.db import constants as db_const
|
||||
from neutron_lib.db import model_base
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import orm
|
||||
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron.db import models_v2
|
||||
|
||||
|
||||
|
@ -30,7 +30,7 @@ class SubnetServiceType(model_base.BASEV2):
|
|||
sa.ForeignKey('subnets.id', ondelete="CASCADE"))
|
||||
# Service types must be valid device owners, therefore share max length
|
||||
service_type = sa.Column(sa.String(
|
||||
length=attributes.DEVICE_OWNER_MAX_LEN))
|
||||
length=db_const.DEVICE_OWNER_FIELD_SIZE))
|
||||
subnet = orm.relationship(models_v2.Subnet,
|
||||
backref=orm.backref('service_types',
|
||||
lazy='joined',
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
# under the License.
|
||||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.db import constants as db_const
|
||||
from neutron_lib.db import model_base
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import orm
|
||||
|
@ -74,7 +75,7 @@ class Port(standard_attr.HasStandardAttributes, model_base.BASEV2,
|
|||
model_base.HasId, model_base.HasProject):
|
||||
"""Represents a port on a Neutron v2 network."""
|
||||
|
||||
name = sa.Column(sa.String(attr.NAME_MAX_LEN))
|
||||
name = sa.Column(sa.String(db_const.NAME_FIELD_SIZE))
|
||||
network_id = sa.Column(sa.String(36), sa.ForeignKey("networks.id"),
|
||||
nullable=False)
|
||||
fixed_ips = orm.relationship(IPAllocation, backref='port', lazy='joined',
|
||||
|
@ -85,8 +86,9 @@ class Port(standard_attr.HasStandardAttributes, model_base.BASEV2,
|
|||
mac_address = sa.Column(sa.String(32), nullable=False)
|
||||
admin_state_up = sa.Column(sa.Boolean(), nullable=False)
|
||||
status = sa.Column(sa.String(16), nullable=False)
|
||||
device_id = sa.Column(sa.String(attr.DEVICE_ID_MAX_LEN), nullable=False)
|
||||
device_owner = sa.Column(sa.String(attr.DEVICE_OWNER_MAX_LEN),
|
||||
device_id = sa.Column(sa.String(db_const.DEVICE_ID_FIELD_SIZE),
|
||||
nullable=False)
|
||||
device_owner = sa.Column(sa.String(db_const.DEVICE_OWNER_FIELD_SIZE),
|
||||
nullable=False)
|
||||
ip_allocation = sa.Column(sa.String(16))
|
||||
|
||||
|
@ -143,7 +145,7 @@ class Subnet(standard_attr.HasStandardAttributes, model_base.BASEV2,
|
|||
are used for the IP allocation.
|
||||
"""
|
||||
|
||||
name = sa.Column(sa.String(attr.NAME_MAX_LEN))
|
||||
name = sa.Column(sa.String(db_const.NAME_FIELD_SIZE))
|
||||
network_id = sa.Column(sa.String(36), sa.ForeignKey('networks.id'))
|
||||
# Added by the segments service plugin
|
||||
segment_id = sa.Column(sa.String(36), sa.ForeignKey('networksegments.id'))
|
||||
|
@ -211,7 +213,7 @@ class SubnetPool(standard_attr.HasStandardAttributes, model_base.BASEV2,
|
|||
"""Represents a neutron subnet pool.
|
||||
"""
|
||||
|
||||
name = sa.Column(sa.String(attr.NAME_MAX_LEN))
|
||||
name = sa.Column(sa.String(db_const.NAME_FIELD_SIZE))
|
||||
ip_version = sa.Column(sa.Integer, nullable=False)
|
||||
default_prefixlen = sa.Column(sa.Integer, nullable=False)
|
||||
min_prefixlen = sa.Column(sa.Integer, nullable=False)
|
||||
|
@ -233,7 +235,7 @@ class Network(standard_attr.HasStandardAttributes, model_base.BASEV2,
|
|||
model_base.HasId, model_base.HasProject):
|
||||
"""Represents a v2 neutron network."""
|
||||
|
||||
name = sa.Column(sa.String(attr.NAME_MAX_LEN))
|
||||
name = sa.Column(sa.String(db_const.NAME_FIELD_SIZE))
|
||||
ports = orm.relationship(Port, backref='networks')
|
||||
subnets = orm.relationship(
|
||||
Subnet, backref=orm.backref('networks', lazy='subquery'),
|
||||
|
|
|
@ -13,10 +13,10 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.db import constants as db_const
|
||||
from neutron_lib.db import model_base
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.api.v2 import attributes as attrs
|
||||
from neutron.common import constants
|
||||
from neutron.db import models_v2
|
||||
from neutron.db import rbac_db_models
|
||||
|
@ -26,7 +26,7 @@ from neutron.db import standard_attr
|
|||
class QosPolicy(standard_attr.HasStandardAttributes, model_base.BASEV2,
|
||||
model_base.HasId, model_base.HasProject):
|
||||
__tablename__ = 'qos_policies'
|
||||
name = sa.Column(sa.String(attrs.NAME_MAX_LEN))
|
||||
name = sa.Column(sa.String(db_const.NAME_FIELD_SIZE))
|
||||
rbac_entries = sa.orm.relationship(rbac_db_models.QosPolicyRBAC,
|
||||
backref='qos_policy', lazy='joined',
|
||||
cascade='all, delete, delete-orphan')
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
import abc
|
||||
|
||||
from neutron_lib.db import constants as db_const
|
||||
from neutron_lib.db import model_base
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
|
@ -23,7 +24,6 @@ from sqlalchemy.ext import declarative
|
|||
from sqlalchemy.orm import validates
|
||||
|
||||
from neutron._i18n import _
|
||||
from neutron.api.v2 import attributes as attr
|
||||
|
||||
|
||||
ACCESS_SHARED = 'access_as_shared'
|
||||
|
@ -46,7 +46,7 @@ class RBACColumns(model_base.HasId, model_base.HasProject):
|
|||
# the target_tenant is the subject that the policy will affect. this may
|
||||
# also be a wildcard '*' to indicate all tenants or it may be a role if
|
||||
# neutron gets better integration with keystone
|
||||
target_tenant = sa.Column(sa.String(attr.TENANT_ID_MAX_LEN),
|
||||
target_tenant = sa.Column(sa.String(db_const.PROJECT_ID_FIELD_SIZE),
|
||||
nullable=False)
|
||||
|
||||
action = sa.Column(sa.String(255), nullable=False)
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
# 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_lib.db import model_base
|
||||
from oslo_utils import timeutils
|
||||
import sqlalchemy as sa
|
||||
|
@ -19,7 +20,6 @@ from sqlalchemy.ext.associationproxy import association_proxy
|
|||
from sqlalchemy.ext import declarative
|
||||
|
||||
from neutron._i18n import _LE
|
||||
from neutron.api.v2 import attributes as attr
|
||||
from neutron.db import sqlalchemytypes
|
||||
|
||||
|
||||
|
@ -51,7 +51,7 @@ class StandardAttribute(model_base.BASEV2):
|
|||
# before a 2-byte prefix is required. We shouldn't get anywhere near this
|
||||
# limit with our table names...
|
||||
resource_type = sa.Column(sa.String(255), nullable=False)
|
||||
description = sa.Column(sa.String(attr.DESCRIPTION_MAX_LEN))
|
||||
description = sa.Column(sa.String(db_const.DESCRIPTION_FIELD_SIZE))
|
||||
|
||||
revision_number = sa.Column(
|
||||
sa.BigInteger().with_variant(sa.Integer(), 'sqlite'),
|
||||
|
|
|
@ -17,6 +17,7 @@ import abc
|
|||
from neutron_lib.api import converters
|
||||
from neutron_lib.api import extensions as api_extensions
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.db import constants as db_const
|
||||
from neutron_lib import exceptions as nexception
|
||||
from neutron_lib.plugins import directory
|
||||
import six
|
||||
|
@ -43,11 +44,12 @@ RESOURCE_ATTRIBUTE_MAP = {
|
|||
'name': {'allow_post': True,
|
||||
'allow_put': True,
|
||||
'default': '',
|
||||
'validate': {'type:string': attr.NAME_MAX_LEN},
|
||||
'validate': {'type:string': db_const.NAME_FIELD_SIZE},
|
||||
'is_visible': True},
|
||||
'tenant_id': {'allow_post': True,
|
||||
'allow_put': False,
|
||||
'validate': {'type:string': attr.TENANT_ID_MAX_LEN},
|
||||
'validate': {
|
||||
'type:string': db_const.PROJECT_ID_FIELD_SIZE},
|
||||
'required_by_policy': True,
|
||||
'is_visible': True},
|
||||
attr.SHARED: {'allow_post': True,
|
||||
|
|
|
@ -17,13 +17,13 @@ import abc
|
|||
|
||||
from neutron_lib.api import converters
|
||||
from neutron_lib.api import extensions as api_extensions
|
||||
from neutron_lib.db import constants as db_const
|
||||
from neutron_lib import exceptions
|
||||
from neutron_lib.plugins import directory
|
||||
import six
|
||||
|
||||
from neutron._i18n import _
|
||||
from neutron.api import extensions
|
||||
from neutron.api.v2 import attributes as attr
|
||||
from neutron.api.v2 import base
|
||||
|
||||
|
||||
|
@ -55,10 +55,11 @@ RESOURCE_ATTRIBUTE_MAP = {
|
|||
'is_visible': True},
|
||||
'configurations': {'allow_post': False, 'allow_put': False,
|
||||
'is_visible': True},
|
||||
'description': {'allow_post': False, 'allow_put': True,
|
||||
'is_visible': True,
|
||||
'validate': {
|
||||
'type:string_or_none': attr.DESCRIPTION_MAX_LEN}},
|
||||
'description': {
|
||||
'allow_post': False, 'allow_put': True,
|
||||
'is_visible': True,
|
||||
'validate': {
|
||||
'type:string_or_none': db_const.DESCRIPTION_FIELD_SIZE}},
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -15,12 +15,12 @@
|
|||
from neutron_lib.api import converters
|
||||
from neutron_lib.api import extensions as api_extensions
|
||||
from neutron_lib.api import validators
|
||||
from neutron_lib.db import constants as db_const
|
||||
from neutron_lib import exceptions as nexception
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
from neutron._i18n import _
|
||||
from neutron.api import extensions
|
||||
from neutron.api.v2 import attributes as attr
|
||||
from neutron.api.v2 import base
|
||||
from neutron.api.v2 import resource_helper
|
||||
from neutron.plugins.common import constants
|
||||
|
@ -92,11 +92,11 @@ RESOURCE_ATTRIBUTE_MAP = {
|
|||
'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': ''},
|
||||
'description': {'allow_post': True, 'allow_put': True,
|
||||
'validate': {'type:string_or_none':
|
||||
attr.LONG_DESCRIPTION_MAX_LEN},
|
||||
db_const.LONG_DESCRIPTION_FIELD_SIZE},
|
||||
'is_visible': True, 'default': ''},
|
||||
'service_type': {'allow_post': True, 'allow_put': False,
|
||||
'validate':
|
||||
|
@ -104,7 +104,8 @@ RESOURCE_ATTRIBUTE_MAP = {
|
|||
'is_visible': True},
|
||||
'tenant_id': {'allow_post': True, 'allow_put': False,
|
||||
'required_by_policy': True,
|
||||
'validate': {'type:string': attr.TENANT_ID_MAX_LEN},
|
||||
'validate': {
|
||||
'type:string': db_const.PROJECT_ID_FIELD_SIZE},
|
||||
'is_visible': True},
|
||||
'service_profiles': {'allow_post': True, 'allow_put': True,
|
||||
'validate': {'type:uuid_list': None},
|
||||
|
@ -121,11 +122,11 @@ RESOURCE_ATTRIBUTE_MAP = {
|
|||
'primary_key': True},
|
||||
'description': {'allow_post': True, 'allow_put': True,
|
||||
'validate': {'type:string_or_none':
|
||||
attr.LONG_DESCRIPTION_MAX_LEN},
|
||||
db_const.LONG_DESCRIPTION_FIELD_SIZE},
|
||||
'is_visible': True, 'default': ''},
|
||||
'driver': {'allow_post': True, 'allow_put': True,
|
||||
'validate': {'type:string':
|
||||
attr.LONG_DESCRIPTION_MAX_LEN},
|
||||
db_const.LONG_DESCRIPTION_FIELD_SIZE},
|
||||
'is_visible': True,
|
||||
'default': ''},
|
||||
'metainfo': {'allow_post': True, 'allow_put': True,
|
||||
|
@ -133,7 +134,8 @@ RESOURCE_ATTRIBUTE_MAP = {
|
|||
'default': ''},
|
||||
'tenant_id': {'allow_post': True, 'allow_put': False,
|
||||
'required_by_policy': True,
|
||||
'validate': {'type:string': attr.TENANT_ID_MAX_LEN},
|
||||
'validate': {
|
||||
'type:string': db_const.PROJECT_ID_FIELD_SIZE},
|
||||
'is_visible': True},
|
||||
'enabled': {'allow_post': True, 'allow_put': True,
|
||||
'convert_to': converters.convert_to_boolean_if_not_none,
|
||||
|
@ -157,8 +159,9 @@ SUB_RESOURCE_ATTRIBUTE_MAP = {
|
|||
'is_visible': True},
|
||||
'tenant_id': {'allow_post': True, 'allow_put': False,
|
||||
'required_by_policy': True,
|
||||
'validate': {'type:string':
|
||||
attr.TENANT_ID_MAX_LEN},
|
||||
'validate': {
|
||||
'type:string':
|
||||
db_const.PROJECT_ID_FIELD_SIZE},
|
||||
'is_visible': True}}
|
||||
},
|
||||
'service_profiles': {
|
||||
|
@ -169,8 +172,9 @@ SUB_RESOURCE_ATTRIBUTE_MAP = {
|
|||
'is_visible': True},
|
||||
'tenant_id': {'allow_post': True, 'allow_put': False,
|
||||
'required_by_policy': True,
|
||||
'validate': {'type:string':
|
||||
attr.TENANT_ID_MAX_LEN},
|
||||
'validate': {
|
||||
'type:string':
|
||||
db_const.PROJECT_ID_FIELD_SIZE},
|
||||
'is_visible': True}}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,11 +17,11 @@ import abc
|
|||
|
||||
from neutron_lib.api import converters
|
||||
from neutron_lib.api import extensions
|
||||
from neutron_lib.db import constants as db_const
|
||||
from neutron_lib import exceptions as nexception
|
||||
import six
|
||||
|
||||
from neutron._i18n import _
|
||||
from neutron.api.v2 import attributes as attr
|
||||
from neutron.api.v2 import resource_helper
|
||||
from neutron.conf import quota
|
||||
from neutron.plugins.common import constants
|
||||
|
@ -96,7 +96,7 @@ RESOURCE_ATTRIBUTE_MAP = {
|
|||
'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': ''},
|
||||
'admin_state_up': {'allow_post': True, 'allow_put': True,
|
||||
'default': True,
|
||||
|
@ -106,7 +106,8 @@ RESOURCE_ATTRIBUTE_MAP = {
|
|||
'is_visible': True},
|
||||
'tenant_id': {'allow_post': True, 'allow_put': False,
|
||||
'required_by_policy': True,
|
||||
'validate': {'type:string': attr.TENANT_ID_MAX_LEN},
|
||||
'validate': {
|
||||
'type:string': db_const.PROJECT_ID_FIELD_SIZE},
|
||||
'is_visible': True},
|
||||
EXTERNAL_GW_INFO: {'allow_post': True, 'allow_put': True,
|
||||
'is_visible': True, 'default': None,
|
||||
|
@ -153,7 +154,8 @@ RESOURCE_ATTRIBUTE_MAP = {
|
|||
'is_visible': True, 'default': None},
|
||||
'tenant_id': {'allow_post': True, 'allow_put': False,
|
||||
'required_by_policy': True,
|
||||
'validate': {'type:string': attr.TENANT_ID_MAX_LEN},
|
||||
'validate': {
|
||||
'type:string': db_const.PROJECT_ID_FIELD_SIZE},
|
||||
'is_visible': True},
|
||||
'status': {'allow_post': False, 'allow_put': False,
|
||||
'is_visible': True},
|
||||
|
|
|
@ -16,11 +16,11 @@ import abc
|
|||
|
||||
from neutron_lib.api import converters
|
||||
from neutron_lib.api import extensions
|
||||
from neutron_lib.db import constants as db_const
|
||||
from neutron_lib import exceptions as nexception
|
||||
import six
|
||||
|
||||
from neutron._i18n import _
|
||||
from neutron.api.v2 import attributes as attr
|
||||
from neutron.api.v2 import resource_helper
|
||||
from neutron.plugins.common import constants
|
||||
from neutron.services import service_base
|
||||
|
@ -49,15 +49,17 @@ RESOURCE_ATTRIBUTE_MAP = {
|
|||
'is_visible': True,
|
||||
'primary_key': True},
|
||||
'name': {'allow_post': True, 'allow_put': False,
|
||||
'validate': {'type:string': attr.NAME_MAX_LEN},
|
||||
'validate': {'type:string': db_const.NAME_FIELD_SIZE},
|
||||
'is_visible': True, 'default': ''},
|
||||
'description': {'allow_post': True, 'allow_put': False,
|
||||
'validate': {
|
||||
'type:string': attr.LONG_DESCRIPTION_MAX_LEN},
|
||||
'type:string':
|
||||
db_const.LONG_DESCRIPTION_FIELD_SIZE},
|
||||
'is_visible': True, 'default': ''},
|
||||
'tenant_id': {'allow_post': True, 'allow_put': False,
|
||||
'required_by_policy': True,
|
||||
'validate': {'type:string': attr.TENANT_ID_MAX_LEN},
|
||||
'validate': {
|
||||
'type:string': db_const.PROJECT_ID_FIELD_SIZE},
|
||||
'is_visible': True},
|
||||
'shared': {'allow_post': True, 'allow_put': False,
|
||||
'is_visible': True, 'default': False,
|
||||
|
@ -81,7 +83,8 @@ RESOURCE_ATTRIBUTE_MAP = {
|
|||
'validate': {'type:subnet': None}},
|
||||
'tenant_id': {'allow_post': True, 'allow_put': False,
|
||||
'required_by_policy': True,
|
||||
'validate': {'type:string': attr.TENANT_ID_MAX_LEN},
|
||||
'validate': {
|
||||
'type:string': db_const.PROJECT_ID_FIELD_SIZE},
|
||||
'is_visible': True}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,11 +19,11 @@ import re
|
|||
|
||||
from neutron_lib.api import converters
|
||||
from neutron_lib.api import extensions as api_extensions
|
||||
from neutron_lib.db import constants as db_const
|
||||
from neutron_lib.plugins import directory
|
||||
import six
|
||||
|
||||
from neutron.api import extensions
|
||||
from neutron.api.v2 import attributes as attr
|
||||
from neutron.api.v2 import base
|
||||
from neutron.api.v2 import resource_helper
|
||||
from neutron.common import constants as common_constants
|
||||
|
@ -52,17 +52,19 @@ RESOURCE_ATTRIBUTE_MAP = {
|
|||
'is_visible': True, 'primary_key': True},
|
||||
'name': {'allow_post': True, 'allow_put': True,
|
||||
'is_visible': True, 'default': '',
|
||||
'validate': {'type:string': attr.NAME_MAX_LEN}},
|
||||
'validate': {'type:string': db_const.NAME_FIELD_SIZE}},
|
||||
'description': {'allow_post': True, 'allow_put': True,
|
||||
'is_visible': True, 'default': '',
|
||||
'validate':
|
||||
{'type:string': attr.LONG_DESCRIPTION_MAX_LEN}},
|
||||
{'type:string':
|
||||
db_const.LONG_DESCRIPTION_FIELD_SIZE}},
|
||||
'shared': {'allow_post': True, 'allow_put': True,
|
||||
'is_visible': True, 'default': False,
|
||||
'convert_to': converters.convert_to_boolean},
|
||||
'tenant_id': {'allow_post': True, 'allow_put': False,
|
||||
'required_by_policy': True,
|
||||
'validate': {'type:string': attr.TENANT_ID_MAX_LEN},
|
||||
'validate': {
|
||||
'type:string': db_const.PROJECT_ID_FIELD_SIZE},
|
||||
'is_visible': True},
|
||||
'rules': {'allow_post': False, 'allow_put': False, 'is_visible': True},
|
||||
},
|
||||
|
|
|
@ -14,12 +14,12 @@
|
|||
# under the License.
|
||||
|
||||
from neutron_lib.api import extensions as api_extensions
|
||||
from neutron_lib.db import constants as db_const
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
from neutron._i18n import _
|
||||
from neutron.api import extensions
|
||||
from neutron.api.v2 import attributes as attr
|
||||
from neutron.api.v2 import base
|
||||
from neutron.conf import quota
|
||||
from neutron.db import rbac_db_models
|
||||
|
@ -63,15 +63,18 @@ RESOURCE_ATTRIBUTE_MAP = {
|
|||
'validate': {'type:uuid': None},
|
||||
'is_visible': True, 'enforce_policy': True},
|
||||
'target_tenant': {'allow_post': True, 'allow_put': True,
|
||||
'validate': {'type:string': attr.TENANT_ID_MAX_LEN},
|
||||
'validate': {
|
||||
'type:string': db_const.PROJECT_ID_FIELD_SIZE},
|
||||
'is_visible': True, 'enforce_policy': True},
|
||||
'tenant_id': {'allow_post': True, 'allow_put': False,
|
||||
'validate': {'type:string': attr.TENANT_ID_MAX_LEN},
|
||||
'validate': {
|
||||
'type:string': db_const.PROJECT_ID_FIELD_SIZE},
|
||||
'required_by_policy': True, 'is_visible': True},
|
||||
'action': {'allow_post': True, 'allow_put': False,
|
||||
# action depends on type so validation has to occur in
|
||||
# the extension
|
||||
'validate': {'type:string': attr.DESCRIPTION_MAX_LEN},
|
||||
'validate': {
|
||||
'type:string': db_const.DESCRIPTION_FIELD_SIZE},
|
||||
# we set enforce_policy so operators can define policies
|
||||
# that restrict actions
|
||||
'is_visible': True, 'enforce_policy': True}
|
||||
|
|
|
@ -19,6 +19,7 @@ import netaddr
|
|||
from neutron_lib.api import extensions as api_extensions
|
||||
from neutron_lib.api import validators
|
||||
from neutron_lib import constants as const
|
||||
from neutron_lib.db import constants as db_const
|
||||
from neutron_lib import exceptions as nexception
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_utils import netutils
|
||||
|
@ -27,7 +28,6 @@ import six
|
|||
|
||||
from neutron._i18n import _
|
||||
from neutron.api import extensions
|
||||
from neutron.api.v2 import attributes as attr
|
||||
from neutron.api.v2 import base
|
||||
from neutron.common import exceptions
|
||||
from neutron.conf import quota
|
||||
|
@ -224,13 +224,16 @@ RESOURCE_ATTRIBUTE_MAP = {
|
|||
'primary_key': True},
|
||||
'name': {'allow_post': True, 'allow_put': True,
|
||||
'is_visible': True, 'default': '',
|
||||
'validate': {'type:name_not_default': attr.NAME_MAX_LEN}},
|
||||
'validate': {
|
||||
'type:name_not_default': db_const.NAME_FIELD_SIZE}},
|
||||
'description': {'allow_post': True, 'allow_put': True,
|
||||
'validate': {'type:string': attr.DESCRIPTION_MAX_LEN},
|
||||
'validate': {
|
||||
'type:string': db_const.DESCRIPTION_FIELD_SIZE},
|
||||
'is_visible': True, 'default': ''},
|
||||
'tenant_id': {'allow_post': True, 'allow_put': False,
|
||||
'required_by_policy': True,
|
||||
'validate': {'type:string': attr.TENANT_ID_MAX_LEN},
|
||||
'validate': {
|
||||
'type:string': db_const.PROJECT_ID_FIELD_SIZE},
|
||||
'is_visible': True},
|
||||
SECURITYGROUPRULES: {'allow_post': False, 'allow_put': False,
|
||||
'is_visible': True},
|
||||
|
@ -265,7 +268,8 @@ RESOURCE_ATTRIBUTE_MAP = {
|
|||
'convert_to': convert_ip_prefix_to_cidr},
|
||||
'tenant_id': {'allow_post': True, 'allow_put': False,
|
||||
'required_by_policy': True,
|
||||
'validate': {'type:string': attr.TENANT_ID_MAX_LEN},
|
||||
'validate': {
|
||||
'type:string': db_const.PROJECT_ID_FIELD_SIZE},
|
||||
'is_visible': True},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import six
|
|||
from neutron_lib.api import converters
|
||||
from neutron_lib.api import extensions as api_extensions
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.db import constants as db_const
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
from neutron.api import extensions
|
||||
|
@ -32,8 +33,8 @@ SEGMENT_ID = 'segment_id'
|
|||
NETWORK_TYPE = 'network_type'
|
||||
PHYSICAL_NETWORK = 'physical_network'
|
||||
SEGMENTATION_ID = 'segmentation_id'
|
||||
NAME_LEN = attributes.NAME_MAX_LEN
|
||||
DESC_LEN = attributes.DESCRIPTION_MAX_LEN
|
||||
NAME_LEN = db_const.NAME_FIELD_SIZE
|
||||
DESC_LEN = db_const.DESCRIPTION_FIELD_SIZE
|
||||
|
||||
# Attribute Map
|
||||
RESOURCE_ATTRIBUTE_MAP = {
|
||||
|
@ -46,7 +47,7 @@ RESOURCE_ATTRIBUTE_MAP = {
|
|||
'tenant_id': {'allow_post': True,
|
||||
'allow_put': False,
|
||||
'validate': {'type:string':
|
||||
attributes.TENANT_ID_MAX_LEN},
|
||||
db_const.PROJECT_ID_FIELD_SIZE},
|
||||
'is_visible': False},
|
||||
'network_id': {'allow_post': True,
|
||||
'allow_put': False,
|
||||
|
|
|
@ -14,14 +14,15 @@
|
|||
# under the License.
|
||||
|
||||
from neutron_lib.api import extensions
|
||||
from neutron_lib.db import constants as db_const
|
||||
|
||||
from neutron.api.v2 import attributes as attr
|
||||
from neutron.db import standard_attr
|
||||
|
||||
|
||||
DESCRIPTION_BODY = {
|
||||
'description': {'allow_post': True, 'allow_put': True,
|
||||
'validate': {'type:string': attr.DESCRIPTION_MAX_LEN},
|
||||
'validate': {
|
||||
'type:string': db_const.DESCRIPTION_FIELD_SIZE},
|
||||
'is_visible': True, 'default': ''}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
# under the License.
|
||||
|
||||
from neutron_lib.api import converters
|
||||
from neutron_lib.db import constants as db_const
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import importutils
|
||||
|
@ -32,7 +33,7 @@ TENANT_ID_ATTR = {'tenant_id':
|
|||
{'allow_post': False,
|
||||
'allow_put': False,
|
||||
'required_by_policy': True,
|
||||
'validate': {'type:string': attributes.TENANT_ID_MAX_LEN},
|
||||
'validate': {'type:string': db_const.PROJECT_ID_FIELD_SIZE},
|
||||
'is_visible': True}}
|
||||
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ import importlib
|
|||
import itertools
|
||||
import os
|
||||
|
||||
from neutron.conf.services import provider_configuration as prov_config
|
||||
from neutron_lib.db import constants as db_const
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
@ -25,7 +25,7 @@ from oslo_log import versionutils
|
|||
import stevedore
|
||||
|
||||
from neutron._i18n import _, _LW
|
||||
from neutron.api.v2 import attributes as attr
|
||||
from neutron.conf.services import provider_configuration as prov_config
|
||||
from neutron.db import _utils as db_utils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -160,10 +160,10 @@ def parse_service_provider_opt(service_module='neutron'):
|
|||
|
||||
"""Parse service definition opts and returns result."""
|
||||
def validate_name(name):
|
||||
if len(name) > attr.NAME_MAX_LEN:
|
||||
if len(name) > db_const.NAME_FIELD_SIZE:
|
||||
raise n_exc.Invalid(
|
||||
_("Provider name %(name)s is limited by %(len)s characters")
|
||||
% {'name': name, 'len': attr.NAME_MAX_LEN})
|
||||
% {'name': name, 'len': db_const.NAME_FIELD_SIZE})
|
||||
|
||||
neutron_mod = NeutronModule(service_module)
|
||||
svc_providers_opt = neutron_mod.service_providers()
|
||||
|
|
|
@ -13,11 +13,11 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.db import constants as db_const
|
||||
from neutron_lib.db import model_base
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import sql
|
||||
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron.db import models_v2
|
||||
from neutron.db import standard_attr
|
||||
from neutron.services.trunk import constants
|
||||
|
@ -28,7 +28,7 @@ class Trunk(standard_attr.HasStandardAttributes, model_base.BASEV2,
|
|||
|
||||
admin_state_up = sa.Column(
|
||||
sa.Boolean(), nullable=False, server_default=sql.true())
|
||||
name = sa.Column(sa.String(attributes.NAME_MAX_LEN))
|
||||
name = sa.Column(sa.String(db_const.NAME_FIELD_SIZE))
|
||||
port_id = sa.Column(sa.String(36),
|
||||
sa.ForeignKey('ports.id',
|
||||
ondelete='CASCADE'),
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
# under the License.
|
||||
|
||||
import mock
|
||||
from neutron_lib.db import constants as db_const
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_policy import policy as oslo_policy
|
||||
from oslo_serialization import jsonutils
|
||||
|
@ -100,7 +101,7 @@ class TestPolicyEnforcementHook(test_functional.PecanFunctionalTest):
|
|||
'tenant_id': {'allow_post': True, 'allow_put': False,
|
||||
'required_by_policy': True,
|
||||
'validate': {'type:string':
|
||||
attributes.TENANT_ID_MAX_LEN},
|
||||
db_const.PROJECT_ID_FIELD_SIZE},
|
||||
'is_visible': True}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,13 +12,13 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.db import constants as db_const
|
||||
from tempest.lib.common.utils import data_utils
|
||||
from tempest import test
|
||||
|
||||
from neutron.api.v2 import attributes as attr
|
||||
from neutron.tests.tempest.api import base
|
||||
|
||||
LONG_NAME_OK = 'x' * (attr.NAME_MAX_LEN)
|
||||
LONG_NAME_OK = 'x' * db_const.NAME_FIELD_SIZE
|
||||
|
||||
|
||||
class MeteringTestJSON(base.BaseAdminNetworkTest):
|
||||
|
|
|
@ -12,13 +12,13 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.db import constants as db_const
|
||||
from tempest.lib import exceptions as lib_exc
|
||||
from tempest import test
|
||||
|
||||
from neutron.api.v2 import attributes as attr
|
||||
from neutron.tests.tempest.api import base
|
||||
|
||||
LONG_NAME_NG = 'x' * (attr.NAME_MAX_LEN + 1)
|
||||
LONG_NAME_NG = 'x' * (db_const.NAME_FIELD_SIZE + 1)
|
||||
|
||||
|
||||
class MeteringNegativeTestJSON(base.BaseAdminNetworkTest):
|
||||
|
|
|
@ -10,15 +10,15 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.db import constants as db_const
|
||||
from tempest.lib import exceptions as lib_exc
|
||||
from tempest import test
|
||||
|
||||
from neutron.api.v2 import attributes as attr
|
||||
from neutron.tests.tempest.api import base
|
||||
|
||||
LONG_NAME_NG = 'z' * (attr.NAME_MAX_LEN + 1)
|
||||
LONG_DESCRIPTION_NG = 'z' * (attr.LONG_DESCRIPTION_MAX_LEN + 1)
|
||||
LONG_TENANT_ID_NG = 'z' * (attr.TENANT_ID_MAX_LEN + 1)
|
||||
LONG_NAME_NG = 'z' * (db_const.NAME_FIELD_SIZE + 1)
|
||||
LONG_DESCRIPTION_NG = 'z' * (db_const.LONG_DESCRIPTION_FIELD_SIZE + 1)
|
||||
LONG_TENANT_ID_NG = 'z' * (db_const.PROJECT_ID_FIELD_SIZE + 1)
|
||||
|
||||
|
||||
class QosNegativeTestJSON(base.BaseAdminNetworkTest):
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
import contextlib
|
||||
|
||||
from neutron_lib import constants as n_consts
|
||||
from neutron_lib.db import constants as db_const
|
||||
from oslo_utils import uuidutils
|
||||
import webob.exc
|
||||
|
||||
from neutron.api import extensions
|
||||
from neutron.api.v2 import attributes as attr
|
||||
from neutron.common import config
|
||||
from neutron import context
|
||||
import neutron.extensions
|
||||
|
@ -34,8 +34,8 @@ DB_METERING_PLUGIN_KLASS = (
|
|||
)
|
||||
|
||||
extensions_path = ':'.join(neutron.extensions.__path__)
|
||||
_long_description_ok = 'x' * (attr.LONG_DESCRIPTION_MAX_LEN)
|
||||
_long_description_ng = 'x' * (attr.LONG_DESCRIPTION_MAX_LEN + 1)
|
||||
_long_description_ok = 'x' * (db_const.LONG_DESCRIPTION_FIELD_SIZE)
|
||||
_long_description_ng = 'x' * (db_const.LONG_DESCRIPTION_FIELD_SIZE + 1)
|
||||
_fake_uuid = uuidutils.generate_uuid
|
||||
|
||||
|
||||
|
|
|
@ -17,11 +17,11 @@ import copy
|
|||
import fixtures
|
||||
import mock
|
||||
|
||||
from neutron_lib.db import constants as db_const
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import uuidutils
|
||||
from webob import exc
|
||||
|
||||
from neutron.api.v2 import attributes as attr
|
||||
from neutron import context
|
||||
from neutron.db import api as dbapi
|
||||
from neutron.db.models import flavor as flavor_models
|
||||
|
@ -42,8 +42,8 @@ _get_path = test_base._get_path
|
|||
_driver = ('neutron.tests.unit.extensions.test_flavors.'
|
||||
'DummyServiceDriver')
|
||||
_provider = 'dummy'
|
||||
_long_name = 'x' * (attr.NAME_MAX_LEN + 1)
|
||||
_long_description = 'x' * (attr.LONG_DESCRIPTION_MAX_LEN + 1)
|
||||
_long_name = 'x' * (db_const.NAME_FIELD_SIZE + 1)
|
||||
_long_description = 'x' * (db_const.LONG_DESCRIPTION_FIELD_SIZE + 1)
|
||||
|
||||
|
||||
class FlavorExtensionTestCase(extension.ExtensionTestCase):
|
||||
|
|
Loading…
Reference in New Issue