From 2103b682679e47a8c01df1d079376005146860ba Mon Sep 17 00:00:00 2001 From: Matthias Runge Date: Mon, 10 Dec 2012 13:49:38 +0100 Subject: [PATCH] Avoid cinder calls, when cinder is unavailable When a volume service is not available, then a cinder client can not be created. This patch skips the calls, so that dashboard doesn't break any more. Change-Id: Ic5d029302d10b453257b452ba78541febf8e4c96 Fixes bug 1084137 --- openstack_dashboard/test/helpers.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/openstack_dashboard/test/helpers.py b/openstack_dashboard/test/helpers.py index dadba3f6..ce3d1cb5 100644 --- a/openstack_dashboard/test/helpers.py +++ b/openstack_dashboard/test/helpers.py @@ -34,6 +34,7 @@ from keystoneclient.v2_0 import client as keystone_client from novaclient.v1_1 import client as nova_client from quantumclient.v2_0 import client as quantum_client from swiftclient import client as swift_client +from cinderclient import client as cinder_client import httplib2 import mox @@ -244,12 +245,14 @@ class APITestCase(TestCase): self._original_keystoneclient = api.keystone.keystoneclient self._original_novaclient = api.nova.novaclient self._original_quantumclient = api.quantum.quantumclient + self._original_cinderclient = api.cinder.cinderclient # Replace the clients with our stubs. api.glance.glanceclient = lambda request: self.stub_glanceclient() api.keystone.keystoneclient = fake_keystoneclient api.nova.novaclient = lambda request: self.stub_novaclient() api.quantum.quantumclient = lambda request: self.stub_quantumclient() + api.cinder.cinderclient = lambda request: self.stub_cinderclient() def tearDown(self): super(APITestCase, self).tearDown() @@ -257,6 +260,7 @@ class APITestCase(TestCase): api.nova.novaclient = self._original_novaclient api.keystone.keystoneclient = self._original_keystoneclient api.quantum.quantumclient = self._original_quantumclient + api.cinder.cinderclient = self._original_cinderclient def stub_novaclient(self): if not hasattr(self, "novaclient"): @@ -264,6 +268,12 @@ class APITestCase(TestCase): self.novaclient = self.mox.CreateMock(nova_client.Client) return self.novaclient + def stub_cinderclient(self): + if not hasattr(self, "cinderclient"): + self.mox.StubOutWithMock(cinder_client, 'Client') + self.cinderclient = self.mox.CreateMock(cinder_client.Client) + return self.cinderclient + def stub_keystoneclient(self): if not hasattr(self, "keystoneclient"): self.mox.StubOutWithMock(keystone_client, 'Client')