diff options
author | Pawel Palucki <pawel.palucki@intel.com> | 2014-11-10 20:56:51 +0100 |
---|---|---|
committer | Alberto Planas <aplanas@gmail.com> | 2015-07-10 13:42:15 +0200 |
commit | 184f5a6380567e902b06e6013bdb2a757ff8c9b3 (patch) | |
tree | ef81d7c17e228847f24db348791dd3bc61a144da | |
parent | 6b9f019959e47221291ca1f4723f389e6c6cda93 (diff) | |
download | horizon-184f5a6380567e902b06e6013bdb2a757ff8c9b3.tar.gz |
Fix TemplateSyntaxError at hypervisors view
If somehow nova API service-list isn't available, listing
hypervisors at /admin/hypervisors/ ends with TemplateSyntaxError.
Expected result is that the page should load but user will
see empty list and error message.
This fix is based on idea found in other views:
openstack_dashboard/dashboards/admin/...
images/views.py
aggregate/views.py
falvors/views.pu
that on any exception while getting data (get_data), we just
return empty list and handle exception to display error message.
Closes-Bug: #1392316
Change-Id: Ia665111185abecab6a96e6c72a6088cf2fa2e02b
(cherry picked from commit 5c4e827568be429ac5227a950c9f24c578ca8fd8)
-rw-r--r-- | openstack_dashboard/dashboards/admin/hypervisors/compute/tabs.py | 1 | ||||
-rw-r--r-- | openstack_dashboard/dashboards/admin/hypervisors/tests.py | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/openstack_dashboard/dashboards/admin/hypervisors/compute/tabs.py b/openstack_dashboard/dashboards/admin/hypervisors/compute/tabs.py index d95065d4b..aaaf1e8dd 100644 --- a/openstack_dashboard/dashboards/admin/hypervisors/compute/tabs.py +++ b/openstack_dashboard/dashboards/admin/hypervisors/compute/tabs.py @@ -33,3 +33,4 @@ class ComputeHostTab(tabs.TableTab): except Exception: msg = _('Unable to get nova services list.') exceptions.handle(self.tab_group.request, msg) + return [] diff --git a/openstack_dashboard/dashboards/admin/hypervisors/tests.py b/openstack_dashboard/dashboards/admin/hypervisors/tests.py index 88c57f55c..05dc37706 100644 --- a/openstack_dashboard/dashboards/admin/hypervisors/tests.py +++ b/openstack_dashboard/dashboards/admin/hypervisors/tests.py @@ -55,6 +55,24 @@ class HypervisorViewTest(test.BaseAdminViewTests): self.assertEqual(1, len(actions_host_down)) self.assertEqual('evacuate', actions_host_down[0].name) + @test.create_stubs({api.nova: ('hypervisor_list', + 'hypervisor_stats', + 'service_list')}) + def test_service_list_unavailable(self): + """test that error message should be returned when + nova.service_list isn't available + """ + hypervisors = self.hypervisors.list() + stats = self.hypervisors.stats + api.nova.hypervisor_list(IsA(http.HttpRequest)).AndReturn(hypervisors) + api.nova.hypervisor_stats(IsA(http.HttpRequest)).AndReturn(stats) + api.nova.service_list(IsA(http.HttpRequest)).AndRaise( + self.exceptions.nova) + self.mox.ReplayAll() + + resp = self.client.get(reverse('horizon:admin:hypervisors:index')) + self.assertMessageCount(resp, error=1, warning=0) + class HypervisorDetailViewTest(test.BaseAdminViewTests): @test.create_stubs({api.nova: ('hypervisor_search',)}) |