Restored instance details to instance index and detail pages.
Fixed bug 900435. Change-Id: I61a475b61ae55cdcd55cc0373c2cdb5d71cff0c1
This commit is contained in:
@@ -71,7 +71,7 @@ class Server(APIResourceWrapper):
|
||||
"""
|
||||
_attrs = ['addresses', 'attrs', 'hostId', 'id', 'image', 'links',
|
||||
'metadata', 'name', 'private_ip', 'public_ip', 'status', 'uuid',
|
||||
'image_name', 'VirtualInterfaces']
|
||||
'image_name', 'VirtualInterfaces', 'flavor', 'key_name']
|
||||
|
||||
def __init__(self, apiresource, request):
|
||||
super(Server, self).__init__(apiresource)
|
||||
|
||||
@@ -28,6 +28,7 @@ from django import http
|
||||
from django import shortcuts
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.utils.datastructures import SortedDict
|
||||
from django.utils.translation import ugettext as _
|
||||
import openstackx.api.exceptions as api_exceptions
|
||||
|
||||
@@ -56,6 +57,20 @@ def index(request):
|
||||
messages.error(request, _('Unable to get instance list: %s')
|
||||
% e.message)
|
||||
|
||||
# Gather our flavors and correlate our instances to them
|
||||
try:
|
||||
flavors = api.flavor_list(request)
|
||||
full_flavors = SortedDict([(str(flavor.id), flavor) for \
|
||||
flavor in flavors])
|
||||
for instance in instances:
|
||||
instance.full_flavor = full_flavors[instance.flavor["id"]]
|
||||
except api_exceptions.Unauthorized, e:
|
||||
LOG.exception('Unauthorized attempt to access flavor list.')
|
||||
messages.error(request, _('Unauthorized.'))
|
||||
except Exception, e:
|
||||
LOG.exception('Exception while fetching flavor info')
|
||||
messages.error(request, _('Unable to get flavor info: %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
|
||||
terminate_form = TerminateInstance()
|
||||
@@ -250,6 +265,19 @@ def detail(request, instance_id):
|
||||
return shortcuts.redirect(
|
||||
'horizon:nova:instances_and_volumes:instances:index')
|
||||
|
||||
# Gather our flavors and images and correlate our instances to them
|
||||
try:
|
||||
flavors = api.flavor_list(request)
|
||||
full_flavors = SortedDict([(str(flavor.id), flavor) for \
|
||||
flavor in flavors])
|
||||
instance.full_flavor = full_flavors[instance.flavor["id"]]
|
||||
except api_exceptions.Unauthorized, e:
|
||||
LOG.exception('Unauthorized attempt to access flavor list.')
|
||||
messages.error(request, _('Unauthorized.'))
|
||||
except Exception, e:
|
||||
LOG.exception('Exception while fetching flavor info')
|
||||
messages.error(request, _('Unable to get flavor info: %s') % e.message)
|
||||
|
||||
return shortcuts.render(request,
|
||||
'nova/instances_and_volumes/instances/detail.html', {
|
||||
'instance': instance,
|
||||
|
||||
@@ -30,6 +30,7 @@ from django import shortcuts
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.utils.datastructures import SortedDict
|
||||
from novaclient import exceptions as novaclient_exceptions
|
||||
import openstackx.api.exceptions as api_exceptions
|
||||
|
||||
@@ -51,12 +52,16 @@ def index(request):
|
||||
form, handled = f.maybe_handle(request)
|
||||
if handled:
|
||||
return handled
|
||||
|
||||
# Gather our instances
|
||||
try:
|
||||
instances = api.server_list(request)
|
||||
except api_exceptions.ApiException as e:
|
||||
instances = []
|
||||
LOG.exception(_('Exception in instance index'))
|
||||
messages.error(request, _('Unable to fetch instances: %s') % e.message)
|
||||
|
||||
# Gather our volumes
|
||||
try:
|
||||
volumes = api.volume_list(request)
|
||||
except novaclient_exceptions.ClientException, e:
|
||||
@@ -64,6 +69,20 @@ def index(request):
|
||||
LOG.exception("ClientException in volume index")
|
||||
messages.error(request, _('Unable to fetch volumes: %s') % e.message)
|
||||
|
||||
# Gather our flavors and correlate our instances to them
|
||||
try:
|
||||
flavors = api.flavor_list(request)
|
||||
full_flavors = SortedDict([(str(flavor.id), flavor) for \
|
||||
flavor in flavors])
|
||||
for instance in instances:
|
||||
instance.full_flavor = full_flavors[instance.flavor["id"]]
|
||||
except api_exceptions.Unauthorized, e:
|
||||
LOG.exception('Unauthorized attempt to access flavor list.')
|
||||
messages.error(request, _('Unauthorized.'))
|
||||
except Exception, e:
|
||||
LOG.exception('Exception while fetching flavor info')
|
||||
messages.error(request, _('Unable to get flavor info: %s') % e.message)
|
||||
|
||||
terminate_form = TerminateInstance()
|
||||
reboot_form = RebootInstance()
|
||||
delete_form = DeleteForm()
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
<a href="{% url horizon:nova:instances_and_volumes:instances:detail instance.id %}">{{ instance.name }}</a>
|
||||
</td>
|
||||
<td>
|
||||
{{ instance.attrs.memory_mb|mbformat }} Ram | {{ instance.attrs.vcpus }} VCPU | {{ instance.attrs.disk_gb }}GB Disk
|
||||
{{ instance.full_flavor.ram|mbformat }} Ram | {{ instance.full_flavor.vcpus }} VCPU | {{ instance.full_flavor.disk }}GB Disk
|
||||
</td>
|
||||
<td>{{ instance.status|lower|capfirst }}</td>
|
||||
<td id="name_{{ instance.name }}" class="actions">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{% extends 'nova/base.html' %}
|
||||
{% load i18n %}
|
||||
{% load i18n sizeformat %}
|
||||
|
||||
{% block page_header %}
|
||||
{# to make searchable false, just remove it from the include statement #}
|
||||
@@ -20,9 +20,9 @@
|
||||
<div class="status">
|
||||
<h4>{% trans "Status" %}</h4>
|
||||
<ul>
|
||||
<li><span>{% trans "Status:" %}</span> {{instance.status}}</li>
|
||||
<li><span>{% trans "Instance Name:" %}</span> {{instance.name}}</li>
|
||||
<li><span>{% trans "Instance ID:" %}</span> {{instance.id}}</li>
|
||||
<li><span>{% trans "Status:" %}</span> {{ instance.status }}</li>
|
||||
<li><span>{% trans "Instance Name:" %}</span> {{ instance.name }}</li>
|
||||
<li><span>{% trans "Instance ID:" %}</span> {{ instance.id }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
@@ -31,9 +31,9 @@
|
||||
<div class="specs">
|
||||
<h4>{% trans "Specs" %}</h4>
|
||||
<ul>
|
||||
<li><span>{% trans "RAM:" %}</span> {{instance.attrs.memory_mb}}</li>
|
||||
<li><span>{% trans "VCPUs:" %}</span> {{instance.attrs.vcpus}} {% trans "VCPU" %}</li>
|
||||
<li><span>{% trans "Disk:" %}</span> {{instance.attrs.disk_gb}}{% trans "GB Disk" %}</li>
|
||||
<li><span>{% trans "RAM:" %}</span> {{ instance.full_flavor.ram|mbformat }}</li>
|
||||
<li><span>{% trans "VCPUs:" %}</span> {{ instance.full_flavor.vcpus }} {% trans "VCPU" %}</li>
|
||||
<li><span>{% trans "Disk:" %}</span> {{ instance.full_flavor.disk }}{% trans "GB" %}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
@@ -42,9 +42,11 @@
|
||||
<div class="meta">
|
||||
<h4>{% trans "Meta" %}</h4>
|
||||
<ul>
|
||||
<li><span>{% trans "Key name:" %}</span> {{instance.attrs.key_name}}</li>
|
||||
<li><span>{% trans "Key name:" %}</span> {{ instance.key_name }}</li>
|
||||
{% comment %} Security Groups aren't sent back from Nova anymore...
|
||||
<li><span>{% trans "Security Group(s):" %}</span> {% for group in instance.attrs.security_groups %}{{group}}, {% endfor %}</li>
|
||||
<li><span>{% trans "Image Name:" %}</span> {{instance.image_name}}</li>
|
||||
{% endcomment %}
|
||||
<li><span>{% trans "Image Name:" %}</span> {{ instance.image_name }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
Reference in New Issue
Block a user