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 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())

View File

@ -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

View File

@ -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