Merge pull request #35 from khandieyea/main

minor/pep related tweaks
This commit is contained in:
Robert Chacón 2022-06-20 17:41:40 -06:00 committed by GitHub
commit 276e42465a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 29 deletions

View File

@ -1,7 +1,7 @@
import requests import requests
import csv import csv
import ipaddress import ipaddress
from ispConfig import UISPbaseURL, uispAuthToken, shapeRouterOrStation, ignoreSubnets from ispConfig import uispBaseURL, uispAuthToken, shapeRouterOrStation, ignoreSubnets
import shutil import shutil
stationModels = ['LBE-5AC-Gen2', 'LBE-5AC-Gen2', 'LBE-5AC-LR', 'AF-LTU5', 'AFLTULR', 'AFLTUPro', 'LTU-LITE'] 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(): def pullShapedDevices():
devices = [] devices = []
uispSitesToImport = [] 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} headers = {'accept':'application/json', 'x-auth-token': uispAuthToken}
r = requests.get(url, headers=headers) r = requests.get(url, headers=headers)
jsonData = r.json() jsonData = r.json()
@ -70,8 +70,8 @@ def pullShapedDevices():
return devices return devices
def getUISPdevicesAtClientSite(siteID): def getUISPdevicesAtClientSite(siteID):
url = UISPbaseURL + "/nms/api/v2.1/devices?siteId=" + siteID url = uispBaseURL + "/nms/api/v2.1/devices?siteId=" + siteID
headers = {'accept':'application/json', 'x-auth-token': uispAuthToken} headers = {'accept':'application/json', 'x-auth-token': UISPuthToken}
r = requests.get(url, headers=headers) r = requests.get(url, headers=headers)
return (r.json()) return (r.json())

View File

@ -1,7 +1,7 @@
#'fq_codel' or 'cake diffserv4' # 'fq_codel' or 'cake diffserv4'
#'cake diffserv4' is recommended # 'cake diffserv4' is recommended
#fqOrCAKE = 'fq_codel' # fqOrCAKE = 'fq_codel'
fqOrCAKE = 'cake diffserv4' fqOrCAKE = 'cake diffserv4'
# How many Mbps are available to the edge of this network # 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 # Shape by Site in addition to by AP and Client
shapeBySite = True 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 enableActualShellCommands = True
# Add 'sudo' before execution of any shell commands. May be required depending on distribution and environment. # Add 'sudo' before execution of any shell commands. May be required depending on distribution and environment.
runShellCommandsAsSudo = False runShellCommandsAsSudo = False
#Graphing # Graphing
graphingEnabled = True graphingEnabled = True
ppingLocation = "pping" ppingLocation = "pping"
influxDBurl = "http://localhost:8086" influxDBurl = "http://localhost:8086"
@ -36,16 +37,17 @@ influxDBOrg = "Your ISP Name Here"
influxDBtoken = "" influxDBtoken = ""
# NMS/CRM Integration # 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'] ignoreSubnets = ['192.168.0.0/16']
# Optional UISP integration # Optional UISP integration
automaticImportUISP = False automaticImportUISP = False
# Everything before /nms/ on your UISP instance # Everything before /nms/ on your UISP instance
UISPbaseURL = 'https://examplesite.com' uispBaseURL = 'https://examplesite.com'
# UISP Auth Token # UISP Auth Token
uispAuthToken = '' 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' shapeRouterOrStation = 'router'
# API Auth # API Auth

View File

@ -1,27 +1,26 @@
import time import time
import schedule import schedule
from datetime import date
from LibreQoS import refreshShapers from LibreQoS import refreshShapers
from graphBandwidth import refreshBandwidthGraphs from graphBandwidth import refreshBandwidthGraphs
from graphLatency import refreshLatencyGraphs from graphLatency import refreshLatencyGraphs
from ispConfig import graphingEnabled, automaticImportUISP from ispConfig import graphingEnabled, automaticImportUISP
from integrationUISP import updateFromUISP from integrationUISP import updateFromUISP
def importAndShape(): def importandshape():
if automaticImportUISP: if automaticImportUISP:
updateFromUISP() updateFromUISP()
refreshShapers() refreshShapers()
if __name__ == '__main__': if __name__ == '__main__':
importAndShape() importandshape()
schedule.every().day.at("04:00").do(importAndShape) schedule.every().day.at("04:00").do(importandshape)
while True: while True:
schedule.run_pending() schedule.run_pending()
if graphingEnabled: if graphingEnabled:
try: try:
refreshBandwidthGraphs() refreshBandwidthGraphs()
refreshLatencyGraphs(10) refreshLatencyGraphs(10)
except: except:
print("Failed to update graphs") print("Failed to update graphs")
else: else:
time.sleep(60) # wait x seconds time.sleep(60) # wait x seconds