1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-12-24 23:25:24 +00:00

Users permission

This commit is contained in:
Retspen 2015-03-16 11:57:55 +02:00
parent b98084b7ee
commit 983dbaf91a
5 changed files with 270 additions and 225 deletions

View file

@ -106,6 +106,24 @@ def instance(request, compute_id, vname):
if not request.user.is_authenticated(): if not request.user.is_authenticated():
return HttpResponseRedirect(reverse('index')) return HttpResponseRedirect(reverse('index'))
error_messages = []
messages = []
compute = Compute.objects.get(id=compute_id)
computes = Compute.objects.all()
computes_count = len(computes)
keymaps = QEMU_KEYMAPS
console_types = QEMU_CONSOLE_TYPES
try:
userinstace = UserInstance.objects.get(instance__compute_id=compute_id,
instance__name=vname,
user__id=request.user.id)
except UserInstance.DoesNotExist:
userinstace = None
if not request.user.is_superuser:
if not userinstace:
return HttpResponseRedirect(reverse('index'))
def show_clone_disk(disks): def show_clone_disk(disks):
clone_disk = [] clone_disk = []
for disk in disks: for disk in disks:
@ -120,14 +138,6 @@ def instance(request, compute_id, vname):
{'dev': disk['dev'], 'storage': disk['storage'], 'image': image, 'format': disk['format']}) {'dev': disk['dev'], 'storage': disk['storage'], 'image': image, 'format': disk['format']})
return clone_disk return clone_disk
error_messages = []
messages = []
compute = Compute.objects.get(id=compute_id)
computes = Compute.objects.all()
computes_count = len(computes)
keymaps = QEMU_KEYMAPS
console_types = QEMU_CONSOLE_TYPES
try: try:
conn = wvmInstance(compute.hostname, conn = wvmInstance(compute.hostname,
compute.login, compute.login,
@ -164,21 +174,17 @@ def instance(request, compute_id, vname):
has_managed_save_image = conn.get_managed_save_image() has_managed_save_image = conn.get_managed_save_image()
clone_disks = show_clone_disk(disks) clone_disks = show_clone_disk(disks)
console_passwd = conn.get_console_passwd() console_passwd = conn.get_console_passwd()
except libvirtError as lib_err:
error_messages.append(lib_err)
try: try:
instance = Instance.objects.get(compute_id=compute_id, name=vname) instance = Instance.objects.get(compute_id=compute_id, name=vname)
if instance.uuid != uuid: if instance.uuid != uuid:
instance.uuid = uuid instance.uuid = uuid
instance.save()
except Instance.DoesNotExist:
instance = Instance(compute_id=compute_id, name=vname, uuid=uuid)
instance.save() instance.save()
except Instance.DoesNotExist:
instance = Instance(compute_id=compute_id, name=vname, uuid=uuid)
instance.save()
try:
if request.method == 'POST': if request.method == 'POST':
if 'poweron' in request.POST: if 'poweron' in request.POST:
conn.start() conn.start()
return HttpResponseRedirect(request.get_full_path() + '#poweron') return HttpResponseRedirect(request.get_full_path() + '#poweron')
@ -209,8 +215,17 @@ def instance(request, compute_id, vname):
if request.POST.get('delete_disk', ''): if request.POST.get('delete_disk', ''):
conn.delete_disk() conn.delete_disk()
finally: finally:
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.save()
except UserInstance.DoesNotExist:
pass
conn.delete() conn.delete()
return HttpResponseRedirect(reverse('instances', args=[compute_id])) return HttpResponseRedirect(reverse('instances'))
if 'snapshot' in request.POST: if 'snapshot' in request.POST:
name = request.POST.get('name', '') name = request.POST.get('name', '')
@ -330,7 +345,7 @@ def instance(request, compute_id, vname):
conn.close() conn.close()
except libvirtError as err: except libvirtError as lib_err:
error_messages.append(err) error_messages.append(lib_err)
return render(request, 'instance.html', locals()) return render(request, 'instance.html', locals())

View file

@ -7,6 +7,26 @@
<div class="col-lg-12"> <div class="col-lg-12">
<h1 class="page-header">{{ vname }}</h1> <h1 class="page-header">{{ vname }}</h1>
</div> </div>
<h4 class="page-header">
{% trans "Status:" %}
{% 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 %}
{% trans "Vcpu:" %}
{% if cur_vcpu %}{{ cur_vcpu }}{% else %}{{ vcpu }}{% endif %}
{% trans "Ram:" %}
{{ cur_memory }}{% trans "MB" %}
{% trans "Disk:" %}
{% for disk in disks %}
{{ disk.size|filesizeformat }}
{% endfor %}
</h4>
</div> </div>
<!-- /.row --> <!-- /.row -->
@ -14,26 +34,6 @@
<div class="row" id="max-width-page"> <div class="row" id="max-width-page">
<div class="col-lg-12"> <div class="col-lg-12">
{% 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 %}
{% if cur_vcpu %}{{ cur_vcpu }}{% else %}{{ vcpu }}{% endif %} {% trans "Vcpu" %}
{{ cur_memory }}{% trans "MB" %} {% trans "Ram" %}
{% for disk in disks %}
{{ disk.size|filesizeformat }} {% trans "Disk" %}
{% endfor %}
{{ description }}
<hr>
<div role="tabpanel"> <div role="tabpanel">
<!-- Nav tabs --> <!-- Nav tabs -->
<ul class="nav nav-pills" role="tablist"> <ul class="nav nav-pills" role="tablist">
@ -97,11 +97,13 @@
{% trans "Power Off" %} {% trans "Power Off" %}
</a> </a>
</li> </li>
<li role="presentation"> {% if status %}
<a href="#suspend" aria-controls="suspend" role="tab" data-toggle="tab"> <li role="presentation">
{% trans "Suspend" %} <a href="#suspend" aria-controls="suspend" role="tab" data-toggle="tab">
</a> {% trans "Suspend" %}
</li> </a>
</li>
{% endif %}
{% endifequal %} {% endifequal %}
{% ifequal status 3 %} {% ifequal status 3 %}
<li role="presentation" class="active"> <li role="presentation" class="active">
@ -201,67 +203,72 @@
<!-- Tab panes --> <!-- Tab panes -->
<div class="tab-content"> <div class="tab-content">
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="resizevm"> <div role="tabpanel" class="tab-pane tab-pane-bordered active" id="resizevm">
<form class="form-horizontal" method="post" role="form">{% csrf_token %} {% if request.user.is_superuser or userinstace.is_change %}
<p style="font-weight:bold;">{% trans "Logical host CPUs:" %} {{ vcpu_host }}</p> <form class="form-horizontal" method="post" role="form">{% csrf_token %}
<div class="form-group"> <p style="font-weight:bold;">{% trans "Logical host CPUs:" %} {{ vcpu_host }}</p>
<label class="col-sm-4 control-label" style="font-weight:normal;"> {% trans "Current allocation" %}</label> <div class="form-group">
<div class="col-sm-4"> <label class="col-sm-4 control-label" style="font-weight:normal;"> {% trans "Current allocation" %}</label>
<select name="cur_vcpu" class="form-control"> <div class="col-sm-4">
{% for cpu in vcpu_range %} <select name="cur_vcpu" class="form-control">
{% if cur_vcpu %} {% for cpu in vcpu_range %}
<option value="{{ cpu }}" {% if cpu == cur_vcpu %}selected{% endif %}>{{ cpu }}</option> {% if cur_vcpu %}
{% else %} <option value="{{ cpu }}" {% if cpu == cur_vcpu %}selected{% endif %}>{{ cpu }}</option>
{% else %}
<option value="{{ cpu }}" {% if cpu == vcpu %}selected{% endif %}>{{ cpu }}</option>
{% endif %}
{% endfor %}
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" style="font-weight:normal;">{% trans "Maximum allocation" %}</label>
<div class="col-sm-4">
<select name="vcpu" class="form-control">
{% for cpu in vcpu_range %}
<option value="{{ cpu }}" {% if cpu == vcpu %}selected{% endif %}>{{ cpu }}</option> <option value="{{ cpu }}" {% if cpu == vcpu %}selected{% endif %}>{{ cpu }}</option>
{% endif %} {% endfor %}
{% endfor %} </select>
</select> </div>
</div> </div>
</div> <p style="font-weight:bold;">{% trans "Total host memory:" %} {{ memory_host|filesizeformat }}</p>
<div class="form-group"> <div class="form-group">
<label class="col-sm-4 control-label" style="font-weight:normal;">{% trans "Maximum allocation" %}</label> <label class="col-sm-4 control-label" style="font-weight:normal;">{% trans "Current allocation" %} ({% trans "MB" %})</label>
<div class="col-sm-4"> <div class="col-sm-4 js-custom__container">
<select name="vcpu" class="form-control"> <select name="cur_memory" class="form-control js-custom__toggle">
{% for cpu in vcpu_range %} {% for mem in memory_range %}
<option value="{{ cpu }}" {% if cpu == vcpu %}selected{% endif %}>{{ cpu }}</option> <option value="{{ mem }}"
{% endfor %} {% if mem == cur_memory %}selected{% endif %}>{{ mem }}</option>
</select> {% endfor %}
</select>
<input type="text" name="cur_memory_custom" class="form-control js-custom__toggle" style="display: none" />
<small><input type="checkbox" class="js-custom__checkbox" /> {% trans "Custom value" %}</small>
</div>
</div> </div>
</div> <div class="form-group">
<p style="font-weight:bold;">{% trans "Total host memory:" %} {{ memory_host|filesizeformat }}</p> <label class="col-sm-4 control-label"
<div class="form-group"> style="font-weight:normal;">{% trans "Maximum allocation" %} ({% trans "MB" %})</label>
<label class="col-sm-4 control-label" style="font-weight:normal;">{% trans "Current allocation" %} ({% trans "MB" %})</label>
<div class="col-sm-4 js-custom__container">
<select name="cur_memory" class="form-control js-custom__toggle">
{% for mem in memory_range %}
<option value="{{ mem }}"
{% if mem == cur_memory %}selected{% endif %}>{{ mem }}</option>
{% endfor %}
</select>
<input type="text" name="cur_memory_custom" class="form-control js-custom__toggle" style="display: none" />
<small><input type="checkbox" class="js-custom__checkbox" /> {% trans "Custom value" %}</small>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label"
style="font-weight:normal;">{% trans "Maximum allocation" %} ({% trans "MB" %})</label>
<div class="col-sm-4 js-custom__container"> <div class="col-sm-4 js-custom__container">
<select name="memory" class="form-control js-custom__toggle"> <select name="memory" class="form-control js-custom__toggle">
{% for mem in memory_range %} {% for mem in memory_range %}
<option value="{{ mem }}" <option value="{{ mem }}"
{% if mem == memory %}selected{% endif %}>{{ mem }}</option> {% if mem == memory %}selected{% endif %}>{{ mem }}</option>
{% endfor %} {% endfor %}
</select> </select>
<input type="text" name="memory_custom" class="form-control js-custom__toggle" style="display: none" /> <input type="text" name="memory_custom" class="form-control js-custom__toggle" style="display: none" />
<small><input type="checkbox" class="js-custom__checkbox" /> {% trans "Custom value" %}</small> <small><input type="checkbox" class="js-custom__checkbox" /> {% trans "Custom value" %}</small>
</div>
</div> </div>
</div> {% ifequal status 5 %}
{% ifequal status 5 %} <button type="submit" class="btn btn-lg btn-success pull-right" name="resize">{% trans "Resize" %}</button>
<button type="submit" class="btn btn-lg btn-success pull-right" name="resize">{% trans "Resize" %}</button> {% else %}
{% else %} <button class="btn btn-lg btn-success pull-right disabled">{% trans "Resize" %}</button>
<button class="btn btn-lg btn-success pull-right disabled">{% trans "Resize" %}</button> {% endifequal %}
{% endifequal %} </form>
</form> {% else %}
{% trans "You don't have permission for resizing instance" %}
<button class="btn btn-lg btn-success pull-right disabled">{% trans "Resize" %}</button>
{% endif %}
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
</div> </div>
@ -685,15 +692,19 @@
<div class="tab-content"> <div class="tab-content">
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="destroy"> <div role="tabpanel" class="tab-pane tab-pane-bordered active" id="destroy">
<p>{% trans "Delete storage for instance?" %}</p> <p>{% trans "Delete storage for instance?" %}</p>
<form class="form-group" method="post" role="form">{% csrf_token %} {% if request.user.is_superuser or userinstace.is_delete %}
<div class="checkbox" style="margin-left: 8px;"> <form class="form-group" method="post" role="form">{% csrf_token %}
<label> <div class="checkbox" style="margin-left: 8px;">
<input type="checkbox" name="delete_disk" value="true"> <label>
<strong>{% trans "Remove Instance's data" %}</strong> <input type="checkbox" name="delete_disk" value="true">
</label> <strong>{% trans "Remove Instance's data" %}</strong>
</div> </label>
<button type="submit" class="btn btn-lg btn-success pull-right" name="delete">{% trans "Destroy" %}</button> </div>
</form> <button type="submit" class="btn btn-lg btn-success pull-right" name="delete">{% trans "Destroy" %}</button>
</form>
{% else %}
<button class="btn btn-lg btn-success disabled pull-right" name="delete">{% trans "Destroy" %}</button>
{% endif %}
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
</div> </div>

View file

@ -23,39 +23,138 @@
<div class="col-lg-12"> <div class="col-lg-12">
<div class="table-responsive"> <div class="table-responsive">
{% if request.user.is_superuser %} {% if request.user.is_superuser %}
<table class="table table-hover table-striped sortable-theme-bootstrap" data-sortable> {% if not all_host_vms %}
<thead> <div class="col-lg-12">
<tr> <div class="alert alert-warning alert-dismissable">
<th>Name</th> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<th>Host</th> <i class="fa fa-exclamation-triangle"></i> <strong>{% trans "Warning:" %}</strong> {% trans "You don't have any Instace" %}
<th>Status</th> </div>
<th>VCPU</th> </div>
<th>Memory</th> {% else %}
<th data-sortable="false" style="width: 165px;">Actions</th> <table class="table table-hover table-striped sortable-theme-bootstrap" data-sortable>
</tr> <thead>
</thead> <tr>
<tbody class="searchable"> <th>Name</th>
{% for host, inst in all_host_vms.items %} <th>Host</th>
{% for vm, info in inst.items %} <th>Status</th>
<th>VCPU</th>
<th>Memory</th>
<th data-sortable="false" style="width: 165px;">Actions</th>
</tr>
</thead>
<tbody class="searchable">
{% for host, inst in all_host_vms.items %}
{% for vm, info in inst.items %}
<tr>
<td><a href="{% url 'instance' host.0 vm %}">{{ vm }}</a></td>
<td><a href="{% url 'overview' host.0 %}">{{ host.1 }}</a></td>
<td>{% ifequal info.status 1 %}
<p class="text-success">{% trans "Active" %}</p>
{% endifequal %}
{% ifequal info.status 5 %}
<p class="text-danger">{% trans "Off" %}</p>
{% endifequal %}
{% ifequal info.status 3 %}
<p class="text-warning">{% trans "Suspend" %}</p>
{% endifequal %}
</td>
<td>{{ info.vcpu }}</td>
<td>{{ info.memory }} {% trans "MB" %}</td>
<td><form action="" method="post" role="form">{% csrf_token %}
<input type="hidden" name="name" value="{{ vm }}"/>
<input type="hidden" name="compute_id" value="{{ host.0 }}"/>
{% ifequal info.status 5 %}
<button class="btn btn-sm btn-default" type="submit" name="start" title="Start">
<span class="glyphicon glyphicon-play"></span>
</button>
<button class="btn btn-sm btn-default disabled" title="{% trans "Suspend" %}">
<span class="glyphicon glyphicon-pause"></span>
</button>
<button class="btn btn-sm btn-default disabled" title="{% trans "Destroy" %}">
<span class="glyphicon glyphicon-stop"></span>
</button>
<button class="btn btn-sm btn-default disabled" title="{% trans "Console" %}">
<span class="glyphicon glyphicon-eye-open"></span>
</button>
{% endifequal %}
{% ifequal info.status 3 %}
<button class="btn btn-sm btn-default" type="submit" name="resume"
title="{% trans "Resume" %}">
<span class="glyphicon glyphicon-play"></span>
</button>
<button class="btn btn-sm btn-default disabled" title="{% trans "Suspend" %}">
<span class="glyphicon glyphicon-pause"></span>
</button>
<button class="btn btn-sm btn-default disabled" title="{% trans "Destroy" %}">
<span class="glyphicon glyphicon-stop"></span>
</button>
<button class="btn btn-sm btn-default disabled" title="{% trans "Console" %}">
<span class="glyphicon glyphicon-eye-open"></span>
</button>
{% endifequal %}
{% ifequal info.status 1 %}
<button class="btn btn-sm btn-default disabled" title="{% trans "Start" %}">
<span class="glyphicon glyphicon-play"></span>
</button>
<button class="btn btn-sm btn-default" type="submit" name="suspend"
title="{% trans "Suspend" %}">
<span class="glyphicon glyphicon-pause"></span>
</button>
<button class="btn btn-sm btn-default" type="submit" name="destroy"
title="{% trans "Destroy" %}" onclick="return confirm('Are you sure?')">
<span class="glyphicon glyphicon-stop"></span>
</button>
<a href="#" class="btn btn-sm btn-default" onclick='open_console("{{ host.0 }}-{{ info.uuid }}")' title="{% trans "Console" %}">
<span class="glyphicon glyphicon-eye-open"></span>
</a>
{% endifequal %}
</form>
</td>
</tr>
{% endfor %}
{% endfor %}
</tbody>
</table>
{% endif %}
{% else %}
{% if not all_user_vms %}
<div class="col-lg-12">
<div class="alert alert-warning alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<i class="fa fa-exclamation-triangle"></i> <strong>{% trans "Warning:" %}</strong> {% trans "You don't have any Instace" %}
</div>
</div>
{% else %}
<table class="table table-hover table-striped sortable-theme-bootstrap" data-sortable>
<thead>
<tr>
<th>Name</th>
<th>Status</th>
<th>VCPU</th>
<th>Memory</th>
<th data-sortable="false" style="width: 165px;">Actions</th>
</tr>
</thead>
<tbody class="searchable">
{% for inst, vm in all_user_vms.items %}
<tr> <tr>
<td><a href="{% url 'instance' host.0 vm %}">{{ vm }}</a></td> <td><a href="{% url 'instance' vm.compute_id vm.name %}">{{ vm.name }}</a></td>
<td><a href="{% url 'overview' host.0 %}">{{ host.1 }}</a></td> <td>{% ifequal vm.status 1 %}
<td>{% ifequal info.status 1 %}
<p class="text-success">{% trans "Active" %}</p> <p class="text-success">{% trans "Active" %}</p>
{% endifequal %} {% endifequal %}
{% ifequal info.status 5 %} {% ifequal vm.status 5 %}
<p class="text-danger">{% trans "Off" %}</p> <p class="text-danger">{% trans "Off" %}</p>
{% endifequal %} {% endifequal %}
{% ifequal info.status 3 %} {% ifequal vm.status 3 %}
<p class="text-warning">{% trans "Suspend" %}</p> <p class="text-warning">{% trans "Suspend" %}</p>
{% endifequal %} {% endifequal %}
</td> </td>
<td>{{ info.vcpu }}</td> <td>{{ vm.vcpu }}</td>
<td>{{ info.memory }} {% trans "MB" %}</td> <td>{{ vm.memory }} {% trans "MB" %}</td>
<td><form action="" method="post" role="form">{% csrf_token %} <td><form action="" method="post" role="form">{% csrf_token %}
<input type="hidden" name="name" value="{{ vm }}"/> <input type="hidden" name="name" value="{{ vm.name }}"/>
<input type="hidden" name="compute_id" value="{{ host.0 }}"/> <input type="hidden" name="compute_id" value="{{ vm.compute_id }}"/>
{% ifequal info.status 5 %} {% ifequal vm.status 5 %}
<button class="btn btn-sm btn-default" type="submit" name="start" title="Start"> <button class="btn btn-sm btn-default" type="submit" name="start" title="Start">
<span class="glyphicon glyphicon-play"></span> <span class="glyphicon glyphicon-play"></span>
</button> </button>
@ -69,7 +168,7 @@
<span class="glyphicon glyphicon-eye-open"></span> <span class="glyphicon glyphicon-eye-open"></span>
</button> </button>
{% endifequal %} {% endifequal %}
{% ifequal info.status 3 %} {% ifequal vm.status 3 %}
<button class="btn btn-sm btn-default" type="submit" name="resume" <button class="btn btn-sm btn-default" type="submit" name="resume"
title="{% trans "Resume" %}"> title="{% trans "Resume" %}">
<span class="glyphicon glyphicon-play"></span> <span class="glyphicon glyphicon-play"></span>
@ -84,7 +183,7 @@
<span class="glyphicon glyphicon-eye-open"></span> <span class="glyphicon glyphicon-eye-open"></span>
</button> </button>
{% endifequal %} {% endifequal %}
{% ifequal info.status 1 %} {% ifequal vm.status 1 %}
<button class="btn btn-sm btn-default disabled" title="{% trans "Start" %}"> <button class="btn btn-sm btn-default disabled" title="{% trans "Start" %}">
<span class="glyphicon glyphicon-play"></span> <span class="glyphicon glyphicon-play"></span>
</button> </button>
@ -96,7 +195,8 @@
title="{% trans "Destroy" %}" onclick="return confirm('Are you sure?')"> title="{% trans "Destroy" %}" onclick="return confirm('Are you sure?')">
<span class="glyphicon glyphicon-stop"></span> <span class="glyphicon glyphicon-stop"></span>
</button> </button>
<a href="#" class="btn btn-sm btn-default" onclick='open_console("{{ host.0 }}-{{ info.uuid }}")' title="{% trans "Console" %}"> <a href="#" class="btn btn-sm btn-default"
onclick='open_console("{{ host.0 }}-{{ vm.uuid }}")' title="{% trans "Console" %}">
<span class="glyphicon glyphicon-eye-open"></span> <span class="glyphicon glyphicon-eye-open"></span>
</a> </a>
{% endifequal %} {% endifequal %}
@ -104,91 +204,9 @@
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
{% endfor %} </tbody>
</tbody> </table>
</table> {% endif %}
{% else %}
<table class="table table-hover table-striped sortable-theme-bootstrap" data-sortable>
<thead>
<tr>
<th>Name</th>
<th>Status</th>
<th>VCPU</th>
<th>Memory</th>
<th data-sortable="false" style="width: 165px;">Actions</th>
</tr>
</thead>
<tbody class="searchable">
{% for inst, vm in all_user_vms.items %}
<tr>
<td><a href="{% url 'instance' vm.compute_id vm.name %}">{{ vm.name }}</a></td>
<td>{% ifequal vm.status 1 %}
<p class="text-success">{% trans "Active" %}</p>
{% endifequal %}
{% ifequal vm.status 5 %}
<p class="text-danger">{% trans "Off" %}</p>
{% endifequal %}
{% ifequal vm.status 3 %}
<p class="text-warning">{% trans "Suspend" %}</p>
{% endifequal %}
</td>
<td>{{ vm.vcpu }}</td>
<td>{{ vm.memory }} {% trans "MB" %}</td>
<td><form action="" method="post" role="form">{% csrf_token %}
<input type="hidden" name="name" value="{{ vm.name }}"/>
<input type="hidden" name="compute_id" value="{{ vm.compute_id }}"/>
{% ifequal vm.status 5 %}
<button class="btn btn-sm btn-default" type="submit" name="start" title="Start">
<span class="glyphicon glyphicon-play"></span>
</button>
<button class="btn btn-sm btn-default disabled" title="{% trans "Suspend" %}">
<span class="glyphicon glyphicon-pause"></span>
</button>
<button class="btn btn-sm btn-default disabled" title="{% trans "Destroy" %}">
<span class="glyphicon glyphicon-stop"></span>
</button>
<button class="btn btn-sm btn-default disabled" title="{% trans "Console" %}">
<span class="glyphicon glyphicon-eye-open"></span>
</button>
{% endifequal %}
{% ifequal vm.status 3 %}
<button class="btn btn-sm btn-default" type="submit" name="resume"
title="{% trans "Resume" %}">
<span class="glyphicon glyphicon-play"></span>
</button>
<button class="btn btn-sm btn-default disabled" title="{% trans "Suspend" %}">
<span class="glyphicon glyphicon-pause"></span>
</button>
<button class="btn btn-sm btn-default disabled" title="{% trans "Destroy" %}">
<span class="glyphicon glyphicon-stop"></span>
</button>
<button class="btn btn-sm btn-default disabled" title="{% trans "Console" %}">
<span class="glyphicon glyphicon-eye-open"></span>
</button>
{% endifequal %}
{% ifequal vm.status 1 %}
<button class="btn btn-sm btn-default disabled" title="{% trans "Start" %}">
<span class="glyphicon glyphicon-play"></span>
</button>
<button class="btn btn-sm btn-default" type="submit" name="suspend"
title="{% trans "Suspend" %}">
<span class="glyphicon glyphicon-pause"></span>
</button>
<button class="btn btn-sm btn-default" type="submit" name="destroy"
title="{% trans "Destroy" %}" onclick="return confirm('Are you sure?')">
<span class="glyphicon glyphicon-stop"></span>
</button>
<a href="#" class="btn btn-sm btn-default"
onclick='open_console("{{ host.0 }}-{{ vm.uuid }}")' title="{% trans "Console" %}">
<span class="glyphicon glyphicon-eye-open"></span>
</a>
{% endifequal %}
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %} {% endif %}
</div> </div>
</div> </div>

View file

@ -29,7 +29,7 @@
<tr> <tr>
<th>#</th> <th>#</th>
<th>{% trans "Name" %}</th> <th>{% trans "Name" %}</th>
<th>{% trans "Is blocked" %}</th> <th>{% trans "User blocked" %}</th>
<th>{% trans "Can change" %}</th> <th>{% trans "Can change" %}</th>
<th>{% trans "Can delete" %}</th> <th>{% trans "Can delete" %}</th>
<th colspan="2">{% trans "Action" %}</th> <th colspan="2">{% trans "Action" %}</th>

View file

@ -195,6 +195,7 @@ class wvmInstance(wvmConnect):
storage = None storage = None
src_fl = None src_fl = None
disk_format = None disk_format = None
disk_size = None
for disk in ctx.xpathEval('/domain/devices/disk'): for disk in ctx.xpathEval('/domain/devices/disk'):
device = disk.xpathEval('@device')[0].content device = disk.xpathEval('@device')[0].content
if device == 'disk': if device == 'disk':