mirror of
https://github.com/retspen/webvirtcloud
synced 2024-12-23 22:55:23 +00:00
Users permission
This commit is contained in:
parent
b98084b7ee
commit
983dbaf91a
5 changed files with 270 additions and 225 deletions
|
@ -106,6 +106,24 @@ def instance(request, compute_id, vname):
|
|||
if not request.user.is_authenticated():
|
||||
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):
|
||||
clone_disk = []
|
||||
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']})
|
||||
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:
|
||||
conn = wvmInstance(compute.hostname,
|
||||
compute.login,
|
||||
|
@ -164,21 +174,17 @@ def instance(request, compute_id, vname):
|
|||
has_managed_save_image = conn.get_managed_save_image()
|
||||
clone_disks = show_clone_disk(disks)
|
||||
console_passwd = conn.get_console_passwd()
|
||||
except libvirtError as lib_err:
|
||||
error_messages.append(lib_err)
|
||||
|
||||
try:
|
||||
instance = Instance.objects.get(compute_id=compute_id, name=vname)
|
||||
if instance.uuid != uuid:
|
||||
instance.uuid = uuid
|
||||
try:
|
||||
instance = Instance.objects.get(compute_id=compute_id, name=vname)
|
||||
if instance.uuid != uuid:
|
||||
instance.uuid = uuid
|
||||
instance.save()
|
||||
except Instance.DoesNotExist:
|
||||
instance = Instance(compute_id=compute_id, name=vname, uuid=uuid)
|
||||
instance.save()
|
||||
except Instance.DoesNotExist:
|
||||
instance = Instance(compute_id=compute_id, name=vname, uuid=uuid)
|
||||
instance.save()
|
||||
|
||||
try:
|
||||
if request.method == 'POST':
|
||||
|
||||
if 'poweron' in request.POST:
|
||||
conn.start()
|
||||
return HttpResponseRedirect(request.get_full_path() + '#poweron')
|
||||
|
@ -209,8 +215,17 @@ def instance(request, compute_id, vname):
|
|||
if request.POST.get('delete_disk', ''):
|
||||
conn.delete_disk()
|
||||
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()
|
||||
return HttpResponseRedirect(reverse('instances', args=[compute_id]))
|
||||
return HttpResponseRedirect(reverse('instances'))
|
||||
|
||||
if 'snapshot' in request.POST:
|
||||
name = request.POST.get('name', '')
|
||||
|
@ -330,7 +345,7 @@ def instance(request, compute_id, vname):
|
|||
|
||||
conn.close()
|
||||
|
||||
except libvirtError as err:
|
||||
error_messages.append(err)
|
||||
except libvirtError as lib_err:
|
||||
error_messages.append(lib_err)
|
||||
|
||||
return render(request, 'instance.html', locals())
|
|
@ -7,6 +7,26 @@
|
|||
<div class="col-lg-12">
|
||||
<h1 class="page-header">{{ vname }}</h1>
|
||||
</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>
|
||||
<!-- /.row -->
|
||||
|
||||
|
@ -14,26 +34,6 @@
|
|||
|
||||
<div class="row" id="max-width-page">
|
||||
<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">
|
||||
<!-- Nav tabs -->
|
||||
<ul class="nav nav-pills" role="tablist">
|
||||
|
@ -97,11 +97,13 @@
|
|||
{% trans "Power Off" %}
|
||||
</a>
|
||||
</li>
|
||||
<li role="presentation">
|
||||
<a href="#suspend" aria-controls="suspend" role="tab" data-toggle="tab">
|
||||
{% trans "Suspend" %}
|
||||
</a>
|
||||
</li>
|
||||
{% if status %}
|
||||
<li role="presentation">
|
||||
<a href="#suspend" aria-controls="suspend" role="tab" data-toggle="tab">
|
||||
{% trans "Suspend" %}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endifequal %}
|
||||
{% ifequal status 3 %}
|
||||
<li role="presentation" class="active">
|
||||
|
@ -201,67 +203,72 @@
|
|||
<!-- Tab panes -->
|
||||
<div class="tab-content">
|
||||
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="resizevm">
|
||||
<form class="form-horizontal" method="post" role="form">{% csrf_token %}
|
||||
<p style="font-weight:bold;">{% trans "Logical host CPUs:" %} {{ vcpu_host }}</p>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label" style="font-weight:normal;"> {% trans "Current allocation" %}</label>
|
||||
<div class="col-sm-4">
|
||||
<select name="cur_vcpu" class="form-control">
|
||||
{% for cpu in vcpu_range %}
|
||||
{% if cur_vcpu %}
|
||||
<option value="{{ cpu }}" {% if cpu == cur_vcpu %}selected{% endif %}>{{ cpu }}</option>
|
||||
{% else %}
|
||||
{% if request.user.is_superuser or userinstace.is_change %}
|
||||
<form class="form-horizontal" method="post" role="form">{% csrf_token %}
|
||||
<p style="font-weight:bold;">{% trans "Logical host CPUs:" %} {{ vcpu_host }}</p>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label" style="font-weight:normal;"> {% trans "Current allocation" %}</label>
|
||||
<div class="col-sm-4">
|
||||
<select name="cur_vcpu" class="form-control">
|
||||
{% for cpu in vcpu_range %}
|
||||
{% if cur_vcpu %}
|
||||
<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>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</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>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<p style="font-weight:bold;">{% trans "Total host memory:" %} {{ memory_host|filesizeformat }}</p>
|
||||
<div class="form-group">
|
||||
<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>
|
||||
<p style="font-weight:bold;">{% trans "Total host memory:" %} {{ memory_host|filesizeformat }}</p>
|
||||
<div class="form-group">
|
||||
<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="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">
|
||||
<select name="memory" class="form-control js-custom__toggle">
|
||||
{% for mem in memory_range %}
|
||||
<option value="{{ mem }}"
|
||||
{% if mem == memory %}selected{% endif %}>{{ mem }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<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>
|
||||
<div class="col-sm-4 js-custom__container">
|
||||
<select name="memory" class="form-control js-custom__toggle">
|
||||
{% for mem in memory_range %}
|
||||
<option value="{{ mem }}"
|
||||
{% if mem == memory %}selected{% endif %}>{{ mem }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% ifequal status 5 %}
|
||||
<button type="submit" class="btn btn-lg btn-success pull-right" name="resize">{% trans "Resize" %}</button>
|
||||
{% else %}
|
||||
<button class="btn btn-lg btn-success pull-right disabled">{% trans "Resize" %}</button>
|
||||
{% endifequal %}
|
||||
</form>
|
||||
{% ifequal status 5 %}
|
||||
<button type="submit" class="btn btn-lg btn-success pull-right" name="resize">{% trans "Resize" %}</button>
|
||||
{% else %}
|
||||
<button class="btn btn-lg btn-success pull-right disabled">{% trans "Resize" %}</button>
|
||||
{% endifequal %}
|
||||
</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>
|
||||
</div>
|
||||
|
@ -685,15 +692,19 @@
|
|||
<div class="tab-content">
|
||||
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="destroy">
|
||||
<p>{% trans "Delete storage for instance?" %}</p>
|
||||
<form class="form-group" method="post" role="form">{% csrf_token %}
|
||||
<div class="checkbox" style="margin-left: 8px;">
|
||||
<label>
|
||||
<input type="checkbox" name="delete_disk" value="true">
|
||||
<strong>{% trans "Remove Instance's data" %}</strong>
|
||||
</label>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-lg btn-success pull-right" name="delete">{% trans "Destroy" %}</button>
|
||||
</form>
|
||||
{% if request.user.is_superuser or userinstace.is_delete %}
|
||||
<form class="form-group" method="post" role="form">{% csrf_token %}
|
||||
<div class="checkbox" style="margin-left: 8px;">
|
||||
<label>
|
||||
<input type="checkbox" name="delete_disk" value="true">
|
||||
<strong>{% trans "Remove Instance's data" %}</strong>
|
||||
</label>
|
||||
</div>
|
||||
<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>
|
||||
</div>
|
||||
|
|
|
@ -23,39 +23,138 @@
|
|||
<div class="col-lg-12">
|
||||
<div class="table-responsive">
|
||||
{% if request.user.is_superuser %}
|
||||
<table class="table table-hover table-striped sortable-theme-bootstrap" data-sortable>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Host</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 host, inst in all_host_vms.items %}
|
||||
{% for vm, info in inst.items %}
|
||||
{% if not all_host_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>Host</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 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>
|
||||
<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 %}
|
||||
<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 info.status 5 %}
|
||||
{% ifequal vm.status 5 %}
|
||||
<p class="text-danger">{% trans "Off" %}</p>
|
||||
{% endifequal %}
|
||||
{% ifequal info.status 3 %}
|
||||
{% ifequal vm.status 3 %}
|
||||
<p class="text-warning">{% trans "Suspend" %}</p>
|
||||
{% endifequal %}
|
||||
</td>
|
||||
<td>{{ info.vcpu }}</td>
|
||||
<td>{{ info.memory }} {% trans "MB" %}</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 }}"/>
|
||||
<input type="hidden" name="compute_id" value="{{ host.0 }}"/>
|
||||
{% ifequal info.status 5 %}
|
||||
<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>
|
||||
|
@ -69,7 +168,7 @@
|
|||
<span class="glyphicon glyphicon-eye-open"></span>
|
||||
</button>
|
||||
{% endifequal %}
|
||||
{% ifequal info.status 3 %}
|
||||
{% ifequal vm.status 3 %}
|
||||
<button class="btn btn-sm btn-default" type="submit" name="resume"
|
||||
title="{% trans "Resume" %}">
|
||||
<span class="glyphicon glyphicon-play"></span>
|
||||
|
@ -84,7 +183,7 @@
|
|||
<span class="glyphicon glyphicon-eye-open"></span>
|
||||
</button>
|
||||
{% endifequal %}
|
||||
{% ifequal info.status 1 %}
|
||||
{% ifequal vm.status 1 %}
|
||||
<button class="btn btn-sm btn-default disabled" title="{% trans "Start" %}">
|
||||
<span class="glyphicon glyphicon-play"></span>
|
||||
</button>
|
||||
|
@ -96,7 +195,8 @@
|
|||
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" %}">
|
||||
<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 %}
|
||||
|
@ -104,91 +204,9 @@
|
|||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% 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>
|
||||
</tbody>
|
||||
</table>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
<tr>
|
||||
<th>#</th>
|
||||
<th>{% trans "Name" %}</th>
|
||||
<th>{% trans "Is blocked" %}</th>
|
||||
<th>{% trans "User blocked" %}</th>
|
||||
<th>{% trans "Can change" %}</th>
|
||||
<th>{% trans "Can delete" %}</th>
|
||||
<th colspan="2">{% trans "Action" %}</th>
|
||||
|
|
|
@ -195,6 +195,7 @@ class wvmInstance(wvmConnect):
|
|||
storage = None
|
||||
src_fl = None
|
||||
disk_format = None
|
||||
disk_size = None
|
||||
for disk in ctx.xpathEval('/domain/devices/disk'):
|
||||
device = disk.xpathEval('@device')[0].content
|
||||
if device == 'disk':
|
||||
|
|
Loading…
Reference in a new issue