Merge "Drop flavor name validation in horizon side."

This commit is contained in:
Zuul 2017-12-20 17:31:57 +00:00 committed by Gerrit Code Review
commit 7c087f0cad
2 changed files with 7 additions and 9 deletions

View File

@ -792,11 +792,11 @@ class UpdateFlavorWorkflowTests(BaseFlavorWorkflowTests):
@test.create_stubs({api.keystone: ('tenant_list',),
api.nova: ('flavor_get',
'flavor_list',)})
def test_update_flavor_set_invalid_name(self):
def test_update_flavor_set_invalid_name_length(self):
flavor = self.flavors.first()
projects = self.tenants.list()
eph = getattr(flavor, 'OS-FLV-EXT-DATA:ephemeral')
invalid_flavor_name = "m1.tiny()"
invalid_flavor_name = "a" * 256
# init
api.nova.flavor_get(IsA(http.HttpRequest), flavor.id) \
@ -825,8 +825,9 @@ class UpdateFlavorWorkflowTests(BaseFlavorWorkflowTests):
'eph_gb': eph,
'is_public': True}
resp = self.client.post(url, workflow_data)
self.assertFormErrors(resp, 1, 'Name may only contain letters, '
'numbers, underscores, periods and hyphens.')
self.assertFormErrors(resp)
self.assertContains(resp,
"Ensure this value has at most 255 characters")
@test.create_stubs({api.keystone: ('tenant_list',),
api.nova: ('flavor_get',

View File

@ -32,12 +32,9 @@ class CreateFlavorInfoAction(workflows.Action):
_flavor_id_help_text = _("Flavor ID should be UUID4 or integer. "
"Leave this field blank or use 'auto' to set "
"a random UUID4.")
name = forms.RegexField(
name = forms.CharField(
label=_("Name"),
max_length=255,
regex=r'^[\w\.\- ]+$',
error_messages={'invalid': _('Name may only contain letters, numbers, '
'underscores, periods and hyphens.')})
max_length=255)
flavor_id = forms.RegexField(label=_("ID"),
regex=_flavor_id_regex,
required=False,