Merge "Tolerate unconfigured glance service when loading image name"
This commit is contained in:
commit
d4c4efbcce
@ -36,6 +36,7 @@ from novaclient.v2 import security_groups as nova_security_groups
|
||||
from novaclient.v2 import servers as nova_servers
|
||||
|
||||
from horizon import conf
|
||||
from horizon import exceptions as horizon_exceptions
|
||||
from horizon.utils import functions as utils
|
||||
from horizon.utils.memoized import memoized # noqa
|
||||
|
||||
@ -121,7 +122,8 @@ class Server(base.APIResourceWrapper):
|
||||
try:
|
||||
image = glance.image_get(self.request, self.image['id'])
|
||||
return image.name
|
||||
except glance_exceptions.ClientException:
|
||||
except (glance_exceptions.ClientException,
|
||||
horizon_exceptions.ServiceCatalogException):
|
||||
return _("-")
|
||||
|
||||
@property
|
||||
|
@ -28,6 +28,7 @@ from novaclient import exceptions as nova_exceptions
|
||||
from novaclient.v2 import servers
|
||||
import six
|
||||
|
||||
from horizon import exceptions as horizon_exceptions
|
||||
from openstack_dashboard import api
|
||||
from openstack_dashboard.test import helpers as test
|
||||
|
||||
@ -48,6 +49,17 @@ class ServerWrapperTests(test.TestCase):
|
||||
server = api.nova.Server(self.servers.first(), self.request)
|
||||
self.assertEqual(image.name, server.image_name)
|
||||
|
||||
def test_image_name_no_glance_service(self):
|
||||
server = self.servers.first()
|
||||
self.mox.StubOutWithMock(api.glance, 'image_get')
|
||||
api.glance.image_get(IsA(http.HttpRequest),
|
||||
server.image['id']).AndRaise(
|
||||
horizon_exceptions.ServiceCatalogException('image'))
|
||||
self.mox.ReplayAll()
|
||||
|
||||
server = api.nova.Server(server, self.request)
|
||||
self.assertEqual('-', server.image_name)
|
||||
|
||||
|
||||
class ComputeApiTests(test.APITestCase):
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user