mirror of
https://github.com/LibreQoE/LibreQoS.git
synced 2025-02-25 18:55:32 -06:00
Allow integrationUISProutes.csv to override default costs in UISP route determination.
Requested by D. Denson. Now that the UISP network tree is built as a spanning tree, with 10 cost per hop we can reliably flip the tree from A->B->C to C->B->A depending upon root positioning. This addition allows you to specify additional routes (that MUST exist!) e.g. A->C and specify a cost to use instead of the default 10. This allows for topologies in which A-B-C is actually faster than a direct A-C route (for example, becuase of short 60ghz hops).
This commit is contained in:
parent
2d3874e812
commit
6df648e299
@ -192,9 +192,14 @@ def debugSpaces(n):
|
||||
spaces = spaces + " "
|
||||
return spaces
|
||||
|
||||
def walkGraphOutwards(siteList, root):
|
||||
def walkGraphOutwards(siteList, root, routeOverrides):
|
||||
def walkGraph(node, parent, cost, backPath):
|
||||
site = findInSiteListById(siteList, node)
|
||||
routeName = parent['name'] + "->" + site['name']
|
||||
if routeName in routeOverrides:
|
||||
# We have an overridden cost for this route, so use it instead
|
||||
#print("--> Using overridden cost for " + routeName + ". New cost: " + str(routeOverrides[routeName]) + ".")
|
||||
cost = routeOverrides[routeName]
|
||||
if cost < site['cost']:
|
||||
# It's cheaper to get here this way, so update the cost and parent.
|
||||
site['cost'] = cost
|
||||
@ -213,7 +218,20 @@ def walkGraphOutwards(siteList, root):
|
||||
# Force the parent since we're at the top
|
||||
site = findInSiteListById(siteList, connection)
|
||||
site['parent'] = root['id']
|
||||
walkGraph(connection, root, 20, [root['id']])
|
||||
walkGraph(connection, root, 10, [root['id']])
|
||||
|
||||
def loadRoutingOverrides():
|
||||
# Loads integrationUISProutes.csv and returns a set of "from", "to", "cost"
|
||||
overrides = {}
|
||||
if os.path.isfile("integrationUISProutes.csv"):
|
||||
with open("integrationUISProutes.csv", "r") as f:
|
||||
reader = csv.reader(f)
|
||||
for row in reader:
|
||||
if not row[0].startswith("#") and len(row) == 3:
|
||||
fromSite, toSite, cost = row
|
||||
overrides[fromSite.strip() + "->" + toSite.strip()] = int(cost)
|
||||
#print(overrides)
|
||||
return overrides
|
||||
|
||||
def buildFullGraph():
|
||||
# Attempts to build a full network graph, incorporating as much of the UISP
|
||||
@ -235,10 +253,11 @@ def buildFullGraph():
|
||||
# Create a list of just network sites
|
||||
siteList = buildSiteList(sites, dataLinks)
|
||||
rootSite = findInSiteList(siteList, uispSite)
|
||||
routeOverrides = loadRoutingOverrides()
|
||||
if rootSite is None:
|
||||
print("ERROR: Unable to find root site in UISP")
|
||||
return
|
||||
walkGraphOutwards(siteList, rootSite)
|
||||
walkGraphOutwards(siteList, rootSite, routeOverrides)
|
||||
# Debug code: dump the list of site parents
|
||||
# for s in siteList:
|
||||
# if s['parent'] == "":
|
||||
|
5
src/integrationUISProutes.csv
Normal file
5
src/integrationUISProutes.csv
Normal file
@ -0,0 +1,5 @@
|
||||
# Allows you to override route costs in the UISP integration, to better
|
||||
# represent your network. Costs by default increment 10 at each hop.
|
||||
# So if you want to skip 10 links, put a cost of 100 in.
|
||||
# From Site Name, To Site Name, New Cost
|
||||
# MYCORE, MYTOWER, 100
|
|
Loading…
Reference in New Issue
Block a user