|
@@ -34,6 +34,13 @@ def dict_merge(a, b):
|
|
|
|
|
|
def merge_alfred_batman(alfreddata, batmandata):
|
|
|
merged = {}
|
|
|
+
|
|
|
+ batlookup = {}
|
|
|
+ for nodeid in batmandata:
|
|
|
+ batlookup[nodeid] = nodeid
|
|
|
+ for bda in batmandata[nodeid]['aliases']:
|
|
|
+ batlookup[bda] = nodeid
|
|
|
+
|
|
|
for nodeid in alfreddata:
|
|
|
nodeinfo = alfreddata[nodeid]
|
|
|
candidates = set()
|
|
@@ -43,7 +50,17 @@ def merge_alfred_batman(alfreddata, batmandata):
|
|
|
for mac in nodeinfo['macs']:
|
|
|
candidates.add(mac2id(mac))
|
|
|
|
|
|
- for candidate in candidates:
|
|
|
+ if 'network' in nodeinfo:
|
|
|
+ n = nodeinfo['network']
|
|
|
+ if 'mac' in n: candidates.add(mac2id(n['mac']))
|
|
|
+ if 'mesh_interfaces' in n:
|
|
|
+ for mac in n['mesh_interfaces']:
|
|
|
+ candidates.add(mac2id(mac))
|
|
|
+
|
|
|
+ if not 'neighbours' in nodeinfo: nodeinfo['neighbours'] = []
|
|
|
+
|
|
|
+ for candidate_raw in candidates:
|
|
|
+ candidate = batlookup[candidate_raw] if candidate_raw in batlookup else candidate_raw
|
|
|
if candidate in batmandata:
|
|
|
nodeinfo = dict_merge(nodeinfo, batmandata[candidate])
|
|
|
|