Merge pull request #434 from LibreQoE/rchac-patch-9

Splynx Integration Speedup
This commit is contained in:
Robert Chacón 2023-12-08 14:07:54 -07:00 committed by GitHub
commit 7726c94055
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -50,7 +50,6 @@ def getRouters(headers):
for router in data:
routerID = router['id']
ipForRouter[routerID] = router['ip']
print("Router IPs found: " + str(len(ipForRouter)))
return ipForRouter
@ -62,6 +61,10 @@ def combineAddress(json):
else:
return json["street_1"] + " " + json["city"] + " " + json["zip_code"]
def getAllServices(headers):
services = spylnxRequest("admin/customers/customer/0/internet-services?main_attributes%5Bstatus%5D=active", headers)
return services
def createShaper():
net = NetworkGraph()
@ -70,15 +73,21 @@ def createShaper():
tariff, downloadForTariffID, uploadForTariffID = getTariffs(headers)
customers = getCustomers(headers)
ipForRouter = getRouters(headers)
allServices = getAllServices(headers)
allServicesDict = {}
for serviceItem in allServices:
if (serviceItem['status'] == 'active'):
allServicesDict[serviceItem["id"]] = serviceItem
#It's not very clear how a service is meant to handle multiple
#devices on a shared tariff. Creating each service as a combined
#entity including the customer, to be on the safe side.
for customerJson in customers:
if customerJson['status'] == 'active':
services = spylnxRequest("admin/customers/customer/" + customerJson["id"] + "/internet-services", headers)
for serviceJson in services:
if (serviceJson['status'] == 'active'):
if customerJson['id'] in allServicesDict:
serviceJson = allServicesDict[customerJson['id']]
#print(serviceJson)
combinedId = "c_" + str(customerJson["id"]) + "_s_" + str(serviceJson["id"])
tariff_id = serviceJson['tariff_id']
customer = NetworkNode(
@ -107,6 +116,7 @@ def createShaper():
elif taking_ipv4 == 1:
ipv4 = serviceJson['ipv4']
# If not "Taking IPv6" (Router will assign IP), then use router's set IP
if isinstance(serviceJson['taking_ipv6'], str):
taking_ipv6 = int(serviceJson['taking_ipv6'])