Remove duplicate VALID_NAME_REGEX
VALID_NAME_REGEX was defined in api/openstack/common and compute/flavors, remove the duplicate definitions. Change-Id: I37175cc3ba11777d9a7508d757433c3dbff0b1a2 Related-Bug: 1431932
This commit is contained in:
parent
2dae8b4c87
commit
737c957c8a
|
@ -27,7 +27,6 @@ import six.moves.urllib.parse as urlparse
|
|||
import webob
|
||||
from webob import exc
|
||||
|
||||
from nova.api.validation import parameter_types
|
||||
from nova.compute import task_states
|
||||
from nova.compute import utils as compute_utils
|
||||
from nova.compute import vm_states
|
||||
|
@ -59,8 +58,6 @@ QUOTAS = quota.QUOTAS
|
|||
|
||||
CONF.import_opt('enable', 'nova.cells.opts', group='cells')
|
||||
|
||||
VALID_NAME_REGEX = re.compile(parameter_types.valid_name_regex, re.UNICODE)
|
||||
|
||||
|
||||
XML_NS_V11 = 'http://docs.openstack.org/compute/api/v1.1'
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ from webob import exc
|
|||
from nova.api.openstack import common
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api.validation import parameter_types
|
||||
import nova.exception
|
||||
from nova.i18n import _
|
||||
from nova.i18n import _LE
|
||||
|
@ -109,7 +110,7 @@ class ServerGroupController(wsgi.Controller):
|
|||
if field == 'name':
|
||||
utils.check_string_length(value, field,
|
||||
min_length=1, max_length=255)
|
||||
if not common.VALID_NAME_REGEX.search(value):
|
||||
if not parameter_types.valid_name_regex_obj.search(value):
|
||||
msg = _("Invalid format for name: '%s'") % value
|
||||
raise nova.exception.InvalidInput(reason=msg)
|
||||
elif field == 'policies':
|
||||
|
|
|
@ -100,6 +100,9 @@ valid_name_leading_trailing_spaces_regex = (
|
|||
'no_ws': re.escape(_get_printable_no_ws())})
|
||||
|
||||
|
||||
valid_name_regex_obj = re.compile(valid_name_regex, re.UNICODE)
|
||||
|
||||
|
||||
boolean = {
|
||||
'type': ['boolean', 'string'],
|
||||
'enum': [True, 'True', 'TRUE', 'true', '1', 'ON', 'On', 'on',
|
||||
|
|
|
@ -51,7 +51,6 @@ LOG = logging.getLogger(__name__)
|
|||
# create flavor names in locales that use them, however flavor IDs are limited
|
||||
# to ascii characters.
|
||||
VALID_ID_REGEX = re.compile("^[\w\.\- ]*$")
|
||||
VALID_NAME_REGEX = re.compile(parameter_types.valid_name_regex, re.UNICODE)
|
||||
|
||||
# NOTE(dosaboy): This is supposed to represent the maximum value that we can
|
||||
# place into a SQL single precision float so that we can check whether values
|
||||
|
@ -111,7 +110,7 @@ def create(name, memory, vcpus, root_gb, ephemeral_gb=0, flavorid=None,
|
|||
utils.check_string_length(name, 'name', min_length=1, max_length=255)
|
||||
|
||||
# ensure name does not contain any special characters
|
||||
valid_name = VALID_NAME_REGEX.search(name)
|
||||
valid_name = parameter_types.valid_name_regex_obj.search(name)
|
||||
if not valid_name:
|
||||
msg = _("Flavor names can only contain printable characters "
|
||||
"and horizontal spaces.")
|
||||
|
|
Loading…
Reference in New Issue