mirror of
https://github.com/retspen/webvirtcloud
synced 2024-10-31 19:44:16 +00:00
adds bridge slave list to details of interface
This commit is contained in:
parent
f3f4f0afe8
commit
0738ec7ec4
3 changed files with 60 additions and 5 deletions
|
@ -38,12 +38,12 @@
|
|||
<div class="row">
|
||||
<div class="col-xs-6 col-sm-4">
|
||||
<p>{% trans "Interface" %}:</p>
|
||||
<p>{% trans "IPv4" %}: ({% ifequal ipv4 None %}{% trans 'None' %}{% else %}{{ ipv4_type }}{% endifequal %})</p>
|
||||
<p>{% trans "IPv6" %}: ({% ifequal ipv6 None %}{% trans 'None' %}{% else %}{{ ipv6_type }}{% endifequal %})</p>
|
||||
<p>{% trans "IPv4" %} ({% ifequal ipv4 None %}{% trans 'None' %}{% else %}{{ ipv4_type }}{% endifequal %}):</p>
|
||||
<p>{% trans "IPv6" %} ({% ifequal ipv6 None %}{% trans 'None' %}{% else %}{{ ipv6_type }}{% endifequal %}):</p>
|
||||
<p>{% trans "MAC Adress" %}:</p>
|
||||
<p>{% trans "Interface Type" %}:</p>
|
||||
{% ifequal itype 'bridge' %}
|
||||
<p>{% trans "Bridge device" %}</p>
|
||||
<p>{% trans "Bridge Device" %}:</p>
|
||||
{% endifequal %}
|
||||
<p>{% trans "Boot Mode" %}:</p>
|
||||
<p>{% trans "State" %}:</p>
|
||||
|
@ -69,5 +69,33 @@
|
|||
</form>
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-sm-12">
|
||||
{% ifequal itype 'bridge' %}
|
||||
<table class="table table-bordered">
|
||||
<caption>{% trans 'Slaves' %}</caption>
|
||||
<thead>
|
||||
<tr class="active">
|
||||
<td>{% trans 'MAC' %}</td>
|
||||
<td>{% trans 'Name' %}</td>
|
||||
<td>{% trans 'Type' %}</td>
|
||||
<td>{% trans 'Speed' %}</td>
|
||||
<td>{% trans 'State' %}</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for iface in slave_ifaces %}
|
||||
<tr>
|
||||
<td>{{ iface.mac }}</td>
|
||||
<td>{{ iface.name }}</td>
|
||||
<td>{{ iface.type }}</td>
|
||||
<td>{{ iface.speed }}</td>
|
||||
<td>{{ iface.state }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endifequal %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
|
@ -88,6 +88,7 @@ def interface(request, compute_id, iface):
|
|||
ipv6 = conn.get_ipv6()
|
||||
ipv6_type = conn.get_ipv6_type()
|
||||
bridge = conn.get_bridge()
|
||||
slave_ifaces = conn.get_bridge_slave_ifaces()
|
||||
|
||||
if request.method == 'POST':
|
||||
if 'stop' in request.POST:
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from vrtManager.connection import wvmConnect
|
||||
from vrtManager import util
|
||||
from xml.etree import ElementTree
|
||||
from libvirt import VIR_INTERFACE_XML_INACTIVE
|
||||
|
||||
|
||||
|
@ -119,9 +120,34 @@ class wvmInterface(wvmConnect):
|
|||
return int_ipv6_ip + '/' + int_ipv6_mask
|
||||
|
||||
def get_bridge(self):
|
||||
bridge = None
|
||||
if self.get_type() == 'bridge':
|
||||
xml = self._XMLDesc()
|
||||
return util.get_xml_path(xml, "/interface/bridge/interface/@name")
|
||||
bridge = util.get_xml_path(self._XMLDesc(), "/interface/bridge/interface/@name")
|
||||
for iface in self.get_bridge_slave_ifaces():
|
||||
if iface.get('state') == 'up' and iface.get('speed') is not 'unknown':
|
||||
bridge = iface.get('name')
|
||||
return bridge
|
||||
return bridge
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_bridge_slave_ifaces(self):
|
||||
ifaces = list()
|
||||
if self.get_type() == 'bridge':
|
||||
tree = ElementTree.fromstring(self._XMLDesc())
|
||||
for iface in tree.findall("./bridge/"):
|
||||
address = state = speed = None
|
||||
name = iface.get('name')
|
||||
type = iface.get('type')
|
||||
link = iface.find('link')
|
||||
if link is not None:
|
||||
state = link.get('state')
|
||||
speed = link.get('speed')
|
||||
mac = iface.find('mac')
|
||||
if mac is not None:
|
||||
address = mac.get('address')
|
||||
ifaces.append({'name': name, 'type': type, 'state': state, 'speed': speed, 'mac': address})
|
||||
return ifaces
|
||||
else:
|
||||
return None
|
||||
|
||||
|
|
Loading…
Reference in a new issue