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

@ -21,7 +21,8 @@ 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.
@ -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,20 +1,19 @@
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():
def importandshape():
if automaticImportUISP:
updateFromUISP()
refreshShapers()
if __name__ == '__main__':
importAndShape()
schedule.every().day.at("04:00").do(importAndShape)
importandshape()
schedule.every().day.at("04:00").do(importandshape)
while True:
schedule.run_pending()
if graphingEnabled: