1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-12-24 23:25:24 +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> </div>
{% endif %} {% endif %}
{% ifequal state 0 %} {% if net_forward.0 == 'route' or net_forward.0 == 'nat' or net_forward.0 == 'isolated' %}
{% include 'add_outbound_qos.html' %} {% if state == 0 and qos.items|length != 2%}
{% include 'add_inbound_qos.html' %} <form class="form-horizontal" method="post" name="set_qos" role="form">{% csrf_token %}
{% endifequal %} {% include 'add_network_qos.html' %}
</form>
{% endif %}
<div class="row"> <div class="row">
<h3 class="page-header">{% trans "Qos Configuration" %} <h3 class="page-header">{% trans "Qos Configuration" %}</h3>
</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> </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 %} {% endblock %}
{% block script %} {% block script %}
<script> <script>

View file

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