Drop flavor name validation in horizon side.
This patch drop name validation in horizon and let nova check if the is name is valid or not. Instead of using pattern in the flavors form, pattern will be checked in the nova. Also I added limation for the name size with tests to check the max size since the min size has it's unit test. Closes-Bug: 1738328 Change-Id: Ib4f6f9b87560df43819d992254603e55ea8ff6a3
This commit is contained in:
parent
bf88aaf245
commit
154ddab1d4
openstack_dashboard/dashboards/admin/flavors
@ -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',
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user