add online attribut to Node
This commit is contained in:
parent
b97492f6c7
commit
c67fcfd09c
|
@ -32,6 +32,7 @@ class Node():
|
||||||
self.name = ""
|
self.name = ""
|
||||||
self.macs = set()
|
self.macs = set()
|
||||||
self.group = 0
|
self.group = 0
|
||||||
|
self.online = False
|
||||||
# groups:
|
# groups:
|
||||||
# 0 normal node
|
# 0 normal node
|
||||||
# 1 aftermath
|
# 1 aftermath
|
||||||
|
@ -68,6 +69,7 @@ for line in lines:
|
||||||
node = maybe_node_by_mac(nodes, (x['of'], x['secondary']))
|
node = maybe_node_by_mac(nodes, (x['of'], x['secondary']))
|
||||||
except:
|
except:
|
||||||
node = Node()
|
node = Node()
|
||||||
|
node.online = True
|
||||||
nodes.append(node)
|
nodes.append(node)
|
||||||
|
|
||||||
node.add_mac(x['of'])
|
node.add_mac(x['of'])
|
||||||
|
@ -81,6 +83,7 @@ for line in lines:
|
||||||
node = maybe_node_by_mac(nodes, (x['router'], ))
|
node = maybe_node_by_mac(nodes, (x['router'], ))
|
||||||
except:
|
except:
|
||||||
node = Node()
|
node = Node()
|
||||||
|
node.online = True
|
||||||
node.add_mac(x['router'])
|
node.add_mac(x['router'])
|
||||||
nodes.append(node)
|
nodes.append(node)
|
||||||
|
|
||||||
|
@ -91,6 +94,7 @@ for line in lines:
|
||||||
node = maybe_node_by_mac(nodes, (x['neighbor'], ))
|
node = maybe_node_by_mac(nodes, (x['neighbor'], ))
|
||||||
except:
|
except:
|
||||||
node = Node()
|
node = Node()
|
||||||
|
node.online = True
|
||||||
if x['label'] == 'TT':
|
if x['label'] == 'TT':
|
||||||
node.group = 3
|
node.group = 3
|
||||||
|
|
||||||
|
@ -149,14 +153,13 @@ def map_link(nodes, pair):
|
||||||
link.strength = strength
|
link.strength = strength
|
||||||
return link
|
return link
|
||||||
|
|
||||||
|
|
||||||
links = [map_link(nodes, x) for x in links]
|
links = [map_link(nodes, x) for x in links]
|
||||||
|
|
||||||
output = dict()
|
output = dict()
|
||||||
|
|
||||||
output['nodes'] = [{'group': x.group, 'name': x.name,
|
output['nodes'] = [{'group': x.group, 'name': x.name,
|
||||||
'macs': ', '.join(x.macs)
|
'macs': ', '.join(x.macs)
|
||||||
} for x in nodes]
|
} for x in nodes if x.online]
|
||||||
output['links'] = [{'source': x.pair[0], 'target': x.pair[1],
|
output['links'] = [{'source': x.pair[0], 'target': x.pair[1],
|
||||||
'distance': x.distance,
|
'distance': x.distance,
|
||||||
'strength': x.strength
|
'strength': x.strength
|
||||||
|
|
Loading…
Reference in a new issue