use primary mac as node id
parent
cc3b69d6be
commit
ccf4c96ae0
|
@ -7,7 +7,7 @@ class D3MapBuilder:
|
|||
def build(self):
|
||||
output = dict()
|
||||
|
||||
output['nodes'] = [{'group': x.group, 'name': x.name,
|
||||
output['nodes'] = [{'group': x.group, 'name': x.name, 'id': x.id,
|
||||
'macs': ', '.join(x.macs)
|
||||
} for x in self._db.get_nodes() if x.online]
|
||||
output['links'] = [{'source': x.pair[0], 'target': x.pair[1],
|
||||
|
|
1
node.py
1
node.py
|
@ -1,6 +1,7 @@
|
|||
class Node():
|
||||
def __init__(self):
|
||||
self.name = ""
|
||||
self.id = ""
|
||||
self.macs = set()
|
||||
self.group = 0
|
||||
self.online = False
|
||||
|
|
11
nodedb.py
11
nodedb.py
|
@ -98,6 +98,17 @@ class NodeDB:
|
|||
|
||||
self._links.add(tuple(sorted((a,b))))
|
||||
|
||||
for line in lines:
|
||||
x = json.loads(line)
|
||||
|
||||
if 'primary' in x:
|
||||
try:
|
||||
node = self.maybe_node_by_mac((x['primary'], ))
|
||||
except:
|
||||
continue
|
||||
|
||||
node.id = x['primary']
|
||||
|
||||
def import_aliases(self, aliases):
|
||||
for mac, alias in aliases.items():
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue