fix up admin instance list

This commit is contained in:
Anthony Young
2011-06-18 20:52:29 -07:00
parent 03ee9f0d5f
commit c9dc7023f0
2 changed files with 25 additions and 7 deletions

View File

@@ -160,7 +160,22 @@ def index(request):
if handled:
return handled
instances = api.extras_api(request).servers.list()
try:
instances = api.extras_api(request).servers.list()
def get_image_cache():
images = api.glance_api(request).get_images_detailed()
image_dict = {}
for image in images:
image_dict[image['id']] = image
return image_dict
image_dict = get_image_cache()
for instance in instances:
# FIXME - ported this over, but it is hacky
instance._info['attrs']['image_name'] =\
image_dict.get(int(instance.attrs['image_id']),{}).get('name')
except:
messages.error(request, 'Unable to get instance list: %s' % e.message)
# We don't have any way of showing errors for these, so don't bother
# trying to reuse the forms from above

View File

@@ -1,12 +1,13 @@
{% load parse_date %}
<table class="wide">
<tr>
<th>Id</th>
<th>User</th>
<th>Node</th>
<th>Hostname</th>
<th>Created</th>
<th>Image</th>
<th>IP</th>
<th>Public IP</th>
<th>IP</th>
<th>State</th>
<th>Actions</th>
</tr>
@@ -15,10 +16,12 @@
<td>{{instance.id}}</td>
<td>{{instance.attrs.user_id}}</td>
<td>{{instance.attrs.hostname}}</td>
<td>{{instance.attrs.created_at}}</td>
<td title="bucket/image.manifest.xml">{{instance.imageId}}</td>
<td>{{instance.public_ip}}</td>
<td>{{instance.private_ip}}</td>
<td>{{instance.attrs.launched_at|parse_date}}</td>
<td>{{instance.attrs.image_name}}</td>
<td>{{instance.addresses.public.0.addr|default:'N/A'}}</td>
<td>{{instance.addresses.private.0.addr|default:'networking'}}</td>
<td>{{instance.status}}</td>
<td id="actions">
<ul>