mirror of
https://github.com/retspen/webvirtcloud
synced 2024-12-23 22:55:23 +00:00
Volumes list allocation info added. While creating image files it is recommended username and group name info. Storage.html does not show messages. messages section added
This commit is contained in:
parent
2585e64cfd
commit
4126ad2591
2 changed files with 218 additions and 210 deletions
|
@ -6,220 +6,223 @@
|
|||
<link rel="stylesheet" href="{% static "css/sortable-theme-bootstrap.css" %}" />
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<!-- Page Heading -->
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
{% include 'create_stg_vol_block.html' %}
|
||||
<h1 class="page-header">{% trans "Storage:" %} {{ pool }}</h1>
|
||||
<ol class="breadcrumb">
|
||||
<li class="active">
|
||||
<i class="fa fa-dashboard"></i> <a href="{% url 'overview' compute.id %}">{% trans "Overview" %}</a>
|
||||
</li>
|
||||
<li>
|
||||
<i class="fa fa-hdd-o"></i> <a href="{% url 'storages' compute.id %}">{% trans "Storages" %}</a>
|
||||
</li>
|
||||
<li>
|
||||
<i class="fa fa-sitemap"></i> <a href="{% url 'networks' compute.id %}">{% trans "Networks" %}</a>
|
||||
</li>
|
||||
<li>
|
||||
<i class="fa fa-wifi"></i> <a href="{% url 'interfaces' compute.id %}">{% trans "Interfaces" %}</a>
|
||||
</li>
|
||||
<li>
|
||||
<i class="fa fa-key"></i> <a href="{% url 'secrets' compute.id %}">{% trans "Secrets" %}</a>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
<!-- Page Heading -->
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
{% include 'create_stg_vol_block.html' %}
|
||||
<h1 class="page-header">{% trans "Storage:" %} {{ pool }}</h1>
|
||||
<ol class="breadcrumb">
|
||||
<li class="active">
|
||||
<i class="fa fa-dashboard"></i> <a href="{% url 'overview' compute.id %}">{% trans "Overview" %}</a>
|
||||
</li>
|
||||
<li>
|
||||
<i class="fa fa-hdd-o"></i> <a href="{% url 'storages' compute.id %}">{% trans "Storages" %}</a>
|
||||
</li>
|
||||
<li>
|
||||
<i class="fa fa-sitemap"></i> <a href="{% url 'networks' compute.id %}">{% trans "Networks" %}</a>
|
||||
</li>
|
||||
<li>
|
||||
<i class="fa fa-wifi"></i> <a href="{% url 'interfaces' compute.id %}">{% trans "Interfaces" %}</a>
|
||||
</li>
|
||||
<li>
|
||||
<i class="fa fa-key"></i> <a href="{% url 'secrets' compute.id %}">{% trans "Secrets" %}</a>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.row -->
|
||||
|
||||
{% include 'errors_block.html' %}
|
||||
{% include 'messages_block.html' %}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-6 col-sm-6">
|
||||
<p>{% trans "Pool name:" %}</p>
|
||||
<p>{% trans "Pool type:" %}</p>
|
||||
<p>{% trans "Pool path:" %}</p>
|
||||
<p>{% trans "Pool status:" %}</p>
|
||||
<p>{% trans "Size:" %} ({{ size|filesizeformat }} / {{ used|filesizeformat }})</p>
|
||||
<p>{% trans "State:" %}</p>
|
||||
<p>{% trans "Autostart:" %}</p>
|
||||
</div>
|
||||
<div class="col-xs-6 col-sm-6">
|
||||
<p>{{ pool }}</p>
|
||||
<p>{% if not type %}{% trans "None" %}{% else %}{{ type }}{% endif %}</p>
|
||||
<p>{% if not path %}{% trans "None" %}{% else %}{{ path }}{% endif %}</p>
|
||||
<p>{% if not status %}{% trans "None" %}{% else %}{{ status }}{% endif %}</p>
|
||||
<p>{% trans "Usage:" %} {{ percent }}%</p>
|
||||
<p>
|
||||
<form action="" method="post" role="form">{% csrf_token %}
|
||||
{% ifequal state 0 %}
|
||||
<input type="submit" class="btn btn-xs btn-default" name="start" value="{% trans "Start" %}">
|
||||
<input type="submit" class="btn btn-xs btn-default" name="delete" value="{% trans "Delete" %}"
|
||||
onclick="return confirm('{% trans "Are you sure?" %}')">
|
||||
{% else %}
|
||||
<input type="submit" class="btn btn-xs btn-default" name="stop" value="{% trans "Stop" %}"
|
||||
onclick="return confirm('{% trans "Are you sure?" %}')">
|
||||
{% endifequal %}
|
||||
</form>
|
||||
</p>
|
||||
<p>
|
||||
<form action="" method="post" role="form">{% csrf_token %}
|
||||
{% ifequal autostart 0 %}
|
||||
<input type="submit" class="btn btn-xs btn-default" name="set_autostart"
|
||||
value="{% trans "Enable" %}">
|
||||
{% else %}
|
||||
<input type="submit" class="btn btn-xs btn-default" name="unset_autostart"
|
||||
onclick="return confirm('{% trans "Are you sure?" %}')" value="{% trans "Disable" %}">
|
||||
{% endifequal %}
|
||||
</form>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
{% if state %}
|
||||
<div class="row">
|
||||
<div class="pull-right">
|
||||
<input id="filter" class="form-control" type="text" placeholder="Search">
|
||||
</div>
|
||||
<!-- /.row -->
|
||||
<h3 class="page-header">{% trans "Volumes" %}</h3>
|
||||
|
||||
{% include 'errors_block.html' %}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-6 col-sm-6">
|
||||
<p>{% trans "Pool name:" %}</p>
|
||||
<p>{% trans "Pool type:" %}</p>
|
||||
<p>{% trans "Pool path:" %}</p>
|
||||
<p>{% trans "Pool status:" %}</p>
|
||||
<p>{% trans "Size:" %} ({{ size|filesizeformat }} / {{ used|filesizeformat }})</p>
|
||||
<p>{% trans "State:" %}</p>
|
||||
<p>{% trans "Autostart:" %}</p>
|
||||
</div>
|
||||
<div class="col-xs-6 col-sm-6">
|
||||
<p>{{ pool }}</p>
|
||||
<p>{% if not type %}{% trans "None" %}{% else %}{{ type }}{% endif %}</p>
|
||||
<p>{% if not path %}{% trans "None" %}{% else %}{{ path }}{% endif %}</p>
|
||||
<p>{% if not status %}{% trans "None" %}{% else %}{{ status }}{% endif %}</p>
|
||||
<p>{% trans "Usage:" %} {{ percent }}%</p>
|
||||
<p>
|
||||
<form action="" method="post" role="form">{% csrf_token %}
|
||||
{% ifequal state 0 %}
|
||||
<input type="submit" class="btn btn-xs btn-default" name="start" value="{% trans "Start" %}">
|
||||
<input type="submit" class="btn btn-xs btn-default" name="delete" value="{% trans "Delete" %}"
|
||||
onclick="return confirm('{% trans "Are you sure?" %}')">
|
||||
{% else %}
|
||||
<input type="submit" class="btn btn-xs btn-default" name="stop" value="{% trans "Stop" %}"
|
||||
onclick="return confirm('{% trans "Are you sure?" %}')">
|
||||
{% endifequal %}
|
||||
</div>
|
||||
{% if volumes %}
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped sortable-theme-bootstrap" data-sortable>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 45px;">#</th>
|
||||
<th>{% trans "Name" %}</th>
|
||||
<th>{% trans "Allocated" %}</th>
|
||||
<th>{% trans "Size" %}</th>
|
||||
<th>{% trans "Format" %}</th>
|
||||
<th data-sortable="false" colspan="2">{% trans "Action" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="searchable">
|
||||
{% for volume in volumes %}
|
||||
<tr>
|
||||
<td>{{ forloop.counter }}</td>
|
||||
<td>{{ volume.name }}</td>
|
||||
<td>{{ volume.allocation|filesizeformat }}</td>
|
||||
<td>{{ volume.size|filesizeformat }}</td>
|
||||
<td>{{ volume.type }}</td>
|
||||
<td style="width:30px;">
|
||||
<!-- Modal Clone -->
|
||||
<div class="modal fade" id="Clone{{ forloop.counter }}" tabindex="-1" role="dialog"
|
||||
aria-labelledby="addHostLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title">{% trans "Clone image" %} <span class="text-danger">{{ volume.name }}</span></h4>
|
||||
</div>
|
||||
<form class="form-horizontal" method="post" role="form">{% csrf_token %}
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Name" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" name="name" placeholder="{% trans "Name" %}" required pattern="[a-zA-Z0-9\.\-_]+">
|
||||
<input type="hidden" name="image" value="{{ volume.name }}">
|
||||
</div>
|
||||
<label class="col-sm-1 control-label">.img</label>
|
||||
</div>
|
||||
<div class="form-group" id="image_format">
|
||||
<label class="col-sm-3 control-label">{% trans "Convert" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input class="volume-convert" type="checkbox" name="convert" value="true">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group format-convert">
|
||||
<label class="col-sm-3 control-label">{% trans "Format" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<select name="format" class="form-control image-format">
|
||||
<option value="raw">{% trans "raw" %}</option>
|
||||
<option value="qcow">{% trans "qcow" %}</option>
|
||||
<option value="qcow2">{% trans "qcow2" %}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group meta-prealloc" style="display: none;">
|
||||
<label class="col-sm-3 control-label">{% trans "Metadata" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="checkbox" name="meta_prealloc" value="true">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">{% trans "Close" %}</button>
|
||||
<button type="submit" class="btn btn-primary" name="cln_volume">{% trans "Clone" %}</button>
|
||||
</div>
|
||||
</form>
|
||||
</div> <!-- /.modal-content -->
|
||||
</div> <!-- /.modal-dialog -->
|
||||
</div> <!-- /.modal -->
|
||||
{% ifnotequal volume.type "iso" %}
|
||||
<a data-toggle="modal" href="#Clone{{ forloop.counter }}" class="btn btn-sm btn-default" title="{% trans "Clone" %}"><i class="fa fa-files-o"></i></a>
|
||||
{% else %}
|
||||
<a class="btn btn-sm btn-default disabled"><i class="fa fa-files-o"></i></a>
|
||||
{% endifnotequal %}
|
||||
</td>
|
||||
<td style="width:30px;">
|
||||
<form action="" method="post" style="height:10px" role="form">{% csrf_token %}
|
||||
<input type="hidden" name="volname" value="{{ volume.name }}">
|
||||
<button type="submit" class="btn btn-sm btn-default" name="del_volume" title="{% trans "Delete" %}" onclick="return confirm('{% trans "Are you sure?" %}')">
|
||||
<i class="fa fa-trash"></i>
|
||||
</button>
|
||||
</form>
|
||||
</p>
|
||||
<p>
|
||||
<form action="" method="post" role="form">{% csrf_token %}
|
||||
{% ifequal autostart 0 %}
|
||||
<input type="submit" class="btn btn-xs btn-default" name="set_autostart"
|
||||
value="{% trans "Enable" %}">
|
||||
{% else %}
|
||||
<input type="submit" class="btn btn-xs btn-default" name="unset_autostart"
|
||||
onclick="return confirm('{% trans "Are you sure?" %}')" value="{% trans "Disable" %}">
|
||||
{% endifequal %}
|
||||
</form>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
{% if state %}
|
||||
<div class="row">
|
||||
<div class="pull-right">
|
||||
<input id="filter" class="form-control" type="text" placeholder="Search">
|
||||
</div>
|
||||
<h3 class="page-header">{% trans "Volumes" %}</h3>
|
||||
|
||||
</div>
|
||||
{% if volumes %}
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped sortable-theme-bootstrap" data-sortable>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 45px;">#</th>
|
||||
<th>{% trans "Name" %}</th>
|
||||
<th>{% trans "Size" %}</th>
|
||||
<th>{% trans "Format" %}</th>
|
||||
<th data-sortable="false" colspan="2">{% trans "Action" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="searchable">
|
||||
{% for volume in volumes %}
|
||||
<tr>
|
||||
<td>{{ forloop.counter }}</td>
|
||||
<td>{{ volume.name }}</td>
|
||||
<td>{{ volume.size|filesizeformat }}</td>
|
||||
<td>{{ volume.type }}</td>
|
||||
<td style="width:30px;">
|
||||
<!-- Modal Clone -->
|
||||
<div class="modal fade" id="Clone{{ forloop.counter }}" tabindex="-1" role="dialog"
|
||||
aria-labelledby="addHostLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title">{% trans "Clone image" %} <span class="text-danger">{{ volume.name }}</span></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form class="form-horizontal" method="post" role="form">{% csrf_token %}
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Name" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" name="name" placeholder="{% trans "Name" %}" required pattern="[a-zA-Z0-9\.\-_]+">
|
||||
<input type="hidden" name="image" value="{{ volume.name }}">
|
||||
</div>
|
||||
<label class="col-sm-1 control-label">.img</label>
|
||||
</div>
|
||||
<div class="form-group" id="image_format">
|
||||
<label class="col-sm-3 control-label">{% trans "Convert" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input class="volume-convert" type="checkbox" name="convert" value="true">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group format-convert">
|
||||
<label class="col-sm-3 control-label">{% trans "Format" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<select name="format" class="form-control image-format">
|
||||
<option value="raw">{% trans "raw" %}</option>
|
||||
<option value="qcow">{% trans "qcow" %}</option>
|
||||
<option value="qcow2">{% trans "qcow2" %}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group meta-prealloc" style="display: none;">
|
||||
<label class="col-sm-3 control-label">{% trans "Metadata" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="checkbox" name="meta_prealloc" value="true">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">{% trans "Close" %}</button>
|
||||
<button type="submit" class="btn btn-primary" name="cln_volume">{% trans "Clone" %}</button>
|
||||
</div>
|
||||
</form>
|
||||
</div> <!-- /.modal-content -->
|
||||
</div> <!-- /.modal-dialog -->
|
||||
</div> <!-- /.modal -->
|
||||
{% ifnotequal volume.type "iso" %}
|
||||
<a data-toggle="modal" href="#Clone{{ forloop.counter }}" class="btn btn-sm btn-default" title="{% trans "Clone" %}"><i class="fa fa-files-o"></i></a>
|
||||
{% else %}
|
||||
<a class="btn btn-sm btn-default disabled"><i class="fa fa-files-o"></i></a>
|
||||
{% endifnotequal %}
|
||||
</td>
|
||||
<td style="width:30px;">
|
||||
<form action="" method="post" style="height:10px" role="form">{% csrf_token %}
|
||||
<input type="hidden" name="volname" value="{{ volume.name }}">
|
||||
<button type="submit" class="btn btn-sm btn-default" name="del_volume" title="{% trans "Delete" %}" onclick="return confirm('{% trans "Are you sure?" %}')">
|
||||
<i class="fa fa-trash"></i>
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% else %}
|
||||
<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 "Hypervisor doesn't have any Volumes" %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% else %}
|
||||
<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 "Hypervisor doesn't have any Volumes" %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block script %}
|
||||
<script src="{% static "js/sortable.min.js" %}"></script>
|
||||
<script>
|
||||
$('.format-convert').hide();
|
||||
$(document).on('change', '.volume-convert', function () {
|
||||
if ($(this).prop('checked')) {
|
||||
$('.format-convert').show();
|
||||
if ($('.image-format').val() == 'qcow2') {
|
||||
$('.meta-prealloc').show();
|
||||
<script src="{% static "js/sortable.min.js" %}"></script>
|
||||
<script>
|
||||
$('.format-convert').hide();
|
||||
$(document).on('change', '.volume-convert', function () {
|
||||
if ($(this).prop('checked')) {
|
||||
$('.format-convert').show();
|
||||
if ($('.image-format').val() == 'qcow2') {
|
||||
$('.meta-prealloc').show();
|
||||
}
|
||||
} else {
|
||||
$('.format-convert').hide();
|
||||
$('.meta-prealloc').hide();
|
||||
}
|
||||
} else {
|
||||
$('.format-convert').hide();
|
||||
$('.meta-prealloc').hide();
|
||||
}
|
||||
});
|
||||
$(document).on('change', '.image-format', function () {
|
||||
if ($(this).val() == "qcow2") {
|
||||
$('.meta-prealloc').show();
|
||||
} else {
|
||||
$('.meta-prealloc').hide();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
(function ($) {
|
||||
$('#filter').keyup(function () {
|
||||
var rex = new RegExp($(this).val(), 'i');
|
||||
$('.searchable tr').hide();
|
||||
$('.searchable tr').filter(function () {
|
||||
return rex.test($(this).text());
|
||||
}).show();
|
||||
})
|
||||
}(jQuery));
|
||||
});
|
||||
</script>
|
||||
});
|
||||
$(document).on('change', '.image-format', function () {
|
||||
if ($(this).val() == "qcow2") {
|
||||
$('.meta-prealloc').show();
|
||||
} else {
|
||||
$('.meta-prealloc').hide();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
(function ($) {
|
||||
$('#filter').keyup(function () {
|
||||
var rex = new RegExp($(this).val(), 'i');
|
||||
$('.searchable tr').hide();
|
||||
$('.searchable tr').filter(function () {
|
||||
return rex.test($(this).text());
|
||||
}).show();
|
||||
})
|
||||
}(jQuery));
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
|
@ -7,7 +7,7 @@ from computes.models import Compute
|
|||
from storages.forms import AddStgPool, AddImage, CloneImage
|
||||
from vrtManager.storage import wvmStorage, wvmStorages
|
||||
from libvirt import libvirtError
|
||||
|
||||
from django.contrib import messages
|
||||
|
||||
@login_required
|
||||
def storages(request, compute_id):
|
||||
|
@ -155,6 +155,7 @@ def storage(request, compute_id, pool):
|
|||
meta_prealloc = True
|
||||
try:
|
||||
conn.create_volume(data['name'], data['size'], data['format'], meta_prealloc)
|
||||
messages.success("Image file {} is created successfully".format(data['name']+".img"))
|
||||
return HttpResponseRedirect(request.get_full_path())
|
||||
except libvirtError as lib_err:
|
||||
error_messages.append(lib_err)
|
||||
|
@ -166,6 +167,7 @@ def storage(request, compute_id, pool):
|
|||
try:
|
||||
vol = conn.get_volume(volname)
|
||||
vol.delete(0)
|
||||
messages.success(request,_('Volume: {} is deleted.'.format(volname)))
|
||||
return HttpResponseRedirect(request.get_full_path())
|
||||
except libvirtError as lib_err:
|
||||
error_messages.append(lib_err.message)
|
||||
|
@ -175,6 +177,7 @@ def storage(request, compute_id, pool):
|
|||
error_messages.append(error_msg)
|
||||
else:
|
||||
handle_uploaded_file(path, request.FILES['file'])
|
||||
messages.success(request, _('ISO: {} is uploaded.'.format(request.FILES['file'])))
|
||||
return HttpResponseRedirect(request.get_full_path())
|
||||
if 'cln_volume' in request.POST:
|
||||
form = CloneImage(request.POST)
|
||||
|
@ -194,6 +197,8 @@ def storage(request, compute_id, pool):
|
|||
format = None
|
||||
try:
|
||||
conn.clone_volume(data['image'], data['name'], format, meta_prealloc)
|
||||
messages.success(request, _("{} image cloned as {} successfully".format(data['image'],
|
||||
data['name'] + ".img")))
|
||||
return HttpResponseRedirect(request.get_full_path())
|
||||
except libvirtError as lib_err:
|
||||
error_messages.append(lib_err)
|
||||
|
|
Loading…
Reference in a new issue