fix(network): use netifaces2

This commit is contained in:
clbu 2024-10-16 10:54:40 +02:00
parent 514627aa72
commit de88ca85b9
No known key found for this signature in database
GPG key ID: 0891443A5398527F
2 changed files with 3 additions and 3 deletions

View file

@ -81,7 +81,7 @@ class Network(object):
# #
for addr in ip6_addr: for addr in ip6_addr:
addr["addr"] = addr["addr"].replace('%{}'.format(interface), '') addr["addr"] = addr["addr"].replace('%{}'.format(interface), '')
addr["netmask"] = addr["netmask"].split('/')[0] addr["mask"] = addr["mask"].split('/')[0]
ip_addr.append(addr) ip_addr.append(addr)
mac = open('/sys/class/net/{}/address'.format(interface), 'r').read().strip() mac = open('/sys/class/net/{}/address'.format(interface), 'r').read().strip()
@ -109,7 +109,7 @@ class Network(object):
'ip': [ 'ip': [
'{}/{}'.format( '{}/{}'.format(
x['addr'], x['addr'],
IPAddress(x['netmask']).netmask_bits() IPAddress(x['mask']).netmask_bits()
) for x in ip_addr ) for x in ip_addr
] if ip_addr else None, # FIXME: handle IPv6 addresses ] if ip_addr else None, # FIXME: handle IPv6 addresses
'ethtool': Ethtool(interface).parse(), 'ethtool': Ethtool(interface).parse(),

View file

@ -1,6 +1,6 @@
pynetbox==7.3.4 pynetbox==7.3.4
netaddr==1.3.0 netaddr==1.3.0
netifaces==0.11.0 netifaces2==0.0.22
pyyaml==6.0.1 pyyaml==6.0.1
jsonargparse==4.32.0 jsonargparse==4.32.0
python-slugify==8.0.4 python-slugify==8.0.4