Robert Chacón 2023-02-06 19:44:48 -07:00 committed by GitHub
parent dee2c465be
commit ff40478eee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -537,6 +537,24 @@ def refreshShapers():
minDownload, minUpload = findBandwidthMins(network, 0) minDownload, minUpload = findBandwidthMins(network, 0)
logging.info("Found the bandwidth minimums for each node") logging.info("Found the bandwidth minimums for each node")
# Child nodes inherit bandwidth maximums of parents. We apply this here to avoid bugs when compression is applied with flattenA().
def inheritBandwidthMaxes(data, parentMaxDL, parentMaxUL):
for node in data:
if isinstance(node, str):
if (isinstance(data[node], dict)) and (node != 'children'):
# Cap based on this node's max bandwidth, or parent node's max bandwidth, whichever is lower
data[node]['downloadBandwidthMbps'] = min(data[node]['downloadBandwidthMbps'],parentMaxDL)
data[node]['uploadBandwidthMbps'] = min(data[node]['uploadBandwidthMbps'],parentMaxUL)
# Recursive call this function for children nodes attached to this node
if 'children' in data[node]:
# We need to keep tabs on the minor counter, because we can't have repeating class IDs. Here, we bring back the minor counter from the recursive function
inheritBandwidthMaxes(data[node]['children'], data[node]['downloadBandwidthMbps'], data[node]['uploadBandwidthMbps'])
#return data
# Here is the actual call to the recursive function
inheritBandwidthMaxes(network, parentMaxDL=upstreamBandwidthCapacityDownloadMbps, parentMaxUL=upstreamBandwidthCapacityUploadMbps)
# Compress network.json. HTB only supports 8 levels of HTB depth. Compress to 8 layers if beyond 8. # Compress network.json. HTB only supports 8 levels of HTB depth. Compress to 8 layers if beyond 8.
def flattenB(data): def flattenB(data):
newDict = {} newDict = {}