Merge "Return None image client when no glance endpoint"
This commit is contained in:
commit
175b4b59a3
|
@ -113,8 +113,12 @@ class TripleOAction(actions.Action):
|
|||
|
||||
def get_image_client(self, context):
|
||||
security_ctx = context.security
|
||||
glance_endpoint = keystone_utils.get_endpoint_for_project(
|
||||
security_ctx, 'glance')
|
||||
try:
|
||||
glance_endpoint = keystone_utils.get_endpoint_for_project(
|
||||
security_ctx, 'glance')
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
return glanceclient.Client(
|
||||
glance_endpoint.url,
|
||||
token=security_ctx.auth_token,
|
||||
|
|
|
@ -59,7 +59,7 @@ class GlanceTest(base.TestCase):
|
|||
client = mock.MagicMock()
|
||||
expected = {'kernel': 'file:///kernel', 'ramdisk': 'file:///ramdisk'}
|
||||
ids = glance.create_or_find_kernel_and_ramdisk(
|
||||
client, 'file:///kernel', 'file:///ramdisk')
|
||||
None, 'file:///kernel', 'file:///ramdisk')
|
||||
client.images.assert_not_called()
|
||||
self.assertEqual(expected, ids)
|
||||
|
||||
|
@ -70,3 +70,9 @@ class GlanceTest(base.TestCase):
|
|||
client, 'http://kernel', 'http://ramdisk')
|
||||
client.images.assert_not_called()
|
||||
self.assertEqual(expected, ids)
|
||||
|
||||
def test_return_https_urls_no_client(self):
|
||||
expected = {'kernel': 'https://kernel', 'ramdisk': 'https://ramdisk'}
|
||||
ids = glance.create_or_find_kernel_and_ramdisk(
|
||||
None, 'https://kernel', 'https://ramdisk')
|
||||
self.assertEqual(expected, ids)
|
||||
|
|
Loading…
Reference in New Issue