Merge "Remove duplicate VALID_NAME_REGEX"

This commit is contained in:
Jenkins
2015-10-02 16:08:18 +00:00
committed by Gerrit Code Review
4 changed files with 6 additions and 6 deletions
-3
View File
@@ -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':
+3
View File
@@ -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',
+1 -2
View File
@@ -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.")