Add auto-promotion of client with child sites; a new site is inserted and the children rearranged to preserve speed limits in a sane manner (so a shared relay can have X for one customer, Y for another and Z as a limit)

Signed-off-by: Herbert Wolverson <herberticus@gmail.com>
This commit is contained in:
Herbert Wolverson
2022-10-28 11:33:16 -05:00
parent a155862bc9
commit cfc136de8f
2 changed files with 24 additions and 0 deletions

View File

@@ -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",

View File

@@ -322,6 +322,7 @@ def importFromUISP():
net.reparentById()
net.promoteClientsWithChildren()
net.clientsWithChildrenToSites()
net.reconnectUnconnected()
net.plotNetworkGraph(False)
net.createNetworkJson()