mirror of
https://github.com/LibreQoE/LibreQoS.git
synced 2025-02-25 18:55:32 -06:00
Merge pull request #278 from LibreQoE/toggleDisplayNameOrAddress
Integrations Improvement - Toggle using display name or address for Circuit Name
This commit is contained in:
commit
2843061bbd
@ -2,7 +2,7 @@
|
|||||||
# integrations.
|
# integrations.
|
||||||
|
|
||||||
from typing import List, Any
|
from typing import List, Any
|
||||||
from ispConfig import allowedSubnets, ignoreSubnets, generatedPNUploadMbps, generatedPNDownloadMbps
|
from ispConfig import allowedSubnets, ignoreSubnets, generatedPNUploadMbps, generatedPNDownloadMbps, circuitNameUseAddress
|
||||||
import ipaddress
|
import ipaddress
|
||||||
import enum
|
import enum
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ class NetworkNode:
|
|||||||
address: str
|
address: str
|
||||||
mac: str
|
mac: str
|
||||||
|
|
||||||
def __init__(self, id: str, displayName: str = "", parentId: str = "", type: NodeType = NodeType.site, download: int = generatedPNDownloadMbps, upload: int = generatedPNUploadMbps, ipv4: List = [], ipv6: List = [], address: str = "", mac: str = "") -> None:
|
def __init__(self, id: str, displayName: str = "", parentId: str = "", type: NodeType = NodeType.site, download: int = generatedPNDownloadMbps, upload: int = generatedPNUploadMbps, ipv4: List = [], ipv6: List = [], address: str = "", mac: str = "", customerName: str = "") -> None:
|
||||||
self.id = id
|
self.id = id
|
||||||
self.parentIndex = 0
|
self.parentIndex = 0
|
||||||
self.type = type
|
self.type = type
|
||||||
@ -96,6 +96,7 @@ class NetworkNode:
|
|||||||
self.ipv4 = ipv4
|
self.ipv4 = ipv4
|
||||||
self.ipv6 = ipv6
|
self.ipv6 = ipv6
|
||||||
self.address = address
|
self.address = address
|
||||||
|
self.customerName = customerName
|
||||||
self.mac = mac
|
self.mac = mac
|
||||||
|
|
||||||
|
|
||||||
@ -334,9 +335,14 @@ class NetworkGraph:
|
|||||||
if node.type == NodeType.client:
|
if node.type == NodeType.client:
|
||||||
parent = self.nodes[node.parentIndex].displayName
|
parent = self.nodes[node.parentIndex].displayName
|
||||||
if parent == "Shaper Root": parent = ""
|
if parent == "Shaper Root": parent = ""
|
||||||
|
|
||||||
|
if circuitNameUseAddress:
|
||||||
|
displayNameToUse = node.address
|
||||||
|
else:
|
||||||
|
displayNameToUse = node.customerName
|
||||||
circuit = {
|
circuit = {
|
||||||
"id": node.id,
|
"id": node.id,
|
||||||
"name": node.address,
|
"name": displayNameToUse,
|
||||||
"parent": parent,
|
"parent": parent,
|
||||||
"download": node.downloadMbps,
|
"download": node.downloadMbps,
|
||||||
"upload": node.uploadMbps,
|
"upload": node.uploadMbps,
|
||||||
|
@ -86,6 +86,7 @@ def createShaper():
|
|||||||
id=combinedId,
|
id=combinedId,
|
||||||
displayName=customerJson["name"],
|
displayName=customerJson["name"],
|
||||||
address=combineAddress(customerJson),
|
address=combineAddress(customerJson),
|
||||||
|
customerName=customerJson["name"],
|
||||||
download=downloadForTariffID[tariff_id],
|
download=downloadForTariffID[tariff_id],
|
||||||
upload=uploadForTariffID[tariff_id],
|
upload=uploadForTariffID[tariff_id],
|
||||||
)
|
)
|
||||||
|
@ -36,6 +36,7 @@ def buildFlatGraph():
|
|||||||
if type == "endpoint":
|
if type == "endpoint":
|
||||||
id = site['identification']['id']
|
id = site['identification']['id']
|
||||||
address = site['description']['address']
|
address = site['description']['address']
|
||||||
|
customerName = ''
|
||||||
name = site['identification']['name']
|
name = site['identification']['name']
|
||||||
type = site['identification']['type']
|
type = site['identification']['type']
|
||||||
download = generatedPNDownloadMbps
|
download = generatedPNDownloadMbps
|
||||||
@ -44,7 +45,7 @@ def buildFlatGraph():
|
|||||||
download = int(round(site['qos']['downloadSpeed']/1000000))
|
download = int(round(site['qos']['downloadSpeed']/1000000))
|
||||||
upload = int(round(site['qos']['uploadSpeed']/1000000))
|
upload = int(round(site['qos']['uploadSpeed']/1000000))
|
||||||
|
|
||||||
node = NetworkNode(id=id, displayName=name, type=NodeType.client, download=download, upload=upload, address=address)
|
node = NetworkNode(id=id, displayName=name, type=NodeType.client, download=download, upload=upload, address=address, customerName=customerName)
|
||||||
net.addRawNode(node)
|
net.addRawNode(node)
|
||||||
for device in devices:
|
for device in devices:
|
||||||
if device['identification']['site'] is not None and device['identification']['site']['id'] == id:
|
if device['identification']['site'] is not None and device['identification']['site']['id'] == id:
|
||||||
@ -120,6 +121,7 @@ def buildFullGraph():
|
|||||||
download = generatedPNDownloadMbps
|
download = generatedPNDownloadMbps
|
||||||
upload = generatedPNUploadMbps
|
upload = generatedPNUploadMbps
|
||||||
address = ""
|
address = ""
|
||||||
|
customerName = ""
|
||||||
if site['identification']['parent'] is None:
|
if site['identification']['parent'] is None:
|
||||||
parent = ""
|
parent = ""
|
||||||
else:
|
else:
|
||||||
@ -138,12 +140,16 @@ def buildFullGraph():
|
|||||||
case default:
|
case default:
|
||||||
nodeType = NodeType.client
|
nodeType = NodeType.client
|
||||||
address = site['description']['address']
|
address = site['description']['address']
|
||||||
|
try:
|
||||||
|
customerName = site["ucrm"]["client"]["name"]
|
||||||
|
except:
|
||||||
|
customerName = ""
|
||||||
if (site['qos']['downloadSpeed']) and (site['qos']['uploadSpeed']):
|
if (site['qos']['downloadSpeed']) and (site['qos']['uploadSpeed']):
|
||||||
download = int(round(site['qos']['downloadSpeed']/1000000))
|
download = int(round(site['qos']['downloadSpeed']/1000000))
|
||||||
upload = int(round(site['qos']['uploadSpeed']/1000000))
|
upload = int(round(site['qos']['uploadSpeed']/1000000))
|
||||||
|
|
||||||
node = NetworkNode(id=id, displayName=name, type=nodeType,
|
node = NetworkNode(id=id, displayName=name, type=nodeType,
|
||||||
parentId=parent, download=download, upload=upload, address=address)
|
parentId=parent, download=download, upload=upload, address=address, customerName=customerName)
|
||||||
# If this is the uispSite node, it becomes the root. Otherwise, add it to the
|
# If this is the uispSite node, it becomes the root. Otherwise, add it to the
|
||||||
# node soup.
|
# node soup.
|
||||||
if name == uispSite:
|
if name == uispSite:
|
||||||
|
@ -60,6 +60,9 @@ influxDBtoken = ""
|
|||||||
|
|
||||||
# NMS/CRM Integration
|
# NMS/CRM Integration
|
||||||
|
|
||||||
|
# Use Customer Name or Address as Circuit Name
|
||||||
|
circuitNameUseAddress = True
|
||||||
|
|
||||||
# If a device shows a WAN IP within 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']
|
||||||
allowedSubnets = ['100.64.0.0/10']
|
allowedSubnets = ['100.64.0.0/10']
|
||||||
|
Loading…
Reference in New Issue
Block a user