From 928aa3ef114ebf9246c90f9eae80da9a20172530 Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Sun, 15 May 2016 13:05:33 +0200 Subject: Add ip link support to mac local_macs, improove test result readability --- haircontrol/data.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'haircontrol/data.py') diff --git a/haircontrol/data.py b/haircontrol/data.py index d8195c7..6f5733d 100644 --- a/haircontrol/data.py +++ b/haircontrol/data.py @@ -5,9 +5,12 @@ class EtherDomain: self.mac2ip = {} def __repr__(self): + return '([\n%s\n],\n%s\n)'%(',\n'.join(' %s'%repr(e) for e in get_equipment_list_sorted()), repr(self.ip2mac)) + + def get_equipment_list_sorted(self): e_list = list(self.equipments.values()) e_list.sort(key=lambda x: x.name) - return '([\n%s\n],\n%s\n)'%(',\n'.join(' %s'%repr(e) for e in e_list), repr(self.ip2mac)) + return e_list def add_equipment(self,e): old = self.equipments.get(e.mgmtip) @@ -37,6 +40,7 @@ class Equipment: def add_seen_mac(self, ifname, mac): iface = self.ifaces.get(ifname) if not iface: + print("Warn : add_seen_mac(%s, %s) auto-create iface on %s"%(ifname, mac, self.name)) iface = Interface(ifname) self.ifaces[ifname] = iface iface.mac_seen.append(mac) @@ -48,5 +52,6 @@ class Interface: self.mac_seen = [] def __repr__(self): - return repr( ( self.mac, self.name, '[ %i mac_seen ]'%len(self.mac_seen) ) ) + return repr( ( self.mac, self.name, self.mac_seen ) ) + #return repr( ( self.mac, self.name, '[ %i mac_seen ]'%len(self.mac_seen) ) ) -- cgit v1.1