Skip to content

Commit

Permalink
Display instances with no image information
Browse files Browse the repository at this point in the history
When booted from volume, instances do not have an image reference/id.

Change-Id: I107c096a50c6a49e2a25c3b29b7d5c3273e4348e
Closes-Bug: #1239896
  • Loading branch information
jpichon committed Oct 16, 2013
1 parent 27b5b9f commit f2927f1
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
39 changes: 39 additions & 0 deletions openstack_dashboard/dashboards/project/instances/tests.py
Expand Up @@ -182,6 +182,45 @@ def test_index_flavor_get_exception(self):
self.assertMessageCount(res, error=len(servers))
self.assertItemsEqual(instances, self.servers.list())

@test.create_stubs({api.nova: ('flavor_list',
'server_list',
'tenant_absolute_limits',
'extension_supported',),
api.glance: ('image_list_detailed',),
api.network:
('floating_ip_simple_associate_supported',),
})
def test_index_with_instance_booted_from_volume(self):
volume_server = self.servers.first()
volume_server.image = ""
volume_server.image_name = "(not found)"
servers = self.servers.list()
servers[0] = volume_server

api.nova.extension_supported('AdminActions',
IsA(http.HttpRequest)) \
.MultipleTimes().AndReturn(True)
api.nova.flavor_list(IsA(http.HttpRequest)) \
.AndReturn(self.flavors.list())
api.glance.image_list_detailed(IgnoreArg()) \
.AndReturn((self.images.list(), False))
search_opts = {'marker': None, 'paginate': True}
api.nova.server_list(IsA(http.HttpRequest), search_opts=search_opts) \
.AndReturn([servers, False])
api.nova.tenant_absolute_limits(IsA(http.HttpRequest), reserved=True) \
.MultipleTimes().AndReturn(self.limits['absolute'])
api.network.floating_ip_simple_associate_supported(
IsA(http.HttpRequest)).MultipleTimes().AndReturn(True)

self.mox.ReplayAll()

res = self.client.get(INDEX_URL)

self.assertTemplateUsed(res, 'project/instances/index.html')
instances = res.context['instances_table'].data
self.assertEqual(len(instances), len(servers))
self.assertContains(res, "(not found)")

@test.create_stubs({api.nova: ('server_list',
'flavor_list',
'server_delete',),
Expand Down
1 change: 1 addition & 0 deletions openstack_dashboard/dashboards/project/instances/views.py
Expand Up @@ -89,6 +89,7 @@ def get_data(self):
# Loop through instances to get flavor info.
for instance in instances:
if (hasattr(instance, 'image')
and hasattr(instance.image, 'id')
and instance.image['id'] in image_map):
instance.image = image_map[instance.image['id']]

Expand Down

0 comments on commit f2927f1

Please sign in to comment.