From aeec4224a4008da005b8e270a4359b8db230eba8 Mon Sep 17 00:00:00 2001 From: Jake Dahn Date: Tue, 18 Oct 2011 12:33:23 -0700 Subject: [PATCH] adding instance detail to syspanel --- .../django_openstack/syspanel/urls.py | 1 + .../syspanel/views/instances.py | 32 +++++- .../syspanel/instances/_list.html | 4 +- .../syspanel/instances/detail.html | 104 ++++++++++++++++++ 4 files changed, 138 insertions(+), 3 deletions(-) create mode 100644 django-openstack/django_openstack/templates/django_openstack/syspanel/instances/detail.html diff --git a/django-openstack/django_openstack/syspanel/urls.py b/django-openstack/django_openstack/syspanel/urls.py index 9f1c97d402..48dba7a766 100644 --- a/django-openstack/django_openstack/syspanel/urls.py +++ b/django-openstack/django_openstack/syspanel/urls.py @@ -33,6 +33,7 @@ urlpatterns = patterns('django_openstack.syspanel.views.instances', name='syspanel_tenant_usage'), url(r'^instances/$', 'index', name='syspanel_instances'), url(r'^instances/refresh$', 'refresh', name='syspanel_instances_refresh'), + url(INSTANCES % 'detail', 'detail', name='syspanel_instances_detail'), # NOTE(termie): currently just using the 'dash' versions #url(INSTANCES % 'console', 'console', name='syspanel_instances_console'), #url(INSTANCES % 'vnc', 'vnc', name='syspanel_instances_vnc'), diff --git a/django-openstack/django_openstack/syspanel/views/instances.py b/django-openstack/django_openstack/syspanel/views/instances.py index 24a2c7ec6b..e03336e139 100644 --- a/django-openstack/django_openstack/syspanel/views/instances.py +++ b/django-openstack/django_openstack/syspanel/views/instances.py @@ -22,7 +22,7 @@ from django import template from django import http from django.conf import settings from django.contrib.auth.decorators import login_required -from django.shortcuts import render_to_response +from django.shortcuts import render_to_response, redirect from django.utils.translation import ugettext as _ import datetime @@ -229,3 +229,33 @@ def refresh(request): 'terminate_form': terminate_form, 'reboot_form': reboot_form, }, context_instance=template.RequestContext(request)) + + +@login_required +def detail(request, instance_id): + try: + instance = api.server_get(request, instance_id) + try: + console = api.console_create(request, instance_id, 'vnc') + vnc_url = "%s&title=%s(%s)" % (console.output, + instance.name, + instance_id) + except api_exceptions.ApiException, e: + LOG.exception('ApiException while fetching instance vnc \ + connection') + messages.error(request, + 'Unable to get vnc console for instance %s: %s' % + (instance_id, e.message)) + return redirect('dash_instances', tenant_id) + except api_exceptions.ApiException, e: + LOG.exception('ApiException while fetching instance info') + messages.error(request, + 'Unable to get information for instance %s: %s' % + (instance_id, e.message)) + return redirect('dash_instances', tenant_id) + + return render_to_response( + 'django_openstack/syspanel/instances/detail.html', { + 'instance': instance, + 'vnc_url': vnc_url, + }, context_instance=template.RequestContext(request)) diff --git a/django-openstack/django_openstack/templates/django_openstack/syspanel/instances/_list.html b/django-openstack/django_openstack/templates/django_openstack/syspanel/instances/_list.html index b3c2569c88..d0660c3448 100644 --- a/django-openstack/django_openstack/templates/django_openstack/syspanel/instances/_list.html +++ b/django-openstack/django_openstack/templates/django_openstack/syspanel/instances/_list.html @@ -1,7 +1,7 @@ {% load parse_date %} - + @@ -13,7 +13,7 @@ {% for instance in instances %} - + diff --git a/django-openstack/django_openstack/templates/django_openstack/syspanel/instances/detail.html b/django-openstack/django_openstack/templates/django_openstack/syspanel/instances/detail.html new file mode 100644 index 0000000000..6e49ab8795 --- /dev/null +++ b/django-openstack/django_openstack/templates/django_openstack/syspanel/instances/detail.html @@ -0,0 +1,104 @@ +{% extends 'django_openstack/syspanel/base.html' %} + +{% block sidebar %} + {% with current_sidebar="instances" %} + {{block.super}} + {% endwith %} +{% endblock %} + +{% block page_header %} + {# to make searchable false, just remove it from the include statement #} + {% include "django_openstack/common/_page_header.html" with title="Instance Detail" %} +{% endblock page_header %} + +{% block syspanel_main %} + + +
+
+
    +
  • +
    +

    Status

    +
      +
    • Status: {{instance.status}}
    • +
    • Instance Name: {{instance.name}}
    • +
    • Instance ID: {{instance.id}}
    • +
    +
    +
  • + +
  • +
    +

    Specs

    +
      +
    • RAM: {{instance.attrs.memory_mb}} MB
    • +
    • VCPUs: {{instance.attrs.vcpus}} VCPU
    • +
    • Disk: {{instance.attrs.disk_gb}}GB Disk
    • +
    +
    +
  • + +
  • +
    +

    Meta

    +
      +
    • Key name: {{instance.attrs.key_name}}
    • +
    • Security Group(s): {% for group in instance.attrs.security_groups %}{{group}}, {% endfor %}
    • +
    • Image Name: {{instance.image_name}}
    • +
    +
    +
  • +
+
+ + + +
+ +
+ +
+{% endblock %} + +{% block footer_js %} + +{% endblock footer_js %}
IdName Tenant User Host
{{instance.id}}{{instance.name}} (id: {{instance.id}}) {{instance.attrs.tenant_id}} {{instance.attrs.user_id}} {{instance.attrs.host}}