mirror of
https://github.com/LibreQoE/LibreQoS.git
synced 2025-02-25 18:55:32 -06:00
Code after testing and commenting
This commit is contained in:
@@ -149,6 +149,8 @@ class NetworkGraph:
|
||||
if not node.displayName in self.excludeSites:
|
||||
if node.displayName in self.exceptionCPEs.keys():
|
||||
node.parentId = self.exceptionCPEs[node.displayName]
|
||||
|
||||
# Checking the correctness of parent/children relationship before adding a node
|
||||
if self.validateParentChildren(node):
|
||||
self.nodes.append(node)
|
||||
else:
|
||||
@@ -216,14 +218,15 @@ class NetworkGraph:
|
||||
|
||||
def validateParentChildren(self, node:NetworkNode) -> bool:
|
||||
parentIndex = self.findNodeIndexById(node.parentId)
|
||||
# parent is set to null
|
||||
# parent is set to null or currently does not exist. Ignoring the case that parent does not exist to not make any
|
||||
# conflict with integratoionUISP.py and integrationSpylnx.py.
|
||||
if parentIndex == -1:
|
||||
return True
|
||||
|
||||
parentType = self.nodes[parentIndex].type
|
||||
|
||||
# Each device should have a client as parent
|
||||
if node.type== NodeType.device and parentType !=NodeType.client:
|
||||
if node.type == NodeType.device and parentType != NodeType.client:
|
||||
return False
|
||||
|
||||
# Each client or clientWithChildren should have ap, site or clientWithChildren as parent
|
||||
@@ -232,11 +235,11 @@ class NetworkGraph:
|
||||
return False
|
||||
|
||||
if node.type == NodeType.ap or node.type == NodeType.site:
|
||||
if parentType != NodeType.site or parentType !=NodeType.root:
|
||||
if parentType != NodeType.site or parentType != NodeType.root:
|
||||
return False
|
||||
|
||||
# Checking the root node type having no parent
|
||||
if node.type == NodeType.root and parentType != "":
|
||||
if node.type == NodeType.root and node.parentId != "":
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user