mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-26 22:52:26 +00:00
Determine et affiche le vendeur de la mac (wip sur le except)
This commit is contained in:
parent
eacad3bdb9
commit
e1fa749039
2 changed files with 32 additions and 0 deletions
|
@ -1044,6 +1044,16 @@ class Interface(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
|
|||
IPv6Address(prefix_v6).exploded[:20] +
|
||||
IPv6Address(self.id).exploded[20:]
|
||||
)
|
||||
@cached_property
|
||||
def get_vendor(self):
|
||||
"""Retourne le vendeur associé à la mac de l'interface"""
|
||||
mac = EUI(self.mac_address)
|
||||
try:
|
||||
oui = mac.oui
|
||||
vendor = oui.registration().org
|
||||
except:
|
||||
vendor = "Unknown vendor"
|
||||
return(vendor)
|
||||
|
||||
def sync_ipv6_dhcpv6(self):
|
||||
"""Affecte une ipv6 dhcpv6 calculée à partir de l'id de la machine"""
|
||||
|
|
|
@ -92,6 +92,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
</td>
|
||||
<td>
|
||||
{{ interface.mac_address }}
|
||||
<button class="btn btn-default btn-xs" type="button" data-toggle="collapse"
|
||||
data-target="#collapseVendor_{{ interface.id }}" aria-expanded="true"
|
||||
aria-controls="collapseVendor_{{ interface.id }}">
|
||||
{% trans "Display the vendor" %}
|
||||
</button>
|
||||
</td>
|
||||
<td>
|
||||
<b>IPv4</b> {{ interface.ipv4 }}
|
||||
|
@ -163,6 +168,17 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan=5 style="border-top: none; padding: 1px;">
|
||||
<div class="collapse in" id="collapseVendor_{{ interface.id }}">
|
||||
<ul class="list-group" style="margin-bottom: 0;">
|
||||
<li class="list-group-item col-xs-6 col-sm-6 col-md-6" style="border: none;">
|
||||
{{ interface.get_vendor }}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% if ipv6_enabled and interface.ipv6 != 'None' %}
|
||||
<tr>
|
||||
<td colspan=5 style="border-top: none; padding: 1px;">
|
||||
|
@ -217,6 +233,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
ipv6_div[i].collapse('hide');
|
||||
}
|
||||
});
|
||||
$("#machines_table").ready(function () {
|
||||
var vendor_div = [{% for machine in machines_list %}{% for interface in machine.interface_set.all %}{% if interface.get_vendor %}$("#collapseVendor_{{ interface.id }}"), {% endif %}{% endfor %}{% endfor %}];
|
||||
for (var i = 0; i < vendor_div.length; i++) {
|
||||
vendor_div[i].collapse('hide');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
{% if machines_list.paginator %}
|
||||
|
|
Loading…
Reference in a new issue