summaryrefslogtreecommitdiff
path: root/haircontrol/data.py
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2016-05-15 13:05:33 +0200
committerLudovic Pouzenc <ludovic@pouzenc.fr>2016-05-15 13:05:33 +0200
commit928aa3ef114ebf9246c90f9eae80da9a20172530 (patch)
treea30537ba248d023f863c0e61bdab8da73842d3ec /haircontrol/data.py
parent2e59a405596156412ff7240934071be76ec30301 (diff)
downloadhaircontrol-928aa3ef114ebf9246c90f9eae80da9a20172530.zip
haircontrol-928aa3ef114ebf9246c90f9eae80da9a20172530.tar.gz
haircontrol-928aa3ef114ebf9246c90f9eae80da9a20172530.tar.bz2
Add ip link support to mac local_macs, improove test result readability
Diffstat (limited to 'haircontrol/data.py')
-rw-r--r--haircontrol/data.py9
1 files changed, 7 insertions, 2 deletions
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) ) )