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

View File

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