From d7e4153ca72aa9b454d48eb4b24f1953488f3280 Mon Sep 17 00:00:00 2001 From: Thomas Davis Date: Wed, 28 Aug 2019 09:17:17 -0700 Subject: [PATCH] clean up the ipv6 address also by removing the interface information. --- netbox_agent/network.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/netbox_agent/network.py b/netbox_agent/network.py index aeba708..62e4395 100644 --- a/netbox_agent/network.py +++ b/netbox_agent/network.py @@ -63,13 +63,15 @@ class Network(): ip6_addr = netifaces.ifaddresses(interface).get(netifaces.AF_INET6) # netifaces returns a ipv6 netmask that netaddr does not understand. - # this strips the netmask down to the correct format for netaddr. + # this strips the netmask down to the correct format for netaddr, and remove the interface. # ie, this: # {'addr': 'fe80::ec4:7aff:fe59:ec4a%eno1.50', 'netmask': 'ffff:ffff:ffff:ffff::/64'} + # # becomes: - # {'addr': 'fe80::ec4:7aff:fe59:ec4a%eno1.50', 'netmask': 'ffff:ffff:ffff:ffff::'} + # {'addr': 'fe80::ec4:7aff:fe59:ec4a', 'netmask': 'ffff:ffff:ffff:ffff::'} # for addr in ip6_addr: + addr["addr"] = re.sub("\%.*$", "", addr["addr"]) addr["netmask"] = re.sub("/\d+$", "", addr["netmask"]) ip_addr.append(addr)