summaryrefslogtreecommitdiff
path: root/haircontrol/discovery.py
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2016-06-02 23:39:10 +0200
committerLudovic Pouzenc <ludovic@pouzenc.fr>2016-06-02 23:39:10 +0200
commit41eaecd927452eda97875d388f12da2009d6a6cf (patch)
tree2f717e12fcf6562683a7815c84ea7caf339309ea /haircontrol/discovery.py
parent57be36071e3adcb8c7d59f096cfb82d2f47ce8c5 (diff)
downloadhaircontrol-41eaecd927452eda97875d388f12da2009d6a6cf.zip
haircontrol-41eaecd927452eda97875d388f12da2009d6a6cf.tar.gz
haircontrol-41eaecd927452eda97875d388f12da2009d6a6cf.tar.bz2
Make room for direct_neighbours, add inter.py for use in interactive python shell.
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************")
+