1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2025-01-13 08:55:17 +00:00

Changed instance info in template and deleting process

This commit is contained in:
Retspen 2015-07-09 10:41:56 +03:00
parent d73e8c72e7
commit b819b91d19
2 changed files with 58 additions and 52 deletions

View file

@ -4,39 +4,43 @@
{% block content %} {% block content %}
<!-- Page Heading --> <!-- Page Heading -->
<div class="row"> <div class="row">
<h2 class="page-header">{{ vname }}</h2> <table>
</div> <tr>
<!-- <td><h3>{{ vname }}</h3></td>
<div class="row"> <td>
<div class="col-sm-1 pull-right">
{% ifequal status 5 %} {% ifequal status 5 %}
<span class="text-danger">{% trans "Off" %}</span> <span class="label label-danger">{% trans "Off" %}</span>
{% endifequal %} {% endifequal %}
{% ifequal status 1 %} {% ifequal status 1 %}
<span class="text-success">{% trans "Active" %}</span> <span class="label label-success">{% trans "Active" %}</span>
{% endifequal %} {% endifequal %}
{% ifequal status 3 %} {% ifequal status 3 %}
<span class="text-warning">{% trans "Suspend" %}</span> <span class="label label-warning">{% trans "Suspend" %}</span>
{% endifequal %} {% endifequal %}
</div> </td>
<div class="col-sm-1 pull-right"> </tr>
</table>
<table width="65%">
<tr>
<td>
{% if cur_vcpu %} {% if cur_vcpu %}
{{ cur_vcpu }} {% trans "Vcpu" %} <h4>{{ cur_vcpu }} {% trans "Vcpu" %}</h4>
{% else %} {% else %}
{{ vcpu }} {% trans "Vcpu" %} <h4>{{ vcpu }} {% trans "Vcpu" %}</h4>
{% endif %} {% endif %}
</div> </td>
<div class="col-sm-2 pull-right"> <td>
{{ cur_memory }} {% trans "MB" %} {% trans "Ram" %} <h4>{{ cur_memory }} {% trans "MB" %} {% trans "Ram" %}</h4>
</div> </td>
<div class="col-sm-2 pull-right">
{% for disk in disks %} {% for disk in disks %}
{{ disk.size|filesizeformat }} {% trans "Disk" %} <td>
<h4>{{ disk.size|filesizeformat }} {% trans "Disk" %}</h4>
</td>
{% endfor %} {% endfor %}
</tr>
</table>
<hr>
</div> </div>
</div>
-->
<!-- /.row -->
{% include 'errors_block.html' %} {% include 'errors_block.html' %}
{% include 'messages_block.html' %} {% include 'messages_block.html' %}
@ -1083,7 +1087,7 @@
window.location.reload() window.location.reload()
} }
}) })
}, 2000); }, 5000);
</script> </script>
<script> <script>
var hash = location.hash; var hash = location.hash;

View file

@ -243,15 +243,14 @@ def instance(request, compute_id, vname):
if 'delete' in request.POST: if 'delete' in request.POST:
if conn.get_status() == 1: if conn.get_status() == 1:
conn.force_shutdown() conn.force_shutdown()
try: if request.POST.get('delete_disk', ''):
conn.delete_disk()
conn.delete()
instance = Instance.objects.get(compute_id=compute_id, name=vname) instance = Instance.objects.get(compute_id=compute_id, name=vname)
instance_name = instance.name instance_name = instance.name
instance.delete() 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: if not request.user.is_superuser:
del_userinstance = UserInstance.objects.get(id=userinstace.id) del_userinstance = UserInstance.objects.get(id=userinstace.id)
del_userinstance.delete() del_userinstance.delete()
@ -261,7 +260,10 @@ def instance(request, compute_id, vname):
del_userinstance.delete() del_userinstance.delete()
except UserInstance.DoesNotExist: except UserInstance.DoesNotExist:
pass pass
conn.delete()
msg = _("Destroy")
addlogmsg(request.user.username, instance_name, msg)
return HttpResponseRedirect(reverse('instances')) return HttpResponseRedirect(reverse('instances'))
if 'rootpasswd' in request.POST: if 'rootpasswd' in request.POST: