diff --git a/instances/templates/instance.html b/instances/templates/instance.html index 75742a3..fddb6a6 100644 --- a/instances/templates/instance.html +++ b/instances/templates/instance.html @@ -4,39 +4,43 @@ {% block content %}
- + + + + + +

{{ vname }}

+ {% ifequal status 5 %} + {% trans "Off" %} + {% endifequal %} + {% ifequal status 1 %} + {% trans "Active" %} + {% endifequal %} + {% ifequal status 3 %} + {% trans "Suspend" %} + {% endifequal %} +
+ + + + + {% for disk in disks %} + + {% endfor %} + +
+ {% if cur_vcpu %} +

{{ cur_vcpu }} {% trans "Vcpu" %}

+ {% else %} +

{{ vcpu }} {% trans "Vcpu" %}

+ {% endif %} +
+

{{ cur_memory }} {% trans "MB" %} {% trans "Ram" %}

+
+

{{ disk.size|filesizeformat }} {% trans "Disk" %}

+
+
- - {% include 'errors_block.html' %} {% include 'messages_block.html' %} @@ -1083,7 +1087,7 @@ window.location.reload() } }) - }, 2000); + }, 5000); -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/instances/views.py b/instances/views.py index 5d51319..adba6f9 100644 --- a/instances/views.py +++ b/instances/views.py @@ -243,25 +243,27 @@ def instance(request, compute_id, vname): if 'delete' in request.POST: if conn.get_status() == 1: conn.force_shutdown() - try: - instance = Instance.objects.get(compute_id=compute_id, name=vname) - instance_name = instance.name - instance.delete() - if request.POST.get('delete_disk', ''): - conn.delete_disk() - finally: - msg = _("Destroy") - addlogmsg(request.user.username, instance_name, msg) - if not request.user.is_superuser: - del_userinstance = UserInstance.objects.get(id=userinstace.id) + if request.POST.get('delete_disk', ''): + conn.delete_disk() + conn.delete() + + instance = Instance.objects.get(compute_id=compute_id, name=vname) + instance_name = instance.name + instance.delete() + + if not request.user.is_superuser: + del_userinstance = UserInstance.objects.get(id=userinstace.id) + del_userinstance.delete() + else: + try: + del_userinstance = UserInstance.objects.filter(instance__compute_id=compute_id, instance__name=vname) del_userinstance.delete() - else: - try: - del_userinstance = UserInstance.objects.filter(instance__compute_id=compute_id, instance__name=vname) - del_userinstance.delete() - except UserInstance.DoesNotExist: - pass - conn.delete() + except UserInstance.DoesNotExist: + pass + + msg = _("Destroy") + addlogmsg(request.user.username, instance_name, msg) + return HttpResponseRedirect(reverse('instances')) if 'rootpasswd' in request.POST: