From 5c5037d3c6851e64b236522c6ea0d93a03017c03 Mon Sep 17 00:00:00 2001 From: nikunj2512 Date: Thu, 30 Oct 2014 12:23:20 +0530 Subject: [PATCH] Make "availability zone" field optional for host aggregates Nova allows an admin to create/update a host aggregate without specifying the "availability zone" but on the Horizon dashboard it is still required. This patch makes the availability zone field optional. Change-Id: I44a8b9ff469a203a7e1e1ae3a91e2f49bb94de86 Closes-bug: #1386076 --- openstack_dashboard/dashboards/admin/aggregates/forms.py | 1 + openstack_dashboard/dashboards/admin/aggregates/tests.py | 4 ++-- openstack_dashboard/dashboards/admin/aggregates/workflows.py | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/openstack_dashboard/dashboards/admin/aggregates/forms.py b/openstack_dashboard/dashboards/admin/aggregates/forms.py index bd261868c6..4b348560ad 100644 --- a/openstack_dashboard/dashboards/admin/aggregates/forms.py +++ b/openstack_dashboard/dashboards/admin/aggregates/forms.py @@ -28,6 +28,7 @@ class UpdateAggregateForm(forms.SelfHandlingForm): name = forms.CharField(label=_("Name"), max_length=255) availability_zone = forms.CharField(label=_("Availability Zone"), + required=False, max_length=255) def __init__(self, request, *args, **kwargs): diff --git a/openstack_dashboard/dashboards/admin/aggregates/tests.py b/openstack_dashboard/dashboards/admin/aggregates/tests.py index 9ec56a7944..c41a21a99e 100644 --- a/openstack_dashboard/dashboards/admin/aggregates/tests.py +++ b/openstack_dashboard/dashboards/admin/aggregates/tests.py @@ -113,7 +113,7 @@ class CreateAggregateWorkflowTests(BaseAggregateWorkflowTests): workflow_data = self._get_create_workflow_data(aggregate) workflow_data['name'] = '' workflow_data['availability_zone'] = '' - self._test_generic_create_aggregate(workflow_data, aggregate, 2, + self._test_generic_create_aggregate(workflow_data, aggregate, 1, u'This field is required') @test.create_stubs({api.nova: ('host_list', @@ -238,7 +238,7 @@ class AggregatesViewTests(test.BaseAdminViewTests): aggregate = self.aggregates.first() form_data = {'id': aggregate.id} - self._test_generic_update_aggregate(form_data, aggregate, 2, + self._test_generic_update_aggregate(form_data, aggregate, 1, u'This field is required') diff --git a/openstack_dashboard/dashboards/admin/aggregates/workflows.py b/openstack_dashboard/dashboards/admin/aggregates/workflows.py index 97e6b0615d..23b1bf5cac 100644 --- a/openstack_dashboard/dashboards/admin/aggregates/workflows.py +++ b/openstack_dashboard/dashboards/admin/aggregates/workflows.py @@ -25,6 +25,7 @@ class SetAggregateInfoAction(workflows.Action): max_length=255) availability_zone = forms.CharField(label=_("Availability Zone"), + required=False, max_length=255) class Meta: @@ -186,7 +187,7 @@ class CreateAggregateWorkflow(workflows.Workflow): api.nova.aggregate_create( request, name=context['name'], - availability_zone=context['availability_zone']) + availability_zone=context['availability_zone'] or None) except Exception: exceptions.handle(request, _('Unable to create host aggregate.')) return False