enforce maximum length for name and tenant_id fields

This seems like something legitimate that for some
reason had been missed earlier.

Change-Id: I4781d1db737e2fae7b61787330cf69b68e471967
This commit is contained in:
Thomas Morin 2017-05-31 15:45:18 +02:00
parent 9622465f99
commit 3a86761751
2 changed files with 11 additions and 6 deletions

View File

@ -14,6 +14,7 @@
from neutron_lib.api import converters
from neutron_lib.api.definitions import l3
from neutron_lib.db import constants as db_const
# Regular expression to validate an empty string
EMPTY_REGEX = (r'^$')
@ -84,13 +85,14 @@ RESOURCE_ATTRIBUTE_MAP = {
'primary_key': True,
'enforce_policy': True},
'tenant_id': {'allow_post': True, 'allow_put': False,
'validate': {'type:string': None},
'validate': {
'type:string': db_const.PROJECT_ID_FIELD_SIZE},
'required_by_policy': True,
'is_visible': True,
'enforce_policy': True},
'name': {'allow_post': True, 'allow_put': True,
'default': '',
'validate': {'type:string': None},
'validate': {'type:string': db_const.NAME_FIELD_SIZE},
'is_visible': True,
'enforce_policy': True},
'type': {'allow_post': True, 'allow_put': False,
@ -145,7 +147,8 @@ SUB_RESOURCE_ATTRIBUTE_MAP = {
'is_visible': True,
'primary_key': True},
'tenant_id': {'allow_post': True, 'allow_put': False,
'validate': {'type:string': None},
'validate': {
'type:string': db_const.PROJECT_ID_FIELD_SIZE},
'required_by_policy': True,
'is_visible': True,
'enforce_policy': True},
@ -164,7 +167,8 @@ SUB_RESOURCE_ATTRIBUTE_MAP = {
'is_visible': True,
'primary_key': True},
'tenant_id': {'allow_post': True, 'allow_put': False,
'validate': {'type:string': None},
'validate': {
'type:string': db_const.PROJECT_ID_FIELD_SIZE},
'required_by_policy': True,
'is_visible': True,
'enforce_policy': True},

View File

@ -13,6 +13,7 @@
# under the License.
from neutron_lib.api import converters
from neutron_lib.db import constants as db_const
# The alias of the extension.
@ -55,12 +56,12 @@ RESOURCE_ATTRIBUTE_MAP = {
'validate': {'type:uuid': None},
'is_visible': True, 'primary_key': True},
'name': {'allow_post': True, 'allow_put': True,
'validate': {'type:string': 255},
'validate': {'type:string': db_const.NAME_FIELD_SIZE},
'default': '', 'is_visible': True},
'tenant_id': {'allow_post': True, 'allow_put': False,
'required_by_policy': True,
'validate':
{'type:string': 255},
{'type:string': db_const.PROJECT_ID_FIELD_SIZE},
'is_visible': True},
'port_id': {'allow_post': True, 'allow_put': False,
'required_by_policy': True,