Add warnings, try to troubleshoot issue 273

This commit is contained in:
Robert Chacón
2023-03-03 18:30:17 -07:00
committed by GitHub
parent 99dc9fc066
commit 38fba4a0a4

View File

@@ -1,6 +1,7 @@
from pythonCheck import checkPythonVersion
checkPythonVersion()
import requests
import warnings
from ispConfig import excludeSites, findIPv6usingMikrotik, bandwidthOverheadFactor, exceptionCPEs, splynx_api_key, splynx_api_secret, splynx_api_url
from integrationCommon import isIpv4Permitted
import base64
@@ -49,6 +50,8 @@ def getRouters(headers):
for router in data:
routerID = router['id']
ipForRouter[routerID] = router['ip']
print("Router IPs found: " + str(len(ipForRouter)))
return ipForRouter
def combineAddress(json):
@@ -92,12 +95,14 @@ def createShaper():
ipv6 = ''
routerID = serviceJson['router_id']
# If not "Taking IPv4" (Router will assign IP), then use router's set IP
if isinstance(serviceJson['taking_ipv4'], str):
taking_ipv4 = int(serviceJson['taking_ipv4'])
else:
taking_ipv4 = serviceJson['taking_ipv4']
# Debug
taking_ipv4 = int(serviceJson['taking_ipv4'])
if taking_ipv4 == 0:
ipv4 = ipForRouter[routerID]
try:
ipv4 = ipForRouter[routerID]
except:
warnings.warn("taking_ipv4 was 0 for client " + combinedId + " but router ID was not found in ipForRouter", stacklevel=2)
ipv4 = ''
elif taking_ipv4 == 1:
ipv4 = serviceJson['ipv4']