1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-11-01 03:54:15 +00:00

network qos adding, listing, backend revamped. Add network bug for nat networks solved

This commit is contained in:
catborise 2019-11-20 08:42:09 +03:00
parent 5282d3e556
commit d7f283f089
2 changed files with 65 additions and 61 deletions

View file

@ -339,59 +339,61 @@
</div>
{% endif %}
{% ifequal state 0 %}
{% include 'add_outbound_qos.html' %}
{% include 'add_inbound_qos.html' %}
{% endifequal %}
{% if net_forward.0 == 'route' or net_forward.0 == 'nat' or net_forward.0 == 'isolated' %}
{% if state == 0 and qos.items|length != 2%}
<form class="form-horizontal" method="post" name="set_qos" role="form">{% csrf_token %}
{% include 'add_network_qos.html' %}
</form>
{% endif %}
<div class="row">
<h3 class="page-header">{% trans "Qos Configuration" %}
</h3>
</div>
<div class="row">
<div class="col-sm-12">
<table class="table table-hover">
<thead>
<tr>
<th style="text-align: center">{% trans "Direction" %}</th>
<th style="text-align: center">{% trans "Average" %}</th>
<th style="text-align: center">{% trans "Peak" %}</th>
<th style="text-align: center">{% trans "Burst" %}</th>
<th style="text-align: center">{% trans "Actions" %}</th>
</tr>
</thead>
<tbody>
{% for q, att in qos.items %}
<form method="post" role="form">{% csrf_token %}
<tr>
<td><label class="control-label">{{ q | capfirst }}</label></td>
<td><input id="qos_{{ q }}_av" class="form-control" name="qos_{{ q }}_average"
value="{{ att.average }}"/></td>
<td><input id="qos_{{ q }}_peak" class="form-control" name="qos_{{ q }}_peak"
value="{{ att.peak }}"/></td>
<td><input id="qos_{{ q }}_burst" class="form-control" name="qos_{{ q }}_burst"
value="{{ att.burst }}"/></td>
<td>
<input name="qos_direction" value="{{ q }}" hidden/>
<button type="submit" class="btn btn-sm btn-primary"
name="set_qos"
title="Edit Qos" onclick="return confirm('{% trans "Are you sure?" %}')">
<i class="glyphicon glyphicon-save"></i>
</button>
<button type="submit" class="btn btn-sm btn-danger"
name="unset_qos"
title="Delete Qos" onclick="return confirm('{% trans "Are you sure?" %}')">
<i class="glyphicon glyphicon-trash"></i>
</button>
</td>
</tr>
</form>
{% endfor %}
</tbody>
</table>
<div class="row">
<h3 class="page-header">{% trans "Qos Configuration" %}</h3>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<table class="table table-hover">
<thead>
<tr>
<th style="text-align: center">{% trans "Direction" %}</th>
<th style="text-align: center">{% trans "Average" %}</th>
<th style="text-align: center">{% trans "Peak" %}</th>
<th style="text-align: center">{% trans "Burst" %}</th>
<th style="text-align: center">{% trans "Actions" %}</th>
</tr>
</thead>
<tbody>
{% for q, att in qos.items %}
<form method="post" role="form">{% csrf_token %}
<tr>
<td><label class="control-label">{{ q | capfirst }}</label></td>
<td><input id="qos_average" class="form-control" name="qos_average"
value="{{ att.average|default:'' }}"/></td>
<td><input id="qos_peak" class="form-control" name="qos_peak"
value="{{ att.peak|default:'' }}"/></td>
<td><input id="qos_burst" class="form-control" name="qos_burst"
value="{{ att.burst|default:'' }}"/></td>
<td>
<input name="qos_direction" value="{{ q }}" hidden/>
<button type="submit" class="btn btn-sm btn-primary"
name="set_qos" data-toggle="modal"
title="Edit Qos" onclick="return confirm('{% trans "Are you sure?" %}')">
<i class="glyphicon glyphicon-save"></i>
</button>
<button type="submit" class="btn btn-sm btn-danger"
name="unset_qos"
title="Delete Qos" onclick="return confirm('{% trans "Are you sure?" %}')">
<i class="glyphicon glyphicon-trash"></i>
</button>
</td>
</tr>
</form>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endif %}
{% endblock %}
{% block script %}
<script>

View file

@ -195,19 +195,21 @@ def network(request, compute_id, pool):
else:
messages.success(request, _("Network XML is changed."))
return HttpResponseRedirect(request.get_full_path())
if 'set_qos' in request.POST:
qos_dir = request.POST.get('qos_direction', '')
average = request.POST.get('qos_{}_average'.format(qos_dir), '')
peak = request.POST.get('qos_{}_peak'.format(qos_dir), '')
burst = request.POST.get('qos_{}_burst'.format(qos_dir), '')
average = request.POST.get('qos_average') or 0
peak = request.POST.get('qos_peak') or 0
burst = request.POST.get('qos_burst') or 0
conn.set_qos(qos_dir, average, peak, burst)
if conn.is_active():
messages.success(request, "{} Qos is set. Network XML is changed.".format(qos_dir.capitalize()) +
"Stop and start network to activate new config")
else:
messages.success(request, "{} Qos is set".format(qos_dir.capitalize()))
try:
conn.set_qos(qos_dir, average, peak, burst)
if conn.is_active():
messages.success(request, "{} Qos is set. Network XML is changed.".format(qos_dir.capitalize()) +
"Stop and start network to activate new config")
else:
messages.success(request, "{} Qos is set".format(qos_dir.capitalize()))
except libvirtError as le:
messages.error(request, le.message)
return HttpResponseRedirect(request.get_full_path())
if 'unset_qos' in request.POST:
qos_dir = request.POST.get('qos_direction', '')