use primary mac as node id
This commit is contained in:
parent
cc3b69d6be
commit
ccf4c96ae0
|
@ -7,7 +7,7 @@ class D3MapBuilder:
|
||||||
def build(self):
|
def build(self):
|
||||||
output = dict()
|
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)
|
'macs': ', '.join(x.macs)
|
||||||
} for x in self._db.get_nodes() if x.online]
|
} for x in self._db.get_nodes() if x.online]
|
||||||
output['links'] = [{'source': x.pair[0], 'target': x.pair[1],
|
output['links'] = [{'source': x.pair[0], 'target': x.pair[1],
|
||||||
|
|
1
node.py
1
node.py
|
@ -1,6 +1,7 @@
|
||||||
class Node():
|
class Node():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.name = ""
|
self.name = ""
|
||||||
|
self.id = ""
|
||||||
self.macs = set()
|
self.macs = set()
|
||||||
self.group = 0
|
self.group = 0
|
||||||
self.online = False
|
self.online = False
|
||||||
|
|
11
nodedb.py
11
nodedb.py
|
@ -98,6 +98,17 @@ class NodeDB:
|
||||||
|
|
||||||
self._links.add(tuple(sorted((a,b))))
|
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):
|
def import_aliases(self, aliases):
|
||||||
for mac, alias in aliases.items():
|
for mac, alias in aliases.items():
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue