Merge pull request #278 from LibreQoE/toggleDisplayNameOrAddress

Integrations Improvement - Toggle using display name or address for Circuit Name
This commit is contained in:
Robert Chacón 2023-03-03 20:40:28 -07:00 committed by GitHub
commit 2843061bbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 559 additions and 543 deletions

View File

@ -2,7 +2,7 @@
# integrations.
from typing import List, Any
from ispConfig import allowedSubnets, ignoreSubnets, generatedPNUploadMbps, generatedPNDownloadMbps
from ispConfig import allowedSubnets, ignoreSubnets, generatedPNUploadMbps, generatedPNDownloadMbps, circuitNameUseAddress
import ipaddress
import enum
@ -82,7 +82,7 @@ class NetworkNode:
address: 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.parentIndex = 0
self.type = type
@ -96,6 +96,7 @@ class NetworkNode:
self.ipv4 = ipv4
self.ipv6 = ipv6
self.address = address
self.customerName = customerName
self.mac = mac
@ -334,9 +335,14 @@ class NetworkGraph:
if node.type == NodeType.client:
parent = self.nodes[node.parentIndex].displayName
if parent == "Shaper Root": parent = ""
if circuitNameUseAddress:
displayNameToUse = node.address
else:
displayNameToUse = node.customerName
circuit = {
"id": node.id,
"name": node.address,
"name": displayNameToUse,
"parent": parent,
"download": node.downloadMbps,
"upload": node.uploadMbps,

View File

@ -86,6 +86,7 @@ def createShaper():
id=combinedId,
displayName=customerJson["name"],
address=combineAddress(customerJson),
customerName=customerJson["name"],
download=downloadForTariffID[tariff_id],
upload=uploadForTariffID[tariff_id],
)

View File

@ -36,6 +36,7 @@ def buildFlatGraph():
if type == "endpoint":
id = site['identification']['id']
address = site['description']['address']
customerName = ''
name = site['identification']['name']
type = site['identification']['type']
download = generatedPNDownloadMbps
@ -44,7 +45,7 @@ def buildFlatGraph():
download = int(round(site['qos']['downloadSpeed']/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)
for device in devices:
if device['identification']['site'] is not None and device['identification']['site']['id'] == id:
@ -120,6 +121,7 @@ def buildFullGraph():
download = generatedPNDownloadMbps
upload = generatedPNUploadMbps
address = ""
customerName = ""
if site['identification']['parent'] is None:
parent = ""
else:
@ -138,12 +140,16 @@ def buildFullGraph():
case default:
nodeType = NodeType.client
address = site['description']['address']
try:
customerName = site["ucrm"]["client"]["name"]
except:
customerName = ""
if (site['qos']['downloadSpeed']) and (site['qos']['uploadSpeed']):
download = int(round(site['qos']['downloadSpeed']/1000000))
upload = int(round(site['qos']['uploadSpeed']/1000000))
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
# node soup.
if name == uispSite:

View File

@ -60,6 +60,9 @@ influxDBtoken = ""
# 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
ignoreSubnets = ['192.168.0.0/16']
allowedSubnets = ['100.64.0.0/10']