mirror of
https://github.com/retspen/webvirtcloud
synced 2024-11-01 12:04:15 +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,12 +136,11 @@
|
|||
{% trans "Resume" %}
|
||||
</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li role="presentation" class="active">
|
||||
<a href="#resume" aria-controls="resume" role="tab" data-toggle="tab">
|
||||
{% trans "Resume" %}
|
||||
</a>
|
||||
</li>
|
||||
<li role="presentation">
|
||||
<a href="#powerforce" aria-controls="powerforce" role="tab" data-toggle="tab">
|
||||
{% trans "Force Off" %}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endifequal %}
|
||||
{% ifequal status 5 %}
|
||||
|
@ -186,19 +185,31 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
{% endifequal %}
|
||||
{% 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 %}
|
||||
{% ifequal status 3 %}
|
||||
{% 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>
|
||||
<input type="submit" name="resume" class="btn btn-lg btn-success pull-right" value="{% trans "Resume" %}">
|
||||
{% else %}
|
||||
<form action="" method="post" role="form">{% csrf_token %}
|
||||
<input type="submit" name="resume" class="btn btn-lg btn-success pull-right" value="{% trans "Resume" %}">
|
||||
<div class="clearfix"></div>
|
||||
</form>
|
||||
</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>
|
||||
<button class="btn btn-lg btn-success disabled pull-right">{% trans "Resume" %}</button>
|
||||
{% endif %}
|
||||
<div class="clearfix"></div>
|
||||
</form>
|
||||
</div>
|
||||
<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 %}
|
||||
{% ifequal status 5 %}
|
||||
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="boot">
|
||||
|
@ -605,7 +616,9 @@
|
|||
<input type="submit" class="btn btn-danger" name="unset_bootmenu" title="Hide boot menu" value="{% trans "Disable" %}">
|
||||
{% endifequal %}
|
||||
{% else %}
|
||||
<p>{% trans "**** Please shutdown instance to modify boot menu ****" %}
|
||||
{% ifequal bootmenu 0 %}
|
||||
<p>{% trans "**** Please shutdown instance to modify boot menu ****" %}
|
||||
{% endifequal %}
|
||||
{% endifequal %}
|
||||
</p>
|
||||
</div>
|
||||
|
@ -713,8 +726,12 @@
|
|||
{% endif %}
|
||||
</div>
|
||||
</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 %}
|
||||
|
||||
<div class="clearfix"></div>
|
||||
<p style="font-weight:bold;">
|
||||
{% trans "Instance Volume" %}
|
||||
{% include 'add_instance_volume.html' %}
|
||||
|
@ -796,6 +813,7 @@
|
|||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<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 class="panel-body">
|
||||
<div class="form-group form-inline">
|
||||
|
@ -810,10 +828,10 @@
|
|||
<label class="control-label"><em>to</em></label>
|
||||
<select class="form-control" name="net-source-{{ forloop.counter0 }}">
|
||||
{% 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 %}
|
||||
{% 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 %}
|
||||
</select>
|
||||
</div>
|
||||
|
@ -828,18 +846,13 @@
|
|||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<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>
|
||||
<button class="btn btn-sm btn-primary btn-block" name="change_network" title="{% trans "Apply Network Changes" %}">{% trans "Apply" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</form>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
|
||||
</div>
|
||||
<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>
|
||||
|
@ -1201,7 +1214,7 @@
|
|||
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="graphs">
|
||||
<div class="panel panel-success">
|
||||
<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 class="panel-body">
|
||||
<div class="flot-chart">
|
||||
|
@ -1214,7 +1227,7 @@
|
|||
{% for net in networks %}
|
||||
<div class="panel panel-info">
|
||||
<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 class="panel-body">
|
||||
<div class="flot-chart">
|
||||
|
@ -1228,7 +1241,7 @@
|
|||
{% for disk in disks %}
|
||||
<div class="panel panel-warning">
|
||||
<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 class="panel-body">
|
||||
<div class="flot-chart">
|
||||
|
|
|
@ -622,6 +622,11 @@ def instance(request, compute_id, vname):
|
|||
order_list[idx] = {"type": type, "dev": dev}
|
||||
conn.set_bootorder(order_list)
|
||||
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)
|
||||
return HttpResponseRedirect(request.get_full_path() + '#boot_opt')
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{% extends "base.html" %}
|
||||
{% load i18n %}
|
||||
{% load staticfiles %}
|
||||
{% block title %}{% trans "Network" %} - {{ pool }}{% endblock %}
|
||||
{% block content %}
|
||||
<!-- Page Heading -->
|
||||
|
@ -38,10 +39,10 @@
|
|||
|
||||
<div class="row">
|
||||
<div class="col-xs-6 col-sm-4">
|
||||
<p>{% trans "Network name:" %}</p>
|
||||
<p>{% trans "Device:" %}</p>
|
||||
<p>{% trans "State" %}</p>
|
||||
<p>{% trans "Autostart" %}</p>
|
||||
<p>{% trans "Network name" %}:</p>
|
||||
<p>{% trans "Device" %}:</p>
|
||||
<p>{% trans "State" %}:</p>
|
||||
<p>{% trans "Autostart" %}:</p>
|
||||
</div>
|
||||
<div class="col-xs-6 col-sm-6">
|
||||
<p>{{ pool }}</p>
|
||||
|
@ -67,11 +68,35 @@
|
|||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{#{% if state %}#}
|
||||
<div class="row">
|
||||
<h3 class="page-header">{% trans "IPv4 Configuration" %}</h3>
|
||||
<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 class="row">
|
||||
</div>
|
||||
<div class="row">
|
||||
<h3 class="page-header">{% trans "IPv4 Configuration" %}</h3>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-6 col-sm-4">
|
||||
<p>{% trans "IPv4 Forwarding:" %}</p>
|
||||
<p>{% trans "Network:" %}</p>
|
||||
|
@ -122,75 +147,74 @@
|
|||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% ifequal ipv4_forward.0 'nat' %}
|
||||
{% if state %}
|
||||
{% include 'modify_fixed_address.html' %}
|
||||
{% endif %}
|
||||
<div class="row">
|
||||
<h3 class="page-header">{% trans "Fixed Address" %}</h3>
|
||||
</div>
|
||||
{% endifequal %}
|
||||
{% if fixed_address %}
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<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 'Show' %}
|
||||
</a>
|
||||
</div>
|
||||
<div id="collapseOne" class="panel-collapse collapse">
|
||||
<div class="panel-body">
|
||||
{% ifequal ipv4_forward.0 'nat' %}
|
||||
{% if state %}
|
||||
{% include 'modify_fixed_address.html' %}
|
||||
{% endif %}
|
||||
<div class="row">
|
||||
<h3 class="page-header">{% trans "Fixed Address" %}</h3>
|
||||
</div>
|
||||
{% endifequal %}
|
||||
{% if fixed_address %}
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="panel-group" id="accordion">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<a data-toggle="collapse" data-parent="#accordion" href="#collapseTwo">
|
||||
{% trans 'Show' %}
|
||||
</a>
|
||||
</div>
|
||||
<div id="collapseTwo" class="panel-collapse collapse">
|
||||
<div class="panel-body">
|
||||
|
||||
<div class="input-append form-inline pull-right">
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" id="filter_input">
|
||||
</div>
|
||||
<input type="button" class="btn btn-default" id="filter_button" value="Filter">
|
||||
<button type="button" class="btn btn-default" id="filter_clear">{% trans 'Clear' %}</button>
|
||||
<div class="input-append form-inline pull-right">
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" id="filter_input">
|
||||
</div>
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<input type="button" class="btn btn-default" id="filter_button" value="Filter">
|
||||
<button type="button" class="btn btn-default" id="filter_clear">{% trans 'Clear' %}</button>
|
||||
</div>
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="text-align: center">{% trans "MAC" %}</th>
|
||||
<th style="text-align: center">{% trans "Address" %}</th>
|
||||
<th style="text-align: center">{% trans "Name" %}</th>
|
||||
<th style="text-align: center">{% trans "Action" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody style="text-align: center">
|
||||
{% for fix in fixed_address %}
|
||||
<tr>
|
||||
<th style="text-align: center">{% trans "MAC" %}</th>
|
||||
<th style="text-align: center">{% trans "Address" %}</th>
|
||||
<th style="text-align: center">{% trans "Name" %}</th>
|
||||
<th style="text-align: center">{% trans "Action" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody style="text-align: center">
|
||||
{% for fix in fixed_address %}
|
||||
<tr>
|
||||
<form method="post" role="form">{% csrf_token %}
|
||||
<td><label class="form-control" disabled="true">{{ fix.mac }}</label></td>
|
||||
<td><input class="form-control" value="{{ fix.ip }}" name="address" /></td>
|
||||
<td><input class="form-control" value="{{ fix.name }}" name="name" /></td>
|
||||
<td>
|
||||
<input hidden name="mac" value="{{ fix.mac }}"/>
|
||||
<button type="submit" class="btn btn-sm btn-primary"
|
||||
name="modify_fixed_address"
|
||||
title="Edit entry" onclick="return confirm('{% trans "Are you sure?" %}')">
|
||||
<i class="glyphicon glyphicon-save"></i>
|
||||
</button>
|
||||
<button type="submit" class="btn btn-sm btn-danger"
|
||||
name="delete_fixed_address"
|
||||
title="Delete entry" onclick="return confirm('{% trans "Are you sure?" %}')">
|
||||
<i class="glyphicon glyphicon-trash"></i>
|
||||
</button>
|
||||
</td>
|
||||
</form>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<td>
|
||||
<input hidden name="mac" value="{{ fix.mac }}"/>
|
||||
<button type="submit" class="btn btn-sm btn-primary"
|
||||
name="modify_fixed_address"
|
||||
title="Edit entry" onclick="return confirm('{% trans "Are you sure?" %}')">
|
||||
<i class="glyphicon glyphicon-save"></i>
|
||||
</button>
|
||||
<button type="submit" class="btn btn-sm btn-danger"
|
||||
name="delete_fixed_address"
|
||||
title="Delete entry" onclick="return confirm('{% trans "Are you sure?" %}')">
|
||||
<i class="glyphicon glyphicon-trash"></i>
|
||||
</button>
|
||||
</td>
|
||||
</form>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{#{% endif %}#}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
{% block script %}
|
||||
|
@ -230,4 +254,14 @@
|
|||
});
|
||||
});
|
||||
</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 %}
|
|
@ -88,6 +88,7 @@ def network(request, compute_id, pool):
|
|||
ipv4_dhcp_range_end = conn.get_ipv4_dhcp_range_end()
|
||||
ipv4_network = conn.get_ipv4_network()
|
||||
fixed_address = conn.get_mac_ipaddr()
|
||||
xml = conn._XMLDesc(0)
|
||||
except libvirtError as lib_err:
|
||||
error_messages.append(lib_err)
|
||||
|
||||
|
@ -139,7 +140,6 @@ def network(request, compute_id, pool):
|
|||
conn.delete_fixed_address(mac)
|
||||
messages.success(request, "Fixed Address is Deleted.")
|
||||
return HttpResponseRedirect(request.get_full_path())
|
||||
|
||||
if 'modify_dhcp_range' in request.POST:
|
||||
range_start = request.POST.get('range_start', '')
|
||||
range_end = request.POST.get('range_end', '')
|
||||
|
@ -149,6 +149,22 @@ def network(request, compute_id, pool):
|
|||
return HttpResponseRedirect(request.get_full_path())
|
||||
except libvirtError as lib_err:
|
||||
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()
|
||||
|
||||
|
|
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 -->
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
{% include 'create_nwfilter_block.html' %}
|
||||
<h1 class="page-header">{% trans "NWFilter:" %} {{ name }}</h1>
|
||||
<ol class="breadcrumb">
|
||||
<li class="active">
|
||||
|
@ -38,152 +37,126 @@
|
|||
{% include 'errors_block.html' %}
|
||||
{% include 'messages_block.html' %}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-6 col-sm-4">
|
||||
<p>{% trans "UUID:" %}</p>
|
||||
<p>{% trans "Name:" %}</p>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-6 col-sm-8">
|
||||
<p>{{ uuid }}</p>
|
||||
<p>{{ name }}</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
<p><strong>{% trans "XML:" %}</strong></p>
|
||||
<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_nwfilter">
|
||||
{% trans "Edit" %}
|
||||
</button>
|
||||
</form>
|
||||
<div class="col-xs-6 col-sm-4">
|
||||
<p>{% trans "UUID:" %}</p>
|
||||
<p>{% trans "Name:" %}</p>
|
||||
</div>
|
||||
<div class="col-xs-6 col-sm-8">
|
||||
<p>{{ uuid }}</p>
|
||||
<p>{{ name }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<p><strong>{% trans "Filter References:" %}</strong></p>
|
||||
<form class="form-inline pull-right" method="post" role="form">{% csrf_token %}
|
||||
<div class="form-group">
|
||||
<label>{% trans "Filter:" %}</label>
|
||||
<select id="nwfilter_select" name="nwfilters_select" class="form-control">
|
||||
<option value="" selected>None</option>
|
||||
{% for nwf in nwfilters_all %}
|
||||
<option value="{{ nwf.name }}">{{ nwf.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
||||
<button type="submit" class="btn btn-success pull-right" name="add_nwfilter_ref">
|
||||
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
|
||||
</button>
|
||||
<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>
|
||||
</form>
|
||||
<div id="collapseOne" class="panel-collapse collapse">
|
||||
<div class="panel-body">
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 45px;">#</th>
|
||||
<th>{% trans "Reference" %}</th>
|
||||
<th colspan="3">{% trans "Action" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for ref in refs %}
|
||||
<tr>
|
||||
<td>{{ forloop.counter }}</td>
|
||||
<td>{{ ref }}</td>
|
||||
<td style="width:30px;">
|
||||
<form action="" method="post" style="height:10px" role="form">{% csrf_token %}
|
||||
<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?" %}')">
|
||||
<i class="fa fa-trash"></i>
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</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 -->
|
||||
<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 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_nwfilter">
|
||||
{% trans "Edit" %}
|
||||
</button>
|
||||
</form>
|
||||
</div> <!-- /.modal-content -->
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- /.modal-dialog -->
|
||||
</div><!-- /.modal -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form class="form-inline pull-right" method="post" role="form">{% csrf_token %}
|
||||
<div class="form-group">
|
||||
<label>{% trans "Filter" %}:</label>
|
||||
<select id="nwfilter_select" name="nwfilters_select" class="form-control">
|
||||
<option value="" selected>{% trans 'None' %}</option>
|
||||
{% for nwf in nwfilters_all %}
|
||||
<option value="{{ nwf.name }}">{{ nwf.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<button type="submit" class="btn btn-success pull-right" name="add_nwfilter_ref">
|
||||
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
<div class="row">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 45px;">{% trans "Rule" %}</th>
|
||||
<th>{% trans "ActionType" %}</th>
|
||||
<th>{% trans "Direction" %}</th>
|
||||
<th>{% trans "Priority" %}</th>
|
||||
<th>{% trans "Statematch" %}</th>
|
||||
<th>{% trans "Directives" %}</th>
|
||||
<th colspan="3">{% trans "Action" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for rule in rules %}
|
||||
<tr>
|
||||
<td>{{ forloop.counter }}</td>
|
||||
<td>{{ rule.action }}</td>
|
||||
<td>{{ rule.direction }}</td>
|
||||
<td>{{ rule.priority }}</td>
|
||||
<td>{{ rule.statematch }}</td>
|
||||
<td>{{ rule.directives }}</td>
|
||||
<td style="width:30px;">
|
||||
<form action="" method="post" style="height:10px" role="form">{% csrf_token %}
|
||||
<input type="hidden" name="action" value="{{ rule.action }}">
|
||||
<input type="hidden" name="direction" value="{{ rule.direction }}">
|
||||
<input type="hidden" name="priority" value="{{ rule.priority }}">
|
||||
<button type="submit" class="btn btn-sm btn-default" name="del_nwfilter_rule" title="{% trans "Delete" %}" onclick="return confirm('{% trans "Are you sure?" %}')">
|
||||
<i class="fa fa-trash"></i>
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<h3 class="page-header">{% trans "Filter References" %}</h3>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-12 col-sm-12">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<th style="width: 45px;">#</th>
|
||||
<th>{% trans "Reference" %}</th>
|
||||
<th>{% trans "Action" %}</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for ref in refs %}
|
||||
<tr>
|
||||
<td>{{ forloop.counter }}</td>
|
||||
<td>{{ ref }}</td>
|
||||
<td style="width:30px;">
|
||||
<form action="" method="post" role="form">{% csrf_token %}
|
||||
<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?" %}')">
|
||||
<i class="fa fa-trash"></i>
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{% include 'add_nwf_rule.html' %}
|
||||
<div class="row">
|
||||
<h3 class="page-header">{% trans "Rules" %}</h3>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-12">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<th style="width:45px;">{% trans "Rule" %}</th>
|
||||
<th>{% trans "ActionType" %}</th>
|
||||
<th>{% trans "Direction" %}</th>
|
||||
<th>{% trans "Priority" %}</th>
|
||||
<th>{% trans "Statematch" %}</th>
|
||||
<th>{% trans "Directives" %}</th>
|
||||
<th style="width:100px;">{% trans "Action" %}</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for rule in rules %}
|
||||
<tr>
|
||||
<td>{{ forloop.counter }}</td>
|
||||
<td>{{ rule.action }}</td>
|
||||
<td>{{ rule.direction }}</td>
|
||||
<td>{{ rule.priority }}</td>
|
||||
<td>{{ rule.statematch }}</td>
|
||||
<td>{{ rule.directives }}</td>
|
||||
<td>
|
||||
<form action="" method="post" role="form">{% csrf_token %}
|
||||
<input type="hidden" name="action" value="{{ rule.action }}">
|
||||
<input type="hidden" name="direction" value="{{ rule.direction }}">
|
||||
<input type="hidden" name="priority" value="{{ rule.priority }}">
|
||||
<button type="submit" class="btn btn-sm btn-default" name="del_nwfilter_rule" title="{% trans "Delete" %}" onclick="return confirm('{% trans "Are you sure?" %}')">
|
||||
<i class="fa fa-trash"></i>
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block script %}
|
||||
|
@ -209,7 +182,7 @@
|
|||
var edit_input = $('input[name="edit_xml"]');
|
||||
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");
|
||||
|
@ -217,7 +190,7 @@
|
|||
var rule_input = $('input[name="nwfilterrule_xml"]');
|
||||
rule_editor.getSession().on("change",function () {
|
||||
rule_input.val(rule_editor.getSession().getValue());
|
||||
})
|
||||
});
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -40,12 +40,12 @@
|
|||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="row">
|
||||
<div class="pull-right">
|
||||
<input id="filter" class="form-control" type="text" placeholder="Search">
|
||||
</div>
|
||||
<h3 class="page-header">{% trans "NWFilters" %}</h3>
|
||||
|
||||
<div class="pull-right">
|
||||
<input id="filter" class="form-control" type="text" placeholder="Search">
|
||||
</div>
|
||||
<div class="row">
|
||||
<h3 class="page-header">{% trans "NWFilters" %}</h3>
|
||||
</div>
|
||||
{% if nwfilters %}
|
||||
<div class="table-responsive">
|
||||
|
@ -166,6 +166,4 @@
|
|||
input.val(editor.getSession().getValue());
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -986,6 +986,21 @@ class wvmInstance(wvmConnect):
|
|||
source.set('bridge', bridge_name)
|
||||
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 source is not None: source.set('filter', net_filter)
|
||||
else:
|
||||
|
|
|
@ -2,7 +2,7 @@ from vrtManager import util
|
|||
from vrtManager.IPy import IP
|
||||
from vrtManager.connection import wvmConnect
|
||||
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_AFFECT_LIVE, VIR_NETWORK_UPDATE_AFFECT_CONFIG
|
||||
|
||||
|
@ -178,7 +178,9 @@ class wvmNetwork(wvmConnect):
|
|||
for net in doc.xpath('/network/ip/dhcp/host'):
|
||||
ip = net.xpath('@ip')[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})
|
||||
return result
|
||||
|
||||
|
@ -186,7 +188,10 @@ class wvmNetwork(wvmConnect):
|
|||
|
||||
def modify_fixed_address(self, name, address, mac):
|
||||
util.validate_macaddr(mac)
|
||||
new_xml = '<host mac="{}" name="{}" ip="{}"/>'.format(mac, name, IP(address))
|
||||
if name:
|
||||
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)
|
||||
|
||||
tree = ElementTree.fromstring(self._XMLDesc(0))
|
||||
|
|
Loading…
Reference in a new issue