printing: afficher constructeur de la mac
Killer feature ;o
This commit is contained in:
parent
6fffbd7bd3
commit
ff62cda2af
2 changed files with 17 additions and 1 deletions
|
@ -71,6 +71,21 @@ def telephone(l):
|
||||||
tel.append(t)
|
tel.append(t)
|
||||||
return tel
|
return tel
|
||||||
|
|
||||||
|
_ethercodes = None
|
||||||
|
def const_of_mac(mac):
|
||||||
|
global _ethercodes
|
||||||
|
if not _ethercodes:
|
||||||
|
_ethercodes = dict()
|
||||||
|
with open('/usr/scripts/gestion/ethercodes.dat', 'r') as f:
|
||||||
|
# Évite de mettre en RAM tout de suite, on utilise un itérateur
|
||||||
|
for line in iter(f.readline, ''):
|
||||||
|
line = line.split('\t\t')
|
||||||
|
_ethercodes[line[0][0:8].lower()] = line[-1].strip()
|
||||||
|
try:
|
||||||
|
return mac + u" (%s)" % _ethercodes[mac[0:8]]
|
||||||
|
except KeyError:
|
||||||
|
return mac
|
||||||
|
|
||||||
templateEnv=None
|
templateEnv=None
|
||||||
def template():
|
def template():
|
||||||
global templateEnv
|
global templateEnv
|
||||||
|
@ -87,6 +102,7 @@ def template():
|
||||||
templateEnv.filters['timeformat'] = timeformat
|
templateEnv.filters['timeformat'] = timeformat
|
||||||
templateEnv.filters['split'] = split
|
templateEnv.filters['split'] = split
|
||||||
templateEnv.filters['telephone'] = telephone
|
templateEnv.filters['telephone'] = telephone
|
||||||
|
templateEnv.filters['const_of_mac'] = const_of_mac
|
||||||
templateEnv.filters['tableau'] = tableau
|
templateEnv.filters['tableau'] = tableau
|
||||||
return templateEnv
|
return templateEnv
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
{% if o.hostAlias %}
|
{% if o.hostAlias %}
|
||||||
{{"Alias : "|coul('gras')}}{{o.hostAlias|join(', ')}}
|
{{"Alias : "|coul('gras')}}{{o.hostAlias|join(', ')}}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{"MAC : "|coul('gras')}}{{o.macAddress|join(', ')}}
|
{{"MAC : "|coul('gras')}}{{o.macAddress|join(', ')|const_of_mac}}
|
||||||
{{"IPv4 : "|coul('gras')}}{{o.ipHostNumber|join(', ')}}
|
{{"IPv4 : "|coul('gras')}}{{o.ipHostNumber|join(', ')}}
|
||||||
{{"IPv6 : "|coul('gras')}}{{o.ip6HostNumber|join(', ')}}
|
{{"IPv6 : "|coul('gras')}}{{o.ip6HostNumber|join(', ')}}
|
||||||
{{"DnsIpv6 : "|coul('gras')}}{% if not o.dnsIpv6 or o.dnsIpv6.0.value %}
|
{{"DnsIpv6 : "|coul('gras')}}{% if not o.dnsIpv6 or o.dnsIpv6.0.value %}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue