mirror of
https://github.com/LibreQoE/LibreQoS.git
synced 2025-02-25 18:55:32 -06:00
Merge pull request #318 from LibreQoE/uispChanges
UISP Integration Improvements
This commit is contained in:
commit
1b63032086
@ -2,7 +2,7 @@
|
|||||||
# integrations.
|
# integrations.
|
||||||
|
|
||||||
from typing import List, Any
|
from typing import List, Any
|
||||||
from ispConfig import allowedSubnets, ignoreSubnets, generatedPNUploadMbps, generatedPNDownloadMbps, circuitNameUseAddress
|
from ispConfig import allowedSubnets, ignoreSubnets, generatedPNUploadMbps, generatedPNDownloadMbps, circuitNameUseAddress, upstreamBandwidthCapacityDownloadMbps, upstreamBandwidthCapacityUploadMbps
|
||||||
import ipaddress
|
import ipaddress
|
||||||
import enum
|
import enum
|
||||||
|
|
||||||
@ -290,7 +290,17 @@ class NetworkGraph:
|
|||||||
child)
|
child)
|
||||||
|
|
||||||
del self.__visited
|
del self.__visited
|
||||||
|
|
||||||
|
def inheritBandwidthMaxes(data, parentMaxDL, parentMaxUL):
|
||||||
|
for node in data:
|
||||||
|
if isinstance(node, str):
|
||||||
|
if (isinstance(data[node], dict)) and (node != 'children'):
|
||||||
|
data[node]['downloadBandwidthMbps'] = min(int(data[node]['downloadBandwidthMbps']),int(parentMaxDL))
|
||||||
|
data[node]['uploadBandwidthMbps'] = min(int(data[node]['uploadBandwidthMbps']),int(parentMaxUL))
|
||||||
|
if 'children' in data[node]:
|
||||||
|
inheritBandwidthMaxes(data[node]['children'], data[node]['downloadBandwidthMbps'], data[node]['uploadBandwidthMbps'])
|
||||||
|
inheritBandwidthMaxes(topLevelNode, parentMaxDL=upstreamBandwidthCapacityDownloadMbps, parentMaxUL=upstreamBandwidthCapacityUploadMbps)
|
||||||
|
|
||||||
with open('network.json', 'w') as f:
|
with open('network.json', 'w') as f:
|
||||||
json.dump(topLevelNode, f, indent=4)
|
json.dump(topLevelNode, f, indent=4)
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ def buildFullGraph():
|
|||||||
download = int(download)
|
download = int(download)
|
||||||
upload = int(upload)
|
upload = int(upload)
|
||||||
siteBandwidth[name] = {"download": download, "upload": upload}
|
siteBandwidth[name] = {"download": download, "upload": upload}
|
||||||
|
|
||||||
# Find AP capacities from UISP
|
# Find AP capacities from UISP
|
||||||
for device in devices:
|
for device in devices:
|
||||||
if device['identification']['role'] == "ap":
|
if device['identification']['role'] == "ap":
|
||||||
@ -110,7 +110,27 @@ def buildFullGraph():
|
|||||||
upload = int(device['overview']['uplinkCapacity'] / 1000000)
|
upload = int(device['overview']['uplinkCapacity'] / 1000000)
|
||||||
siteBandwidth[device['identification']['name']] = {
|
siteBandwidth[device['identification']['name']] = {
|
||||||
"download": download, "upload": upload}
|
"download": download, "upload": upload}
|
||||||
|
|
||||||
|
# Find Site Capacities by AirFiber capacities
|
||||||
|
foundAirFibersBySite = {}
|
||||||
|
for device in devices:
|
||||||
|
if device['identification']['site']['type'] == 'site':
|
||||||
|
if device['identification']['role'] == "station":
|
||||||
|
if device['identification']['type'] == "airFiber":
|
||||||
|
if device['overview']['status'] == 'active':
|
||||||
|
download = int(device['overview']['downlinkCapacity']/ 1000000)
|
||||||
|
upload = int(device['overview']['uplinkCapacity']/ 1000000)
|
||||||
|
# Make sure to use half of reported bandwidth for AF60-LRs
|
||||||
|
if device['identification']['model'] == "AF60-LR":
|
||||||
|
download = int(download / 2)
|
||||||
|
upload = int(download / 2)
|
||||||
|
if device['identification']['site']['id'] in foundAirFibersBySite:
|
||||||
|
if (download > foundAirFibersBySite['download']) or (upload > foundAirFibersBySite['upload']):
|
||||||
|
foundAirFibersBySite[device['identification']['site']['id']]['download'] = download
|
||||||
|
foundAirFibersBySite[device['identification']['site']['id']]['upload'] = upload
|
||||||
|
else:
|
||||||
|
foundAirFibersBySite[device['identification']['site']['id']] = {'download': download, 'upload': upload}
|
||||||
|
|
||||||
print("Building Topology")
|
print("Building Topology")
|
||||||
net = NetworkGraph()
|
net = NetworkGraph()
|
||||||
# Add all sites and client sites
|
# Add all sites and client sites
|
||||||
@ -133,6 +153,9 @@ def buildFullGraph():
|
|||||||
# Use the CSV bandwidth values
|
# Use the CSV bandwidth values
|
||||||
download = siteBandwidth[name]["download"]
|
download = siteBandwidth[name]["download"]
|
||||||
upload = siteBandwidth[name]["upload"]
|
upload = siteBandwidth[name]["upload"]
|
||||||
|
elif id in foundAirFibersBySite:
|
||||||
|
download = foundAirFibersBySite[id]['download']
|
||||||
|
upload = foundAirFibersBySite[id]['upload']
|
||||||
else:
|
else:
|
||||||
# Add them just in case
|
# Add them just in case
|
||||||
siteBandwidth[name] = {
|
siteBandwidth[name] = {
|
||||||
@ -209,7 +232,8 @@ def buildFullGraph():
|
|||||||
|
|
||||||
# Save integrationUISPbandwidths.csv
|
# Save integrationUISPbandwidths.csv
|
||||||
# (the newLine fixes generating extra blank lines)
|
# (the newLine fixes generating extra blank lines)
|
||||||
with open('integrationUISPbandwidths.csv', 'w', newline='') as csvfile:
|
# Saves as .template as to not overwrite
|
||||||
|
with open('integrationUISPbandwidths.template.csv', 'w', newline='') as csvfile:
|
||||||
wr = csv.writer(csvfile, quoting=csv.QUOTE_ALL)
|
wr = csv.writer(csvfile, quoting=csv.QUOTE_ALL)
|
||||||
wr.writerow(['ParentNode', 'Download Mbps', 'Upload Mbps'])
|
wr.writerow(['ParentNode', 'Download Mbps', 'Upload Mbps'])
|
||||||
for device in siteBandwidth:
|
for device in siteBandwidth:
|
||||||
|
Loading…
Reference in New Issue
Block a user