mirror of
https://github.com/LibreQoE/LibreQoS.git
synced 2025-02-25 18:55:32 -06:00
Add files via upload
This commit is contained in:
parent
e5d70d4e7a
commit
5f30799538
58
src/csvToNetworkJSON.py
Normal file
58
src/csvToNetworkJSON.py
Normal file
@ -0,0 +1,58 @@
|
||||
from pythonCheck import checkPythonVersion
|
||||
checkPythonVersion()
|
||||
import os
|
||||
import csv
|
||||
import json
|
||||
from ispConfig import uispSite, uispStrategy, overwriteNetworkJSONalways
|
||||
from ispConfig import generatedPNUploadMbps, generatedPNDownloadMbps, upstreamBandwidthCapacityDownloadMbps, upstreamBandwidthCapacityUploadMbps
|
||||
from integrationCommon import NetworkGraph, NetworkNode, NodeType
|
||||
|
||||
def csvToNetworkJSONfile():
|
||||
sites = []
|
||||
with open('manualNetwork.csv') as csv_file:
|
||||
csv_reader = csv.reader(csv_file, delimiter=',')
|
||||
for row in csv_reader:
|
||||
if 'Site Name' in row[0]:
|
||||
header = row
|
||||
else:
|
||||
name, down, up, parent = row
|
||||
site = {'name': name,
|
||||
'download': down,
|
||||
'upload': up,
|
||||
'parent': parent}
|
||||
sites.append(site)
|
||||
|
||||
net = NetworkGraph()
|
||||
idCounter = 1000
|
||||
nameToID = {}
|
||||
for site in sites:
|
||||
site['id'] = idCounter
|
||||
idCounter = idCounter + 1
|
||||
nameToID[site['name']] = site['id']
|
||||
for site in sites:
|
||||
id = site['id']
|
||||
if site['parent'] == '':
|
||||
parentID = None
|
||||
else:
|
||||
parentID = nameToID[site['parent']]
|
||||
name = site['name']
|
||||
parent = site['parent']
|
||||
download = site['download']
|
||||
upload = site['upload']
|
||||
nodeType = NodeType.site
|
||||
node = NetworkNode(id=id, displayName=name, type=nodeType,
|
||||
parentId=parentID, download=download, upload=upload, address=None, customerName=None)
|
||||
net.addRawNode(node)
|
||||
net.prepareTree()
|
||||
net.plotNetworkGraph(False)
|
||||
if net.doesNetworkJsonExist():
|
||||
if overwriteNetworkJSONalways:
|
||||
net.createNetworkJson()
|
||||
else:
|
||||
print("network.json already exists and overwriteNetworkJSONalways set to False. Leaving in-place.")
|
||||
else:
|
||||
net.createNetworkJson()
|
||||
net.createShapedDevices()
|
||||
|
||||
if __name__ == '__main__':
|
||||
csvToNetworkJSONfile()
|
4
src/manualNetwork.template.csv
Normal file
4
src/manualNetwork.template.csv
Normal file
@ -0,0 +1,4 @@
|
||||
Site Name,Download Mbps,Upload Mbps,Parent Site Name
|
||||
SiteA,1000,1000,
|
||||
SiteB,975,975,SiteA
|
||||
SiteC,950,950,SiteB
|
|
Loading…
Reference in New Issue
Block a user