From c92dcf986bb67c097c536665bcd009674a1dfced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Chac=C3=B3n?= Date: Sun, 15 May 2022 18:12:03 -0600 Subject: [PATCH 1/2] Update LibreQoS.py Fixed error: tabs spacing for print output was merged from v1.1, but not defined in v1.0. Removed calls mentioning tabs --- v1.0/LibreQoS.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/v1.0/LibreQoS.py b/v1.0/LibreQoS.py index 4f2c70e9..971d76eb 100644 --- a/v1.0/LibreQoS.py +++ b/v1.0/LibreQoS.py @@ -248,10 +248,8 @@ def refreshShapers(): if '/' in device['ipv4']: hosts = list(ipaddress.ip_network(device['ipv4']).hosts()) for host in hosts: - print(tabs + ' ', end='') shell('./xdp-cpumap-tc/src/xdp_iphash_to_cpu_cmdline --add --ip ' + str(host) + ' --cpu ' + str(currentQueueCounter-1) + ' --classid ' + flowIDstring) else: - print(tabs + ' ', end='') shell('./xdp-cpumap-tc/src/xdp_iphash_to_cpu_cmdline --add --ip ' + device['ipv4'] + ' --cpu ' + str(currentQueueCounter-1) + ' --classid ' + flowIDstring) #Once XDP-CPUMAP-TC handles IPv6, this can be added #if device['ipv6']: @@ -300,10 +298,8 @@ def refreshShapers(): if '/' in device['ipv4']: hosts = list(ipaddress.ip_network(device['ipv4']).hosts()) for host in hosts: - print(tabs + ' ', end='') shell('./xdp-cpumap-tc/src/xdp_iphash_to_cpu_cmdline --add --ip ' + str(host) + ' --cpu ' + str(currentQueueCounter-1) + ' --classid ' + flowIDstring) else: - print(tabs + ' ', end='') shell('./xdp-cpumap-tc/src/xdp_iphash_to_cpu_cmdline --add --ip ' + device['ipv4'] + ' --cpu ' + str(currentQueueCounter-1) + ' --classid ' + flowIDstring) #Once XDP-CPUMAP-TC handles IPv6, this can be added #if device['ipv6']: From 2f7c632f543e1395e82aec11ecc1100e99a60664 Mon Sep 17 00:00:00 2001 From: Warren Date: Mon, 20 Jun 2022 21:47:10 +1200 Subject: [PATCH 2/2] minor/pep related adjustments --- v1.1/integrationUISP.py | 8 ++++---- v1.1/ispConfig.py | 18 ++++++++++-------- v1.1/scheduled.py | 33 ++++++++++++++++----------------- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/v1.1/integrationUISP.py b/v1.1/integrationUISP.py index fb280941..135435dd 100644 --- a/v1.1/integrationUISP.py +++ b/v1.1/integrationUISP.py @@ -1,7 +1,7 @@ import requests import csv import ipaddress -from ispConfig import UISPbaseURL, uispAuthToken, shapeRouterOrStation, ignoreSubnets +from ispConfig import uispBaseURL, uispAuthToken, shapeRouterOrStation, ignoreSubnets import shutil stationModels = ['LBE-5AC-Gen2', 'LBE-5AC-Gen2', 'LBE-5AC-LR', 'AF-LTU5', 'AFLTULR', 'AFLTUPro', 'LTU-LITE'] @@ -10,7 +10,7 @@ routerModels = ['ACB-AC', 'ACB-ISP'] def pullShapedDevices(): devices = [] uispSitesToImport = [] - url = UISPbaseURL + "/nms/api/v2.1/sites?type=client&ucrm=true&ucrmDetails=true" + url = uispBaseURL + "/nms/api/v2.1/sites?type=client&ucrm=true&ucrmDetails=true" headers = {'accept':'application/json', 'x-auth-token': uispAuthToken} r = requests.get(url, headers=headers) jsonData = r.json() @@ -70,8 +70,8 @@ def pullShapedDevices(): return devices def getUISPdevicesAtClientSite(siteID): - url = UISPbaseURL + "/nms/api/v2.1/devices?siteId=" + siteID - headers = {'accept':'application/json', 'x-auth-token': uispAuthToken} + url = uispBaseURL + "/nms/api/v2.1/devices?siteId=" + siteID + headers = {'accept':'application/json', 'x-auth-token': UISPuthToken} r = requests.get(url, headers=headers) return (r.json()) diff --git a/v1.1/ispConfig.py b/v1.1/ispConfig.py index a6c375e2..826269e2 100644 --- a/v1.1/ispConfig.py +++ b/v1.1/ispConfig.py @@ -1,7 +1,7 @@ -#'fq_codel' or 'cake diffserv4' -#'cake diffserv4' is recommended +# 'fq_codel' or 'cake diffserv4' +# 'cake diffserv4' is recommended -#fqOrCAKE = 'fq_codel' +# fqOrCAKE = 'fq_codel' fqOrCAKE = 'cake diffserv4' # How many Mbps are available to the edge of this network @@ -21,13 +21,14 @@ interfaceB = 'eth2' # Shape by Site in addition to by AP and Client shapeBySite = True -# Allow shell commands. False causes commands print to console only without being executed. MUST BE ENABLED FOR PROGRAM TO FUNCTION +# Allow shell commands. False causes commands print to console only without being executed. MUST BE ENABLED FOR +# PROGRAM TO FUNCTION enableActualShellCommands = True # Add 'sudo' before execution of any shell commands. May be required depending on distribution and environment. runShellCommandsAsSudo = False -#Graphing +# Graphing graphingEnabled = True ppingLocation = "pping" influxDBurl = "http://localhost:8086" @@ -36,16 +37,17 @@ influxDBOrg = "Your ISP Name Here" influxDBtoken = "" # NMS/CRM Integration -# If a device shows a WAN IP wihtin these subnets, assume they are behind NAT / un-shapable, and ignore them +# If a device shows a WAN IP within these subnets, assume they are behind NAT / un-shapable, and ignore them ignoreSubnets = ['192.168.0.0/16'] # Optional UISP integration automaticImportUISP = False # Everything before /nms/ on your UISP instance -UISPbaseURL = 'https://examplesite.com' +uispBaseURL = 'https://examplesite.com' # UISP Auth Token uispAuthToken = '' -# UISP | Whether to shape router at customer premises, or instead shape the station radio. When station radio is in router mode, use 'station'. Otherwise, use 'router'. +# UISP | Whether to shape router at customer premises, or instead shape the station radio. When station radio is in +# router mode, use 'station'. Otherwise, use 'router'. shapeRouterOrStation = 'router' # API Auth diff --git a/v1.1/scheduled.py b/v1.1/scheduled.py index 5a42a210..7da95fc0 100644 --- a/v1.1/scheduled.py +++ b/v1.1/scheduled.py @@ -1,27 +1,26 @@ import time import schedule -from datetime import date from LibreQoS import refreshShapers from graphBandwidth import refreshBandwidthGraphs from graphLatency import refreshLatencyGraphs from ispConfig import graphingEnabled, automaticImportUISP from integrationUISP import updateFromUISP -def importAndShape(): - if automaticImportUISP: - updateFromUISP() - refreshShapers() +def importandshape(): + if automaticImportUISP: + updateFromUISP() + refreshShapers() if __name__ == '__main__': - importAndShape() - schedule.every().day.at("04:00").do(importAndShape) - while True: - schedule.run_pending() - if graphingEnabled: - try: - refreshBandwidthGraphs() - refreshLatencyGraphs(10) - except: - print("Failed to update graphs") - else: - time.sleep(60) # wait x seconds + importandshape() + schedule.every().day.at("04:00").do(importandshape) + while True: + schedule.run_pending() + if graphingEnabled: + try: + refreshBandwidthGraphs() + refreshLatencyGraphs(10) + except: + print("Failed to update graphs") + else: + time.sleep(60) # wait x seconds