mirror of
https://github.com/retspen/webvirtcloud
synced 2024-12-24 23:25:24 +00:00
Merge pull request #220 from catborise/master
fix for dhcp fixed address
This commit is contained in:
commit
aea7545030
9 changed files with 335 additions and 243 deletions
|
@ -136,10 +136,9 @@
|
||||||
{% trans "Resume" %}
|
{% trans "Resume" %}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% else %}
|
<li role="presentation">
|
||||||
<li role="presentation" class="active">
|
<a href="#powerforce" aria-controls="powerforce" role="tab" data-toggle="tab">
|
||||||
<a href="#resume" aria-controls="resume" role="tab" data-toggle="tab">
|
{% trans "Force Off" %}
|
||||||
{% trans "Resume" %}
|
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -187,18 +186,30 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endifequal %}
|
{% endifequal %}
|
||||||
{% ifequal status 3 %}
|
{% ifequal status 3 %}
|
||||||
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="resume">
|
|
||||||
<form action="" method="post" role="form">{% csrf_token %}
|
|
||||||
{% if request.user.is_superuser %}
|
{% if request.user.is_superuser %}
|
||||||
|
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="resume">
|
||||||
<p>{% trans "This action restore the instance after suspend." %}</p>
|
<p>{% trans "This action restore the instance after suspend." %}</p>
|
||||||
|
<form action="" method="post" role="form">{% csrf_token %}
|
||||||
<input type="submit" name="resume" class="btn btn-lg btn-success pull-right" value="{% trans "Resume" %}">
|
<input type="submit" name="resume" class="btn btn-lg btn-success pull-right" value="{% trans "Resume" %}">
|
||||||
{% else %}
|
|
||||||
<p>{% trans "Administrator blocked your instance." %}</p>
|
|
||||||
<button class="btn btn-lg btn-success disabled pull-right">{% trans "Resume" %}</button>
|
|
||||||
{% endif %}
|
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="powerforce">
|
||||||
|
<p>{% trans "This action forcibly powers off the instance and may cause data corruption." %}</p>
|
||||||
|
<form action="" method="post" role="form">{% csrf_token %}
|
||||||
|
<input type="submit" name="powerforce" class="btn btn-lg btn-success pull-right" value="{% trans "Force Off" %}">
|
||||||
|
<div class="clearfix"></div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="resume">
|
||||||
|
<p>{% trans "Administrator blocked your instance." %}</p>
|
||||||
|
<form action="" method="post" role="form">{% csrf_token %}
|
||||||
|
<button class="btn btn-lg btn-success disabled pull-right">{% trans "Resume" %}</button>
|
||||||
|
<div class="clearfix"></div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% endifequal %}
|
{% endifequal %}
|
||||||
{% ifequal status 5 %}
|
{% ifequal status 5 %}
|
||||||
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="boot">
|
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="boot">
|
||||||
|
@ -605,8 +616,10 @@
|
||||||
<input type="submit" class="btn btn-danger" name="unset_bootmenu" title="Hide boot menu" value="{% trans "Disable" %}">
|
<input type="submit" class="btn btn-danger" name="unset_bootmenu" title="Hide boot menu" value="{% trans "Disable" %}">
|
||||||
{% endifequal %}
|
{% endifequal %}
|
||||||
{% else %}
|
{% else %}
|
||||||
|
{% ifequal bootmenu 0 %}
|
||||||
<p>{% trans "**** Please shutdown instance to modify boot menu ****" %}
|
<p>{% trans "**** Please shutdown instance to modify boot menu ****" %}
|
||||||
{% endifequal %}
|
{% endifequal %}
|
||||||
|
{% endifequal %}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -713,8 +726,12 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
{% empty %}
|
||||||
|
<div class="col-sm-offset-3 col-sm-6">
|
||||||
|
<div class="well well-sm">{% trans 'There is not any CD-ROM device.' %}</div>
|
||||||
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
<div class="clearfix"></div>
|
||||||
<p style="font-weight:bold;">
|
<p style="font-weight:bold;">
|
||||||
{% trans "Instance Volume" %}
|
{% trans "Instance Volume" %}
|
||||||
{% include 'add_instance_volume.html' %}
|
{% include 'add_instance_volume.html' %}
|
||||||
|
@ -796,6 +813,7 @@
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<label>eth{{ forloop.counter0 }}({{ network.target|default:"no target" }})</label>
|
<label>eth{{ forloop.counter0 }}({{ network.target|default:"no target" }})</label>
|
||||||
|
<button class="btn btn-sm pull-right btn-danger" value="{{ network.mac }}" name="delete_network" title="{% trans "Delete Device" %}" onclick="return confirm('{% trans "Are you sure?" %}')">{% trans "Delete" %}</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="form-group form-inline">
|
<div class="form-group form-inline">
|
||||||
|
@ -810,10 +828,10 @@
|
||||||
<label class="control-label"><em>to</em></label>
|
<label class="control-label"><em>to</em></label>
|
||||||
<select class="form-control" name="net-source-{{ forloop.counter0 }}">
|
<select class="form-control" name="net-source-{{ forloop.counter0 }}">
|
||||||
{% for c_net in compute_networks %}
|
{% for c_net in compute_networks %}
|
||||||
<option value="net:{{ c_net }}" {% ifequal c_net network.nic %} selected {% endifequal %}>Network {{ c_net }}</option>
|
<option value="net:{{ c_net }}" {% ifequal c_net network.nic %} selected {% endifequal %}>{% trans 'Network' %} {{ c_net }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% for c_iface in compute_interfaces %}
|
{% for c_iface in compute_interfaces %}
|
||||||
<option value="iface:{{ c_iface }}" {% ifequal c_iface network.nic %} selected {% endifequal %}>Interface {{ c_iface }}</option>
|
<option value="iface:{{ c_iface }}" {% ifequal c_iface network.nic %} selected {% endifequal %}>{% trans 'Interface' %} {{ c_iface }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
@ -828,18 +846,13 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<button class="btn btn-sm btn-primary btn-block" name="change_network" title="{% trans "Apply Network Changes" %}">{% trans "Apply" %}</button>
|
||||||
|
|
||||||
<div class="panel-footer">
|
|
||||||
<button class="btn btn-sm btn-primary" name="change_network" title="{% trans "Change" %}">{% trans "Change" %}</button>
|
|
||||||
<button class="btn btn-sm pull-right btn-danger" value="{{ network.mac }}" name="delete_network" title="{% trans "Delete" %}" onclick="return confirm('{% trans "Are you sure?" %}')">{% trans "Delete" %}</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="migrate">
|
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="migrate">
|
||||||
<p>{% trans "For migration both host servers must have equal settings and OS type" %}</p>
|
<p>{% trans "For migration both host servers must have equal settings and OS type" %}</p>
|
||||||
|
@ -1201,7 +1214,7 @@
|
||||||
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="graphs">
|
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="graphs">
|
||||||
<div class="panel panel-success">
|
<div class="panel panel-success">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<h3 class="panel-title"><i class="fa fa-long-arrow-right"></i> {% trans "CPU usage" %}</h3>
|
<h3 class="panel-title"><i class="fa fa-long-arrow-right"></i> {% trans "CPU Usage" %}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="flot-chart">
|
<div class="flot-chart">
|
||||||
|
@ -1214,7 +1227,7 @@
|
||||||
{% for net in networks %}
|
{% for net in networks %}
|
||||||
<div class="panel panel-info">
|
<div class="panel panel-info">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<h3 class="panel-title"><i class="fa fa-long-arrow-right"></i> {% trans "Bandwidth device:" %} eth{{ forloop.counter0 }}</h3>
|
<h3 class="panel-title"><i class="fa fa-long-arrow-right"></i> {% trans "Bandwidth Device" %}: eth{{ forloop.counter0 }}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="flot-chart">
|
<div class="flot-chart">
|
||||||
|
@ -1228,7 +1241,7 @@
|
||||||
{% for disk in disks %}
|
{% for disk in disks %}
|
||||||
<div class="panel panel-warning">
|
<div class="panel panel-warning">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<h3 class="panel-title"><i class="fa fa-long-arrow-right"></i> {% trans "Disk I/O device:" %} {{ disk.dev }}</h3>
|
<h3 class="panel-title"><i class="fa fa-long-arrow-right"></i> {% trans "Disk I/O device" %}: {{ disk.dev }}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="flot-chart">
|
<div class="flot-chart">
|
||||||
|
|
|
@ -622,6 +622,11 @@ def instance(request, compute_id, vname):
|
||||||
order_list[idx] = {"type": type, "dev": dev}
|
order_list[idx] = {"type": type, "dev": dev}
|
||||||
conn.set_bootorder(order_list)
|
conn.set_bootorder(order_list)
|
||||||
msg = _("Set boot order")
|
msg = _("Set boot order")
|
||||||
|
|
||||||
|
if not conn.get_status() == 5:
|
||||||
|
messages.success(request, _("Boot menu changes applied. But it will be activated after shutdown"))
|
||||||
|
else:
|
||||||
|
messages.success(request, _("Boot order changed successfully."))
|
||||||
addlogmsg(request.user.username, instance.name, msg)
|
addlogmsg(request.user.username, instance.name, msg)
|
||||||
return HttpResponseRedirect(request.get_full_path() + '#boot_opt')
|
return HttpResponseRedirect(request.get_full_path() + '#boot_opt')
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
{% load staticfiles %}
|
||||||
{% block title %}{% trans "Network" %} - {{ pool }}{% endblock %}
|
{% block title %}{% trans "Network" %} - {{ pool }}{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<!-- Page Heading -->
|
<!-- Page Heading -->
|
||||||
|
@ -38,10 +39,10 @@
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-6 col-sm-4">
|
<div class="col-xs-6 col-sm-4">
|
||||||
<p>{% trans "Network name:" %}</p>
|
<p>{% trans "Network name" %}:</p>
|
||||||
<p>{% trans "Device:" %}</p>
|
<p>{% trans "Device" %}:</p>
|
||||||
<p>{% trans "State" %}</p>
|
<p>{% trans "State" %}:</p>
|
||||||
<p>{% trans "Autostart" %}</p>
|
<p>{% trans "Autostart" %}:</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-6 col-sm-6">
|
<div class="col-xs-6 col-sm-6">
|
||||||
<p>{{ pool }}</p>
|
<p>{{ pool }}</p>
|
||||||
|
@ -67,7 +68,31 @@
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{#{% if state %}#}
|
<div class="row">
|
||||||
|
<h3 class="page-header"></h3>
|
||||||
|
</div>
|
||||||
|
<div class="panel-group" id="accordion">
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
|
||||||
|
{% trans 'XML' %}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div id="collapseOne" class="panel-collapse collapse">
|
||||||
|
<div class="panel-body">
|
||||||
|
<form class="form-inline" method="post" role="form">{% csrf_token %}
|
||||||
|
<div class="col-xs-12" id="xmlheight">
|
||||||
|
<input type="hidden" name="edit_xml"/>
|
||||||
|
<textarea id="edit_editor">{{ xml }}</textarea>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary pull-right" name="edit_network">
|
||||||
|
{% trans "Edit" %}
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<h3 class="page-header">{% trans "IPv4 Configuration" %}</h3>
|
<h3 class="page-header">{% trans "IPv4 Configuration" %}</h3>
|
||||||
</div>
|
</div>
|
||||||
|
@ -136,11 +161,11 @@
|
||||||
<div class="panel-group" id="accordion">
|
<div class="panel-group" id="accordion">
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
|
<a data-toggle="collapse" data-parent="#accordion" href="#collapseTwo">
|
||||||
{% trans 'Show' %}
|
{% trans 'Show' %}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div id="collapseOne" class="panel-collapse collapse">
|
<div id="collapseTwo" class="panel-collapse collapse">
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
|
||||||
<div class="input-append form-inline pull-right">
|
<div class="input-append form-inline pull-right">
|
||||||
|
@ -190,7 +215,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{#{% endif %}#}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block script %}
|
{% block script %}
|
||||||
|
@ -230,4 +254,14 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
<script src="{% static "js/ace.js" %}"></script>
|
||||||
|
<script>
|
||||||
|
var editor = ace.edit("edit_editor");
|
||||||
|
editor.getSession().setMode("ace/mode/xml");
|
||||||
|
|
||||||
|
var edit_input = $('input[name="edit_xml"]');
|
||||||
|
editor.getSession().on("change", function () {
|
||||||
|
edit_input.val(editor.getSession().getValue());
|
||||||
|
});
|
||||||
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -88,6 +88,7 @@ def network(request, compute_id, pool):
|
||||||
ipv4_dhcp_range_end = conn.get_ipv4_dhcp_range_end()
|
ipv4_dhcp_range_end = conn.get_ipv4_dhcp_range_end()
|
||||||
ipv4_network = conn.get_ipv4_network()
|
ipv4_network = conn.get_ipv4_network()
|
||||||
fixed_address = conn.get_mac_ipaddr()
|
fixed_address = conn.get_mac_ipaddr()
|
||||||
|
xml = conn._XMLDesc(0)
|
||||||
except libvirtError as lib_err:
|
except libvirtError as lib_err:
|
||||||
error_messages.append(lib_err)
|
error_messages.append(lib_err)
|
||||||
|
|
||||||
|
@ -139,7 +140,6 @@ def network(request, compute_id, pool):
|
||||||
conn.delete_fixed_address(mac)
|
conn.delete_fixed_address(mac)
|
||||||
messages.success(request, "Fixed Address is Deleted.")
|
messages.success(request, "Fixed Address is Deleted.")
|
||||||
return HttpResponseRedirect(request.get_full_path())
|
return HttpResponseRedirect(request.get_full_path())
|
||||||
|
|
||||||
if 'modify_dhcp_range' in request.POST:
|
if 'modify_dhcp_range' in request.POST:
|
||||||
range_start = request.POST.get('range_start', '')
|
range_start = request.POST.get('range_start', '')
|
||||||
range_end = request.POST.get('range_end', '')
|
range_end = request.POST.get('range_end', '')
|
||||||
|
@ -149,6 +149,22 @@ def network(request, compute_id, pool):
|
||||||
return HttpResponseRedirect(request.get_full_path())
|
return HttpResponseRedirect(request.get_full_path())
|
||||||
except libvirtError as lib_err:
|
except libvirtError as lib_err:
|
||||||
error_messages.append(lib_err.message)
|
error_messages.append(lib_err.message)
|
||||||
|
if 'edit_network' in request.POST:
|
||||||
|
edit_xml = request.POST.get('edit_xml', '')
|
||||||
|
if edit_xml:
|
||||||
|
try:
|
||||||
|
new_conn = wvmNetworks(compute.hostname,
|
||||||
|
compute.login,
|
||||||
|
compute.password,
|
||||||
|
compute.type)
|
||||||
|
conn.define_network(edit_xml)
|
||||||
|
if conn.is_active():
|
||||||
|
messages.success(request, _("Network XML is changed. Stop and start network to activate new config."))
|
||||||
|
else:
|
||||||
|
messages.success(request, _("Network XML is changed."))
|
||||||
|
return HttpResponseRedirect(request.get_full_path())
|
||||||
|
except libvirtError as lib_err:
|
||||||
|
error_messages.append(lib_err.message)
|
||||||
|
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
|
|
33
nwfilters/templates/add_nwf_rule.html
Normal file
33
nwfilters/templates/add_nwf_rule.html
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
{% load i18n %}
|
||||||
|
{% if request.user.is_superuser %}
|
||||||
|
<a href="#AddNWFilterRule" type="button" class="btn btn-success pull-right" data-toggle="modal">
|
||||||
|
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<!-- Modal Secret -->
|
||||||
|
<div class="modal fade" id="AddNWFilterRule" tabindex="-1" role="dialog" aria-labelledby="AddNWFilterRule" 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 "Add New NWFilter Rule" %}</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<form class="form-horizontal" method="post" role="form">{% csrf_token %}
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-xs-12" id="xmlheight">
|
||||||
|
<input type="hidden" name="nwfilterrule_xml"/>
|
||||||
|
<textarea id="rule_editor"></textarea>
|
||||||
|
</div>
|
||||||
|
<p><small><em>{% trans 'If there is a rule which has same attributes it replaces that rule' %}...</em></small></p>
|
||||||
|
</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="add_nwfilter_rule">{% trans "Add" %}</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div> <!-- /.modal-content -->
|
||||||
|
</div>
|
||||||
|
</div> <!-- /.modal-dialog -->
|
||||||
|
</div><!-- /.modal -->
|
||||||
|
{% endif %}
|
|
@ -6,7 +6,6 @@
|
||||||
<!-- Page Heading -->
|
<!-- Page Heading -->
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
{% include 'create_nwfilter_block.html' %}
|
|
||||||
<h1 class="page-header">{% trans "NWFilter:" %} {{ name }}</h1>
|
<h1 class="page-header">{% trans "NWFilter:" %} {{ name }}</h1>
|
||||||
<ol class="breadcrumb">
|
<ol class="breadcrumb">
|
||||||
<li class="active">
|
<li class="active">
|
||||||
|
@ -43,15 +42,24 @@
|
||||||
<p>{% trans "UUID:" %}</p>
|
<p>{% trans "UUID:" %}</p>
|
||||||
<p>{% trans "Name:" %}</p>
|
<p>{% trans "Name:" %}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-xs-6 col-sm-8">
|
<div class="col-xs-6 col-sm-8">
|
||||||
<p>{{ uuid }}</p>
|
<p>{{ uuid }}</p>
|
||||||
<p>{{ name }}</p>
|
<p>{{ name }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<p><strong>{% trans "XML:" %}</strong></p>
|
<h3 class="page-header"></h3>
|
||||||
|
</div>
|
||||||
|
<div class="panel-group" id="accordion">
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
|
||||||
|
{% trans 'XML' %}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div id="collapseOne" class="panel-collapse collapse">
|
||||||
|
<div class="panel-body">
|
||||||
|
|
||||||
<form class="form-inline" method="post" role="form">{% csrf_token %}
|
<form class="form-inline" method="post" role="form">{% csrf_token %}
|
||||||
<div class="col-xs-12" id="xmlheight">
|
<div class="col-xs-12" id="xmlheight">
|
||||||
<input type="hidden" name="edit_xml"/>
|
<input type="hidden" name="edit_xml"/>
|
||||||
|
@ -62,34 +70,34 @@
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
</div>
|
||||||
<p><strong>{% trans "Filter References:" %}</strong></p>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<form class="form-inline pull-right" method="post" role="form">{% csrf_token %}
|
<form class="form-inline pull-right" method="post" role="form">{% csrf_token %}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>{% trans "Filter:" %}</label>
|
<label>{% trans "Filter" %}:</label>
|
||||||
<select id="nwfilter_select" name="nwfilters_select" class="form-control">
|
<select id="nwfilter_select" name="nwfilters_select" class="form-control">
|
||||||
<option value="" selected>None</option>
|
<option value="" selected>{% trans 'None' %}</option>
|
||||||
{% for nwf in nwfilters_all %}
|
{% for nwf in nwfilters_all %}
|
||||||
<option value="{{ nwf.name }}">{{ nwf.name }}</option>
|
<option value="{{ nwf.name }}">{{ nwf.name }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<button type="submit" class="btn btn-success pull-right" name="add_nwfilter_ref">
|
<button type="submit" class="btn btn-success pull-right" name="add_nwfilter_ref">
|
||||||
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
|
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="table-responsive">
|
<h3 class="page-header">{% trans "Filter References" %}</h3>
|
||||||
<table class="table table-striped">
|
</div>
|
||||||
|
|
||||||
|
<div class="col-xs-12 col-sm-12">
|
||||||
|
<table class="table table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
|
||||||
<th style="width: 45px;">#</th>
|
<th style="width: 45px;">#</th>
|
||||||
<th>{% trans "Reference" %}</th>
|
<th>{% trans "Reference" %}</th>
|
||||||
<th colspan="3">{% trans "Action" %}</th>
|
<th>{% trans "Action" %}</th>
|
||||||
</tr>
|
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for ref in refs %}
|
{% for ref in refs %}
|
||||||
|
@ -97,7 +105,7 @@
|
||||||
<td>{{ forloop.counter }}</td>
|
<td>{{ forloop.counter }}</td>
|
||||||
<td>{{ ref }}</td>
|
<td>{{ ref }}</td>
|
||||||
<td style="width:30px;">
|
<td style="width:30px;">
|
||||||
<form action="" method="post" style="height:10px" role="form">{% csrf_token %}
|
<form action="" method="post" role="form">{% csrf_token %}
|
||||||
<input type="hidden" name="ref" value="{{ ref }}">
|
<input type="hidden" name="ref" value="{{ ref }}">
|
||||||
<button type="submit" class="btn btn-sm btn-default" name="del_nwfilter_ref" title="{% trans "Delete" %}" onclick="return confirm('{% trans "Are you sure?" %}')">
|
<button type="submit" class="btn btn-sm btn-default" name="del_nwfilter_ref" title="{% trans "Delete" %}" onclick="return confirm('{% trans "Are you sure?" %}')">
|
||||||
<i class="fa fa-trash"></i>
|
<i class="fa fa-trash"></i>
|
||||||
|
@ -109,53 +117,21 @@
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<p><strong>{% trans "Rules:" %}</strong></p>
|
|
||||||
<a href="#AddNWFilterRule" type="button" class="btn btn-success pull-right" data-toggle="modal">
|
|
||||||
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<!-- Modal Secret -->
|
{% include 'add_nwf_rule.html' %}
|
||||||
<div class="modal fade" id="AddNWFilterRule" tabindex="-1" role="dialog" aria-labelledby="AddNWFilterRule" 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 "Add New NWFilter Rule" %}</h4>
|
|
||||||
</div>
|
|
||||||
<div class="modal-body">
|
|
||||||
<form class="form-horizontal" method="post" role="form">{% csrf_token %}
|
|
||||||
<div class="form-group">
|
|
||||||
<div class="col-xs-12" id="xmlheight">
|
|
||||||
<input type="hidden" name="nwfilterrule_xml"/>
|
|
||||||
<textarea id="rule_editor"></textarea>
|
|
||||||
</div>
|
|
||||||
<p><small><em>If there is a rule which has same attributes it replaces that rule...</em></small></p>
|
|
||||||
</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="add_nwfilter_rule">{% trans "Add" %}</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div> <!-- /.modal-content -->
|
|
||||||
</div>
|
|
||||||
</div> <!-- /.modal-dialog -->
|
|
||||||
</div><!-- /.modal -->
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="table-responsive">
|
<h3 class="page-header">{% trans "Rules" %}</h3>
|
||||||
<table class="table table-striped">
|
</div>
|
||||||
|
<div class="col-xs-12 col-sm-12">
|
||||||
|
<table class="table table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<th style="width:45px;">{% trans "Rule" %}</th>
|
||||||
<th style="width: 45px;">{% trans "Rule" %}</th>
|
|
||||||
<th>{% trans "ActionType" %}</th>
|
<th>{% trans "ActionType" %}</th>
|
||||||
<th>{% trans "Direction" %}</th>
|
<th>{% trans "Direction" %}</th>
|
||||||
<th>{% trans "Priority" %}</th>
|
<th>{% trans "Priority" %}</th>
|
||||||
<th>{% trans "Statematch" %}</th>
|
<th>{% trans "Statematch" %}</th>
|
||||||
<th>{% trans "Directives" %}</th>
|
<th>{% trans "Directives" %}</th>
|
||||||
<th colspan="3">{% trans "Action" %}</th>
|
<th style="width:100px;">{% trans "Action" %}</th>
|
||||||
</tr>
|
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for rule in rules %}
|
{% for rule in rules %}
|
||||||
|
@ -166,8 +142,8 @@
|
||||||
<td>{{ rule.priority }}</td>
|
<td>{{ rule.priority }}</td>
|
||||||
<td>{{ rule.statematch }}</td>
|
<td>{{ rule.statematch }}</td>
|
||||||
<td>{{ rule.directives }}</td>
|
<td>{{ rule.directives }}</td>
|
||||||
<td style="width:30px;">
|
<td>
|
||||||
<form action="" method="post" style="height:10px" role="form">{% csrf_token %}
|
<form action="" method="post" role="form">{% csrf_token %}
|
||||||
<input type="hidden" name="action" value="{{ rule.action }}">
|
<input type="hidden" name="action" value="{{ rule.action }}">
|
||||||
<input type="hidden" name="direction" value="{{ rule.direction }}">
|
<input type="hidden" name="direction" value="{{ rule.direction }}">
|
||||||
<input type="hidden" name="priority" value="{{ rule.priority }}">
|
<input type="hidden" name="priority" value="{{ rule.priority }}">
|
||||||
|
@ -181,9 +157,6 @@
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block script %}
|
{% block script %}
|
||||||
|
@ -209,7 +182,7 @@
|
||||||
var edit_input = $('input[name="edit_xml"]');
|
var edit_input = $('input[name="edit_xml"]');
|
||||||
editor.getSession().on("change",function () {
|
editor.getSession().on("change",function () {
|
||||||
edit_input.val(editor.getSession().getValue());
|
edit_input.val(editor.getSession().getValue());
|
||||||
})
|
});
|
||||||
|
|
||||||
var rule_editor = ace.edit("rule_editor");
|
var rule_editor = ace.edit("rule_editor");
|
||||||
rule_editor.getSession().setMode("ace/mode/xml");
|
rule_editor.getSession().setMode("ace/mode/xml");
|
||||||
|
@ -217,7 +190,7 @@
|
||||||
var rule_input = $('input[name="nwfilterrule_xml"]');
|
var rule_input = $('input[name="nwfilterrule_xml"]');
|
||||||
rule_editor.getSession().on("change",function () {
|
rule_editor.getSession().on("change",function () {
|
||||||
rule_input.val(rule_editor.getSession().getValue());
|
rule_input.val(rule_editor.getSession().getValue());
|
||||||
})
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -40,12 +40,12 @@
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<div class="row">
|
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
<input id="filter" class="form-control" type="text" placeholder="Search">
|
<input id="filter" class="form-control" type="text" placeholder="Search">
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row">
|
||||||
<h3 class="page-header">{% trans "NWFilters" %}</h3>
|
<h3 class="page-header">{% trans "NWFilters" %}</h3>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{% if nwfilters %}
|
{% if nwfilters %}
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
|
@ -166,6 +166,4 @@
|
||||||
input.val(editor.getSession().getValue());
|
input.val(editor.getSession().getValue());
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -986,6 +986,21 @@ class wvmInstance(wvmConnect):
|
||||||
source.set('bridge', bridge_name)
|
source.set('bridge', bridge_name)
|
||||||
source = interface.find('filterref')
|
source = interface.find('filterref')
|
||||||
|
|
||||||
|
if net_filter:
|
||||||
|
if source is not None: source.set('filter', net_filter)
|
||||||
|
else:
|
||||||
|
element = ElementTree.Element("filterref")
|
||||||
|
element.attrib['filter'] = net_filter
|
||||||
|
interface.append(element)
|
||||||
|
else:
|
||||||
|
if source is not None: interface.remove(source)
|
||||||
|
elif interface.get('type') == 'network':
|
||||||
|
source = interface.find('mac')
|
||||||
|
source.set('address', net_mac)
|
||||||
|
source = interface.find('source')
|
||||||
|
source.set('network', net_source)
|
||||||
|
source = interface.find('filterref')
|
||||||
|
|
||||||
if net_filter:
|
if net_filter:
|
||||||
if source is not None: source.set('filter', net_filter)
|
if source is not None: source.set('filter', net_filter)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -2,7 +2,7 @@ from vrtManager import util
|
||||||
from vrtManager.IPy import IP
|
from vrtManager.IPy import IP
|
||||||
from vrtManager.connection import wvmConnect
|
from vrtManager.connection import wvmConnect
|
||||||
from xml.etree import ElementTree
|
from xml.etree import ElementTree
|
||||||
from libvirt import VIR_NETWORK_SECTION_IP_DHCP_HOST, VIR_NETWORK_SECTION_IP_DHCP_RANGE
|
from libvirt import VIR_NETWORK_SECTION_IP_DHCP_HOST
|
||||||
from libvirt import VIR_NETWORK_UPDATE_COMMAND_ADD_LAST, VIR_NETWORK_UPDATE_COMMAND_DELETE, VIR_NETWORK_UPDATE_COMMAND_MODIFY
|
from libvirt import VIR_NETWORK_UPDATE_COMMAND_ADD_LAST, VIR_NETWORK_UPDATE_COMMAND_DELETE, VIR_NETWORK_UPDATE_COMMAND_MODIFY
|
||||||
from libvirt import VIR_NETWORK_UPDATE_AFFECT_LIVE, VIR_NETWORK_UPDATE_AFFECT_CONFIG
|
from libvirt import VIR_NETWORK_UPDATE_AFFECT_LIVE, VIR_NETWORK_UPDATE_AFFECT_CONFIG
|
||||||
|
|
||||||
|
@ -178,7 +178,9 @@ class wvmNetwork(wvmConnect):
|
||||||
for net in doc.xpath('/network/ip/dhcp/host'):
|
for net in doc.xpath('/network/ip/dhcp/host'):
|
||||||
ip = net.xpath('@ip')[0]
|
ip = net.xpath('@ip')[0]
|
||||||
mac = net.xpath('@mac')[0]
|
mac = net.xpath('@mac')[0]
|
||||||
name = net.xpath('@name')[0]
|
name = net.xpath('@name')
|
||||||
|
name = name[0] if name else ""
|
||||||
|
|
||||||
result.append({'ip': ip, 'mac': mac, 'name': name})
|
result.append({'ip': ip, 'mac': mac, 'name': name})
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -186,7 +188,10 @@ class wvmNetwork(wvmConnect):
|
||||||
|
|
||||||
def modify_fixed_address(self, name, address, mac):
|
def modify_fixed_address(self, name, address, mac):
|
||||||
util.validate_macaddr(mac)
|
util.validate_macaddr(mac)
|
||||||
|
if name:
|
||||||
new_xml = '<host mac="{}" name="{}" ip="{}"/>'.format(mac, name, IP(address))
|
new_xml = '<host mac="{}" name="{}" ip="{}"/>'.format(mac, name, IP(address))
|
||||||
|
else:
|
||||||
|
new_xml = '<host mac="{}" ip="{}"/>'.format(mac, IP(address))
|
||||||
new_host_xml = ElementTree.fromstring(new_xml)
|
new_host_xml = ElementTree.fromstring(new_xml)
|
||||||
|
|
||||||
tree = ElementTree.fromstring(self._XMLDesc(0))
|
tree = ElementTree.fromstring(self._XMLDesc(0))
|
||||||
|
|
Loading…
Reference in a new issue