mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-02 08:56:07 +00:00
Plan reviewed with Codex; libvirt's behaviour checked on a host. - A filter is not deleted while a VM's interface references it, as the VM runs or as saved for its next boot (a stopped VM too), or while another filter references it: libvirt refuses only one a running VM uses, and a VM using a filter that references a deleted one does not start. The VMs are read from one listing, one or two XML reads each, instead of a connection per VM; the refusal names them. - Create refuses a name or UUID the host has, clone a name in use or one outside the panel's names, and editing the XML must keep the filter's name and UUID: each would replace another filter or make a copy. Entered XML is read for these checks without expanding entities or taking a DTD (util.parse_xml, shared with the network editor), and a rule is one <rule> element. - A rule or reference is deleted only while it reads as the page showed it, not by index and three attributes: a rule alike in those or a filter changed meanwhile loses nothing. - A reference is added only to another filter of the host not referenced yet; the picker offers those. - References keep their parameters, in order (a name may repeat); a rule shows every protocol element it has, a rule without one too. - One change a POST (two would both start from the page's reading, the second undoing the first); every change redirects and reports its refusal as a message, a POST for a filter gone meanwhile going to the list; the catch-all that showed any error goes, and so does wvmInstance.get_filterrefs, which only the old delete check used. The list reads each filter's XML once from one listing; a filter's page reads its XML once and only the other filters' names; the per-filter XML dialog of the list goes (a filter's page shows its XML). The XML editors send their text untouched too.
163 lines
7.6 KiB
HTML
163 lines
7.6 KiB
HTML
{% extends "base.html" %}
|
|
{% load i18n %}
|
|
{% load static %}
|
|
{% load bootstrap_icons %}
|
|
|
|
{% block title %}{% trans "NWFilter" %}: {{ name }}{% endblock %}
|
|
|
|
{% block page_heading %}{% trans "NWFilter" %}: {{ name }}{% endblock page_heading %}
|
|
|
|
{% block content %}
|
|
<div class="row">
|
|
<div class="col-lg-12">
|
|
{% include "computes/host_nav.html" with section="nwfilters" detail=True %}
|
|
</div>
|
|
</div>
|
|
|
|
<dl class="ms-3 row">
|
|
<dt class="col-4">{% trans "UUID" %}:</dt>
|
|
<dd class="col-8">{{ uuid }}</dd>
|
|
<dt class="col-4">{% trans "Name" %}:</dt>
|
|
<dd class="col-8">{{ name }}</dd>
|
|
</dl>
|
|
|
|
<div class="row">
|
|
<div class="d-grid col-lg-12">
|
|
<button class="btn btn-light mb-3" role="button" data-bs-toggle="collapse" data-bs-target="#collapseXML" aria-expanded="true" aria-controls="collapseXML">
|
|
<span>{% bs_icon 'chevron-down' %} </span>
|
|
{% trans 'XML' %}
|
|
</button>
|
|
<div class="collapse" id="collapseXML">
|
|
<div class="card card-body">
|
|
<form class="form" method="post" role="form">{% csrf_token %}
|
|
<div class="col-12 xmlheight">
|
|
<input type="hidden" name="edit_xml"/>
|
|
<textarea id="edit_editor">{{ xml }}</textarea>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary float-end" name="edit_nwfilter">
|
|
{% trans "Edit" %}
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-lg-12">
|
|
<h5 class="mb-3 me-auto">{% trans "Filter References" %}
|
|
<form class="float-end" method="post" role="form" aria-label="Add NWFilter form">{% csrf_token %}
|
|
<div class="input-group">
|
|
<label class="input-group-text" for="nwfilter_select">{% trans "Filter" %}</label>
|
|
<select id="nwfilter_select" name="nwfilters_select" class="form-select">
|
|
<option value="" selected>{% trans 'None' %}</option>
|
|
{% for nwf in ref_choices %}
|
|
<option value="{{ nwf }}">{{ nwf }}</option>
|
|
{% endfor %}
|
|
</select>
|
|
<button type="submit" class="btn btn-success float-end" name="add_nwfilter_ref" title="{% trans "Add" %}">
|
|
<span aria-hidden="true">{% bs_icon 'plus-circle-fill' %} </span>
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</h5>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-12 col-sm-12">
|
|
<div class="table-responsive">
|
|
<table class="table table-hover mb-3 align-middle">
|
|
<thead>
|
|
<tr>
|
|
<th scope="col">#</th>
|
|
<th scope="col">{% trans "Reference" %}</th>
|
|
<th scope="col">{% trans "Action" %}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for ref in refs %}
|
|
<tr>
|
|
<th scope="row">{{ forloop.counter }}</th>
|
|
<td>{{ ref.filter }}{% for param, value in ref.parameters %} <span class="font-monospace small">{{ param }}={{ value }}</span>{% endfor %}</td>
|
|
<td style="width:30px;">
|
|
<form action="" method="post" role="form" aria-label="Delete NWFilter form">{% csrf_token %}
|
|
<input type="hidden" name="index" value="{{ forloop.counter0 }}">
|
|
<input type="hidden" name="ref" value="{{ ref.text }}">
|
|
<button type="submit" class="btn btn-sm btn-danger" name="del_nwfilter_ref" title="{% trans "Delete" %}" data-confirm="{% blocktrans with ref=ref.filter %}Remove the reference to {{ ref }}? Its rules no longer apply through this filter.{% endblocktrans %}" onclick="return confirm(this.dataset.confirm)">
|
|
{% bs_icon 'trash' %}
|
|
</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
{% include 'add_nwf_rule.html' %}
|
|
<h5 class="mb-3">{% trans "Rules" %}</h5>
|
|
|
|
<div class="table-responsive">
|
|
<table class="table table-hover align-middle">
|
|
<thead>
|
|
<tr>
|
|
<th scope="col">{% trans "Rule" %}</th>
|
|
<th scope="col" class="text-nowrap">{% trans "Action Type" %}</th>
|
|
<th scope="col">{% trans "Direction" %}</th>
|
|
<th scope="col">{% trans "Priority" %}</th>
|
|
<th scope="col">{% trans "Statematch" %}</th>
|
|
<th scope="col">{% trans "Directives" %}</th>
|
|
<th scope="col" style="width:30px;">{% trans "Action" %}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for rule in rules %}
|
|
<tr>
|
|
<th scope="row">{{ forloop.counter }}</th>
|
|
<td>{{ rule.action }}</td>
|
|
<td>{{ rule.direction }}</td>
|
|
<td>{{ rule.priority }}</td>
|
|
<td>{{ rule.statematch }}</td>
|
|
<td class="font-monospace small">{% for protocol in rule.protocols %}<div>{{ protocol.name }}{% for attribute, value in protocol.attributes %} {{ attribute }}={{ value }}{% endfor %}</div>{% endfor %}</td>
|
|
<td>
|
|
<form action="" method="post" role="form" aria-label="Delete NWFilter rule">{% csrf_token %}
|
|
<input type="hidden" name="index" value="{{ forloop.counter0 }}">
|
|
<input type="hidden" name="rule" value="{{ rule.text }}">
|
|
<button type="submit" class="btn btn-sm btn-danger" name="del_nwfilter_rule" title="{% trans 'Delete' %}" data-confirm="{% trans "Delete this rule? Interfaces that use the filter no longer get it." %}" onclick="return confirm(this.dataset.confirm)">
|
|
{% bs_icon 'trash' %}
|
|
</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block script %}
|
|
<script src="{% static 'js/ace/ace.js' %}"></script>
|
|
<script>
|
|
var editor = ace.edit("edit_editor");
|
|
editor.getSession().setMode("ace/mode/xml");
|
|
|
|
var edit_input = $('input[name="edit_xml"]');
|
|
edit_input.val(editor.getSession().getValue());
|
|
editor.getSession().on("change",function () {
|
|
edit_input.val(editor.getSession().getValue());
|
|
});
|
|
|
|
var rule_editor = ace.edit("rule_editor");
|
|
rule_editor.getSession().setMode("ace/mode/xml");
|
|
|
|
var rule_input = $('input[name="nwfilterrule_xml"]');
|
|
rule_input.val(rule_editor.getSession().getValue());
|
|
rule_editor.getSession().on("change",function () {
|
|
rule_input.val(rule_editor.getSession().getValue());
|
|
});
|
|
</script>
|
|
|
|
{% endblock %}
|