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
This commit is contained in:
Matthias Runge 2012-12-10 13:49:38 +01:00
parent ceecde4255
commit 2103b68267
1 changed files with 10 additions and 0 deletions

View File

@ -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')