Handle with IDs, which are not appear in nodes list
This commit is contained in:
parent
bd1798195b
commit
e051d64780
14
graph.py
14
graph.py
|
@ -29,7 +29,7 @@ class Graph:
|
||||||
def parseLinks(self):
|
def parseLinks(self):
|
||||||
link_nodes = self.data['batadv']['nodes']
|
link_nodes = self.data['batadv']['nodes']
|
||||||
for link in self.data['batadv']['links']:
|
for link in self.data['batadv']['links']:
|
||||||
if 'node_id' in link_nodes[link['source']].keys() and 'node_id' in link_nodes[link['target']].keys():#else it is a vpn link
|
if 'node_id' in link_nodes[link['source']] and 'node_id' in link_nodes[link['target']]:#else it is a vpn link
|
||||||
if self.nodes_list[link_nodes[link['source']]['node_id']].isGateway == True or self.nodes_list[link_nodes[link['target']]['node_id']].isGateway:
|
if self.nodes_list[link_nodes[link['source']]['node_id']].isGateway == True or self.nodes_list[link_nodes[link['target']]['node_id']].isGateway:
|
||||||
self.setVpnLink(link['source'], link['target'])
|
self.setVpnLink(link['source'], link['target'])
|
||||||
else:
|
else:
|
||||||
|
@ -51,12 +51,12 @@ class Graph:
|
||||||
}
|
}
|
||||||
|
|
||||||
def setVpnLink(self, src, dst):
|
def setVpnLink(self, src, dst):
|
||||||
if 'node_id' not in self.data['batadv']['nodes'][src].keys() or self.nodes_list[self.data['batadv']['nodes'][src]['node_id']].isGateway == True:
|
if 'node_id' not in self.data['batadv']['nodes'][src] or (self.data['batadv']['nodes'][src]['node_id'] and self.nodes_list[self.data['batadv']['nodes'][src]['node_id']].isGateway == True):
|
||||||
if 'node_id' in self.data['batadv']['nodes'][dst]:
|
if 'node_id' in self.data['batadv']['nodes'][dst] and self.data['batadv']['nodes'][dst]['node_id']:
|
||||||
self.nodes_list[self.data['batadv']['nodes'][dst]['node_id']].stepsToVpn = 0
|
self.nodes_list[self.data['batadv']['nodes'][dst]['node_id']].stepsToVpn = 0
|
||||||
elif 'node_id' not in self.data['batadv']['nodes'][dst].keys() or self.nodes_list[self.data['batadv']['nodes'][dst]['node_id']].isGateway == True:
|
elif 'node_id' not in self.data['batadv']['nodes'][dst] or (self.data['batadv']['nodes'][dst]['node_id'] and self.nodes_list[self.data['batadv']['nodes'][dst]['node_id']].isGateway == True):
|
||||||
if 'node_id' in self.data['batadv']['nodes'][src]:
|
if 'node_id' in self.data['batadv']['nodes'][src] and self.data['batadv']['nodes'][src]['node_id']:
|
||||||
self.nodes_list[self.data['batadv']['nodes'][src]['node_id']].stepsToVpn = 0
|
self.nodes_list[self.data['batadv']['nodes'][src]['node_id']].stepsToVpn = 0
|
||||||
|
|
||||||
def calculateStepsToVpn(self):
|
def calculateStepsToVpn(self):
|
||||||
for node in self.nodes_list.itervalues():
|
for node in self.nodes_list.itervalues():
|
||||||
|
|
Loading…
Reference in a new issue