mirror of
https://github.com/LibreQoE/LibreQoS.git
synced 2025-02-25 18:55:32 -06:00
Update integrationPowercode.py
Optimize import time
This commit is contained in:
parent
0c796ee378
commit
800fdb40b4
@ -21,21 +21,20 @@ def getCustomerInfo():
|
|||||||
r = requests.post(url, data=data, headers=headers, verify=False, timeout=10)
|
r = requests.post(url, data=data, headers=headers, verify=False, timeout=10)
|
||||||
return r.json()
|
return r.json()
|
||||||
|
|
||||||
def getServiceInfo(customerID):
|
def getListServices():
|
||||||
headers= {'Content-Type': 'application/x-www-form-urlencoded'}
|
headers= {'Content-Type': 'application/x-www-form-urlencoded'}
|
||||||
url = powercode_api_url + ":444/api/1/index.php"
|
url = powercode_api_url + ":444/api/preseem/index.php"
|
||||||
data = {}
|
data = {}
|
||||||
data['apiKey'] = powercode_api_key
|
data['apiKey'] = powercode_api_key
|
||||||
data['action'] = 'readCustomerService'
|
data['action'] = 'list_services'
|
||||||
data['customerID'] = customerID
|
|
||||||
|
|
||||||
r = requests.post(url, data=data, headers=headers, verify=False, timeout=10)
|
r = requests.post(url, data=data, headers=headers, verify=False, timeout=10)
|
||||||
servicesDict = {}
|
servicesDict = {}
|
||||||
for service in r.json()['services']:
|
for service in r.json():
|
||||||
if 'internetInfo' in service:
|
if service['rate_down'] and service['rate_up']:
|
||||||
servicesDict[service['serviceID']] = {}
|
servicesDict[service['id']] = {}
|
||||||
servicesDict[service['serviceID']]['downloadMbps'] = int(round(int(service['internetInfo']['maxIn']) / 1000))
|
servicesDict[service['id']]['downloadMbps'] = int(round(int(service['rate_down']) / 1000))
|
||||||
servicesDict[service['serviceID']]['uploadMbps'] = int(round(int(service['internetInfo']['maxOut']) / 1000))
|
servicesDict[service['id']]['uploadMbps'] = int(round(int(service['rate_up']) / 1000))
|
||||||
return servicesDict
|
return servicesDict
|
||||||
|
|
||||||
def createShaper():
|
def createShaper():
|
||||||
@ -56,16 +55,10 @@ def createShaper():
|
|||||||
if customerIDint not in customerIDs:
|
if customerIDint not in customerIDs:
|
||||||
customerIDs.append(customerIDint)
|
customerIDs.append(customerIDint)
|
||||||
|
|
||||||
allServices = {}
|
allServices = getListServices()
|
||||||
counter = 1
|
|
||||||
for customerID in customerIDs:
|
|
||||||
print("Importing " + str(counter) + "/" + str(len(customerIDs)) + " customers")
|
|
||||||
allServices.update(getServiceInfo(customerID))
|
|
||||||
counter += 1
|
|
||||||
|
|
||||||
acceptableEquipment = ['Customer Owned Equipment', 'Router', 'Customer Owned Equipment', 'Managed Routers'] #'CPE'
|
acceptableEquipment = ['Customer Owned Equipment', 'Router', 'Customer Owned Equipment', 'Managed Routers'] #'CPE'
|
||||||
|
|
||||||
print("Consolidating imported customers")
|
|
||||||
devicesByCustomerID = {}
|
devicesByCustomerID = {}
|
||||||
for customer in customerInfo:
|
for customer in customerInfo:
|
||||||
if customer['status'] == 'Active':
|
if customer['status'] == 'Active':
|
||||||
@ -115,6 +108,7 @@ def createShaper():
|
|||||||
ipv6=[]
|
ipv6=[]
|
||||||
)
|
)
|
||||||
net.addRawNode(newDevice)
|
net.addRawNode(newDevice)
|
||||||
|
print("Imported " + str(len(devicesByCustomerID)) + " customers")
|
||||||
net.prepareTree()
|
net.prepareTree()
|
||||||
net.plotNetworkGraph(False)
|
net.plotNetworkGraph(False)
|
||||||
if net.doesNetworkJsonExist():
|
if net.doesNetworkJsonExist():
|
||||||
|
Loading…
Reference in New Issue
Block a user