summaryrefslogtreecommitdiff
path: root/haircontrol/discovery.py
diff options
context:
space:
mode:
Diffstat (limited to 'haircontrol/discovery.py')
-rw-r--r--haircontrol/discovery.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/haircontrol/discovery.py b/haircontrol/discovery.py
index d6839b2..a9639be 100644
--- a/haircontrol/discovery.py
+++ b/haircontrol/discovery.py
@@ -179,3 +179,31 @@ class Discovery:
print("Notice: Nothing inspected on %s"%e)
i.disconnect()
+ def compute_neighbourhood(self):
+ print("**********compute_neighbourhood************")
+ # net.equipments[<mgmt_ip>].ifaces[<ifname>].mac_seen[i]
+
+ # Fake algorithm
+ random_e = '172.16.0.254'
+ for (mgmt_ip,e) in self.net.equipments.items():
+ for (ifname,i) in e.ifaces.items():
+ last = None
+ for mac_seen in i.mac_seen:
+ last = mac_seen
+ if last and last in self.net.mac2ip:
+ random_e = self.net.mac2ip[last]
+ i.direct_neighbours.append(random_e)
+
+# for (mgmt_ip,e) in self.net.equipments.items():
+# print("%s (%s)"%(mgmt_ip,e.name))
+# for (ifname,i) in e.ifaces.items():
+# print("\t%s"%i.name)
+# for mac_seen in i.mac_seen:
+# print("\t\tseen %s"%mac_seen)
+# for remote_mgmtip in i.direct_neighbours:
+# e = self.net.equipments[remote_mgmtip]
+# print("\t\tdirect_neighbour %s (%s)"%(remote_mgmtip, e.name))
+
+
+ print("**********compute_neighbourhood************")
+