From 912099cf3d4cf8ebf4f3f06c98e0d33d0b960e75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Chac=C3=B3n?= Date: Mon, 27 Feb 2023 16:57:30 -0700 Subject: [PATCH] Fix pertaining to https://github.com/LibreQoE/LibreQoS/issues/273 Ensure client is active before attempting to pull plan info --- old/v1.3/integrationSplynx.py | 71 ++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/old/v1.3/integrationSplynx.py b/old/v1.3/integrationSplynx.py index 0e56af8b..f8b24a23 100644 --- a/old/v1.3/integrationSplynx.py +++ b/old/v1.3/integrationSplynx.py @@ -70,44 +70,45 @@ def createShaper(): # 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: - services = spylnxRequest("admin/customers/customer/" + customerJson["id"] + "/internet-services", headers) - for serviceJson in services: - combinedId = "c_" + str(customerJson["id"]) + "_s_" + str(serviceJson["id"]) - tariff_id = serviceJson['tariff_id'] - customer = NetworkNode( - type=NodeType.client, - id=combinedId, - displayName=customerJson["name"], - address=combineAddress(customerJson), - download=downloadForTariffID[tariff_id], - upload=uploadForTariffID[tariff_id], - ) - net.addRawNode(customer) + if customerJson['status'] == 'active': + services = spylnxRequest("admin/customers/customer/" + customerJson["id"] + "/internet-services", headers) + for serviceJson in services: + combinedId = "c_" + str(customerJson["id"]) + "_s_" + str(serviceJson["id"]) + tariff_id = serviceJson['tariff_id'] + customer = NetworkNode( + type=NodeType.client, + id=combinedId, + displayName=customerJson["name"], + address=combineAddress(customerJson), + download=downloadForTariffID[tariff_id], + upload=uploadForTariffID[tariff_id], + ) + net.addRawNode(customer) - ipv4 = '' - ipv6 = '' - routerID = serviceJson['router_id'] - # If not "Taking IPv4" (Router will assign IP), then use router's set IP - if serviceJson['taking_ipv4'] == 0: - ipv4 = ipForRouter[routerID] - elif serviceJson['taking_ipv4'] == 1: - ipv4 = serviceJson['ipv4'] - # If not "Taking IPv6" (Router will assign IP), then use router's set IP - if serviceJson['taking_ipv6'] == 0: + ipv4 = '' ipv6 = '' - elif serviceJson['taking_ipv6'] == 1: - ipv6 = serviceJson['ipv6'] + routerID = serviceJson['router_id'] + # If not "Taking IPv4" (Router will assign IP), then use router's set IP + if serviceJson['taking_ipv4'] == 0: + ipv4 = ipForRouter[routerID] + elif serviceJson['taking_ipv4'] == 1: + ipv4 = serviceJson['ipv4'] + # If not "Taking IPv6" (Router will assign IP), then use router's set IP + if serviceJson['taking_ipv6'] == 0: + ipv6 = '' + elif serviceJson['taking_ipv6'] == 1: + ipv6 = serviceJson['ipv6'] - device = NetworkNode( - id=combinedId+"_d" + str(serviceJson["id"]), - displayName=serviceJson["description"], - type=NodeType.device, - parentId=combinedId, - mac=serviceJson["mac"], - ipv4=[ipv4], - ipv6=[ipv6] - ) - net.addRawNode(device) + device = NetworkNode( + id=combinedId+"_d" + str(serviceJson["id"]), + displayName=serviceJson["description"], + type=NodeType.device, + parentId=combinedId, + mac=serviceJson["mac"], + ipv4=[ipv4], + ipv6=[ipv6] + ) + net.addRawNode(device) net.prepareTree() net.plotNetworkGraph(False)