diff --git a/v1.3/integrationCommon.py b/v1.3/integrationCommon.py index 5943fd43..7ae7a256 100644 --- a/v1.3/integrationCommon.py +++ b/v1.3/integrationCommon.py @@ -150,6 +150,29 @@ class NetworkGraph: if self.nodes[child].type != NodeType.device: node.type = NodeType.clientWithChildren + def clientsWithChildrenToSites(self) -> None: + toAdd = [] + for (i, node) in enumerate(self.nodes): + if node.type == NodeType.clientWithChildren: + siteNode = NetworkNode( + id=node.id + "_gen", + displayName="(Site) " + node.displayName, + type = NodeType.site + ) + siteNode.parentIndex = node.parentIndex + node.parentId = siteNode.id + if node.type == NodeType.clientWithChildren: + node.type = NodeType.client + for child in self.findChildIndices(i): + if self.nodes[child].type == NodeType.client or self.nodes[child].type == NodeType.clientWithChildren or self.nodes[child].type == NodeType.site: + self.nodes[child].parentId = siteNode.id + toAdd.append(siteNode) + + for n in toAdd: + self.addRawNode(n) + + self.reparentById() + def findUnconnectedNodes(self) -> List: # Performs a tree-traversal and finds any nodes that # aren't connected to the root. This is a "sanity check", diff --git a/v1.3/integrationUISP.py b/v1.3/integrationUISP.py index 72bdd304..935feaa5 100644 --- a/v1.3/integrationUISP.py +++ b/v1.3/integrationUISP.py @@ -322,6 +322,7 @@ def importFromUISP(): net.reparentById() net.promoteClientsWithChildren() + net.clientsWithChildrenToSites() net.reconnectUnconnected() net.plotNetworkGraph(False) net.createNetworkJson()