1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2025-01-12 08:25:18 +00:00

rearrange instance network to show ipv4 and ipv6 address. Add capability to show all ip address not one of them. Add ipv4 address to instance summary

This commit is contained in:
catborise 2020-01-10 15:28:09 +03:00
parent f2ba2b58b0
commit 8b9fe4e887
2 changed files with 66 additions and 41 deletions

View file

@ -34,6 +34,11 @@
{% for disk in disks %} {% for disk in disks %}
{{ disk.size|filesizeformat }} {% trans "Disk" %} | {{ disk.size|filesizeformat }} {% trans "Disk" %} |
{% endfor %} {% endfor %}
{% for net in networks %}
{% for ipv4 in net.ipv4|default:"-" %}
{{ ipv4 }} |
{% endfor %}
{% endfor %}
<button <button
{% if guest_agent == True %} {% if guest_agent == True %}
{% if guest_agent_ready == True %} {% if guest_agent_ready == True %}
@ -895,44 +900,27 @@
<div class="col-xs-12 col-sm-12"> <div class="col-xs-12 col-sm-12">
<p><strong>{% trans "Network Devices" %}</strong></p> <p><strong>{% trans "Network Devices" %}</strong></p>
<table class="table table-hover"> <table class="table table-striped table-responsive">
<thead> <thead>
<tr> <tr>
<th>{% trans 'Name' %}</th> <th>{% trans 'Name' %}</th>
<th>{% trans 'MAC' %}</th> <th class="hidden-xs hidden-sm" colspan="6">{% trans 'Info' %}</th>
<th>{% trans 'IP Address' %}</th> <th class="visible-xs visible-sm" colspan="2">{% trans 'Info' %}</th>
<th>{% trans 'Source' %}</th> <th colspan="2">{% trans 'Actions' %}</th>
<th>{% trans 'LinkState' %}</th>
<th>{% trans 'Filter' %}</th>
<th>{% trans 'Qos' %}</th>
<th>{% trans 'Actions' %}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for network in networks %} {% for network in networks %}
<tr> <tr>
<td class="col-sm-1">eth{{ forloop.counter0 }}({{ network.target|default:"no target" }})</td> <td rowspan="2">eth{{ forloop.counter0 }}({{ network.target|default:"no target" }})</td>
<th class="hidden-xs hidden-sm">{% trans 'MAC' %}</th>
<td>{{ network.mac }}</td> <td>{{ network.mac }}</td>
<td>{{ network.ipv4|default:"unknown" }}</td> <th class="hidden-xs hidden-sm">{% trans 'Filter' %}</th>
<td class="hidden-xs">{{ network.filterref|default:"None" }}</td>
<th class="hidden-xs hidden-sm">{% trans 'Source' %}</th>
<td>{{ network.nic }}</td> <td>{{ network.nic }}</td>
<td> <td>
<form method="post">{% csrf_token %} <form class="form-horizontal" method="post" name="edit_network{{ forloop.counter0 }}" role="form">{% csrf_token %}
<input name="mac" value="{{ network.mac }}" hidden/>
<input name="set_link_state" value="{{ network.state }}" hidden/>
<input type="checkbox" {% if network.state == 'up' %} checked
{% endif %} onclick='submit();' />
{% trans 'active' %}
</form>
</td>
<td>{{ network.filterref|default:"None" }}</td>
<td>
<form class="form-horizontal" method="post" name="add_qos{{ forloop.counter0 }}" role="form">{% csrf_token %}
<input type="text" name="net-mac-{{ forloop.counter0 }}" value="{{ network.mac }}" hidden/>
{% include 'add_network_qos.html' with id=forloop.counter0 %}
</form>
</td>
<td class="col-sm-2">
<form class="form-horizontal" method="post" name="set_qos{{ forloop.counter0 }}" role="form">{% csrf_token %}
<button data-target="#editInstanceNetwork{{ forloop.counter0 }}" type="button" class="btn btn-sm btn-primary" <button data-target="#editInstanceNetwork{{ forloop.counter0 }}" type="button" class="btn btn-sm btn-primary"
title="Edit NIC" data-toggle="modal"> title="Edit NIC" data-toggle="modal">
<span class="glyphicon glyphicon-edit" aria-hidden="true"></span> <span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
@ -947,13 +935,13 @@
</div> </div>
<div class="modal-body"> <div class="modal-body">
<div class="form-group form-inline"> <div class="form-group form-inline">
<label class="col-sm-2 control-label">{% trans "MAC" %} </label> <label class="col-sm-3 control-label">{% trans "MAC Addr" %} </label>
<input class="form-control" type="text" value="{{ network.mac }}" readonly/> <input class="form-control" type="text" value="{{ network.mac }}" readonly/>
<label class="control-label"><em>to</em></label> <label class="control-label"><em>to</em></label>
<input class="form-control" type="text" name="net-mac-{{ forloop.counter0 }}" value="{{ network.mac }}"/> <input class="form-control" type="text" name="net-mac-{{ forloop.counter0 }}" value="{{ network.mac }}"/>
</div> </div>
<div class="form-group form-inline"> <div class="form-group form-inline">
<label class="col-sm-2 control-label">{% trans "NIC" %} </label> <label class="col-sm-3 control-label">{% trans "Net Source" %} </label>
<input class="form-control" type="text" value="{{ network.nic }}" readonly/> <input class="form-control" type="text" value="{{ network.nic }}" readonly/>
<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 }}">
@ -966,7 +954,7 @@
</select> </select>
</div> </div>
<div class="form-group form-inline"> <div class="form-group form-inline">
<label class="col-sm-2 control-label">{% trans "Filter" %} </label> <label class="col-sm-3 control-label">{% trans "NW Filter" %} </label>
<input class="form-control" type="text" value="{{ network.filterref }}" readonly/> <input class="form-control" type="text" value="{{ network.filterref }}" readonly/>
<label class="control-label"><em>to</em></label> <label class="control-label"><em>to</em></label>
<select class="form-control" name="net-nwfilter-{{ forloop.counter0 }}"> <select class="form-control" name="net-nwfilter-{{ forloop.counter0 }}">
@ -976,12 +964,18 @@
{% endfor %} {% endfor %}
</select> </select>
</div> </div>
<button class="btn btn-sm btn-primary btn-block" name="change_network" title="{% trans "Apply Network Changes" %}">{% trans "Apply" %}</button> </div>
<div class="modal-footer">
<button class="btn btn-default" data-dismiss="modal">{% trans 'Close' %}</button>
<button class="btn btn-success" name="change_network" title="{% trans "Apply Network Changes" %}">{% trans "Apply" %}</button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</form>
</td>
<td align="right">
<form method="post" name="delete_network" role="form">{% csrf_token %}
<button class="btn btn-sm btn-danger" value="{{ network.mac }}" name="delete_network" title="{% trans "Delete Device" %}" <button class="btn btn-sm btn-danger" value="{{ network.mac }}" name="delete_network" title="{% trans "Delete Device" %}"
onclick="return confirm('{% trans "Are you sure?" %}')"> onclick="return confirm('{% trans "Are you sure?" %}')">
<i class="glyphicon glyphicon-trash"></i> <i class="glyphicon glyphicon-trash"></i>
@ -989,6 +983,37 @@
</form> </form>
</td> </td>
</tr> </tr>
<tr>
<th class="hidden-xs hidden-sm">{% trans 'IPv4' %}</th>
<td>
{% for ipv4 in network.ipv4|default:"unknown" %}
{{ ipv4 }}
{% endfor %}
</td>
<th class="hidden-xs hidden-sm">{% trans 'IPv6' %}</th>
<td class="hidden-xs">
{% for ipv6 in network.ipv6|default:"unknown" %}
{{ ipv6 }}
{% endfor %}
</td>
<th class="hidden-xs hidden-sm">{% trans 'LinkState' %}</th>
<td>
<form method="post">{% csrf_token %}
<input name="mac" value="{{ network.mac }}" hidden/>
<input name="set_link_state" value="{{ network.state }}" hidden/>
<input type="checkbox" {% if network.state == 'up' %} checked
{% endif %} onclick='submit();' />
{% trans 'active' %}
</form>
</td>
<th>{% trans 'QoS' %}</th>
<td align="right">
<form class="form-horizontal" method="post" name="add_qos{{ forloop.counter0 }}" role="form">{% csrf_token %}
<input type="text" name="net-mac-{{ forloop.counter0 }}" value="{{ network.mac }}" hidden/>
{% include 'add_network_qos.html' with id=forloop.counter0 %}
</form>
</td>
</tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
@ -1002,7 +1027,7 @@
<table class="table table-hover"> <table class="table table-hover">
<thead> <thead>
<tr> <tr>
<th>{% trans "Direction" %}</th> <th>{% trans "MAC/Direction" %}</th>
<th>{% trans "Average" %}</th> <th>{% trans "Average" %}</th>
<th>{% trans "Peak" %}</th> <th>{% trans "Peak" %}</th>
<th>{% trans "Burst" %}</th> <th>{% trans "Burst" %}</th>

View file

@ -287,8 +287,8 @@ class wvmInstance(wvmConnect):
leases = [] leases = []
def extract_dom(info): def extract_dom(info):
ipv4 = None ipv4 = []
ipv6 = None ipv6 = []
for addrs in info.values(): for addrs in info.values():
if addrs["hwaddr"] != iface_mac: if addrs["hwaddr"] != iface_mac:
continue continue
@ -296,20 +296,20 @@ class wvmInstance(wvmConnect):
continue continue
for addr in addrs["addrs"]: for addr in addrs["addrs"]:
if addr["type"] == 0: if addr["type"] == 0:
ipv4 = addr["addr"] ipv4.append(addr["addr"])
elif (addr["type"] == 1 and elif (addr["type"] == 1 and
not str(addr["addr"]).startswith("fe80")): not str(addr["addr"]).startswith("fe80")):
ipv6 = addr["addr"] + "/" + str(addr["prefix"]) ipv6.append(addr["addr"] + "/" + str(addr["prefix"]))
return ipv4, ipv6 return ipv4, ipv6
def extract_lease(info): def extract_lease(info):
ipv4 = None ipv4 = []
ipv6 = None ipv6 = []
if info["mac"] == iface_mac: if info["mac"] == iface_mac:
if info["type"] == 0: if info["type"] == 0:
ipv4 = info["ipaddr"] ipv4.append(info["ipaddr"])
elif info["type"] == 1: elif info["type"] == 1:
ipv6 = info["ipaddr"] ipv6.append(info["ipaddr"])
return ipv4, ipv6 return ipv4, ipv6
for ips in ([qemuga] + leases + [arp]): for ips in ([qemuga] + leases + [arp]):