1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-12-24 23:25:24 +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 %}
<!-- Page Heading -->
<div class="row">
<h2 class="page-header">{{ vname }}</h2>
<table>
<tr>
<td><h3>{{ vname }}</h3></td>
<td>
{% ifequal status 5 %}
<span class="label label-danger">{% trans "Off" %}</span>
{% endifequal %}
{% ifequal status 1 %}
<span class="label label-success">{% trans "Active" %}</span>
{% endifequal %}
{% ifequal status 3 %}
<span class="label label-warning">{% trans "Suspend" %}</span>
{% endifequal %}
</td>
</tr>
</table>
<table width="65%">
<tr>
<td>
{% if cur_vcpu %}
<h4>{{ cur_vcpu }} {% trans "Vcpu" %}</h4>
{% else %}
<h4>{{ vcpu }} {% trans "Vcpu" %}</h4>
{% endif %}
</td>
<td>
<h4>{{ cur_memory }} {% trans "MB" %} {% trans "Ram" %}</h4>
</td>
{% for disk in disks %}
<td>
<h4>{{ disk.size|filesizeformat }} {% trans "Disk" %}</h4>
</td>
{% endfor %}
</tr>
</table>
<hr>
</div>
<!--
<div class="row">
<div class="col-sm-1 pull-right">
{% ifequal status 5 %}
<span class="text-danger">{% trans "Off" %}</span>
{% endifequal %}
{% ifequal status 1 %}
<span class="text-success">{% trans "Active" %}</span>
{% endifequal %}
{% ifequal status 3 %}
<span class="text-warning">{% trans "Suspend" %}</span>
{% endifequal %}
</div>
<div class="col-sm-1 pull-right">
{% if cur_vcpu %}
{{ cur_vcpu }} {% trans "Vcpu" %}
{% else %}
{{ vcpu }} {% trans "Vcpu" %}
{% endif %}
</div>
<div class="col-sm-2 pull-right">
{{ cur_memory }} {% trans "MB" %} {% trans "Ram" %}
</div>
<div class="col-sm-2 pull-right">
{% for disk in disks %}
{{ disk.size|filesizeformat }} {% trans "Disk" %}
{% endfor %}
</div>
</div>
-->
<!-- /.row -->
{% include 'errors_block.html' %}
{% include 'messages_block.html' %}
@ -1083,7 +1087,7 @@
window.location.reload()
}
})
}, 2000);
}, 5000);
</script>
<script>
var hash = location.hash;
@ -1134,4 +1138,4 @@
});
}
</script>
{% endblock %}
{% endblock %}

View file

@ -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: