Cannot view detailed image with empty name.
After creating an image with empty name (only space characters in the name), and attempting to view it, the view crashes. Glance is not returning the name X-Meta-Header on the response if the name is not set or empty. Change-Id: I0c55e302d22552e932bdd32e10d00a103d252429 Closes-Bug: 1261367
This commit is contained in:
parent
e45c4b1ff8
commit
af5635a61c
openstack_dashboard
@ -56,7 +56,10 @@ def image_get(request, image_id):
|
||||
"""Returns an Image object populated with metadata for image
|
||||
with supplied identifier.
|
||||
"""
|
||||
return glanceclient(request).images.get(image_id)
|
||||
image = glanceclient(request).images.get(image_id)
|
||||
if not hasattr(image, 'name'):
|
||||
image.name = None
|
||||
return image
|
||||
|
||||
|
||||
def image_list_detailed(request, marker=None, filters=None, paginate=False):
|
||||
|
@ -104,3 +104,11 @@ class GlanceApiTests(test.APITestCase):
|
||||
self.assertTrue(has_more)
|
||||
self.assertEqual(len(list(images_iter)),
|
||||
len(api_images) - len(expected_images) - 1)
|
||||
|
||||
def test_get_image_empty_name(self):
|
||||
glanceclient = self.stub_glanceclient()
|
||||
glanceclient.images = self.mox.CreateMockAnything()
|
||||
glanceclient.images.get('empty').AndReturn(self.empty_name_image)
|
||||
self.mox.ReplayAll()
|
||||
image = api.glance.image_get(self.request, 'empty')
|
||||
self.assertIsNone(image.name)
|
||||
|
@ -162,6 +162,19 @@ def data(TEST):
|
||||
'protected': False}
|
||||
multi_prop_image = images.Image(images.ImageManager(None), image_dict)
|
||||
|
||||
# An image wihout name being returned based on current api
|
||||
image_dict = {'id': 'c8756975-7a3b-4e43-b7f7-433576112849',
|
||||
'status': "active",
|
||||
'size': 8 * 1024 ** 3,
|
||||
'min_disk': 0,
|
||||
'owner': 'someothertenant',
|
||||
'container_format': 'aki',
|
||||
'is_public': False,
|
||||
'protected': False}
|
||||
no_name_image = images.Image(images.ImageManager(None), image_dict)
|
||||
|
||||
TEST.images.add(public_image, private_image, protected_image,
|
||||
public_image2, private_image2, private_image3,
|
||||
shared_image1, official_image1, multi_prop_image)
|
||||
|
||||
TEST.empty_name_image = no_name_image
|
||||
|
Loading…
x
Reference in New Issue
Block a user