From 3ae8a4d069218965045319458c91a011b4c1fc8f Mon Sep 17 00:00:00 2001 From: "Herbert Wolverson (aider)" Date: Sat, 12 Apr 2025 10:11:06 -0500 Subject: [PATCH 1/3] feat: add client bandwidth multiplier field to integration config --- .../js_build/src/config_integration.js | 14 ++++++++++++++ .../node_manager/static2/config_integration.html | 6 ++++++ 2 files changed, 20 insertions(+) diff --git a/src/rust/lqosd/src/node_manager/js_build/src/config_integration.js b/src/rust/lqosd/src/node_manager/js_build/src/config_integration.js index 0929d747..5b22ccea 100644 --- a/src/rust/lqosd/src/node_manager/js_build/src/config_integration.js +++ b/src/rust/lqosd/src/node_manager/js_build/src/config_integration.js @@ -16,6 +16,14 @@ function validateConfig() { alert("Please remove empty lines from Promote to Root Nodes"); return false; } + + // Validate multiplier + const multiplier = parseFloat(document.getElementById("clientBandwidthMultiplier").value); + if (isNaN(multiplier) || multiplier <= 0) { + alert("Client Bandwidth Multiplier must be a number greater than 0"); + return false; + } + return true; } @@ -31,6 +39,10 @@ function updateConfig() { .map(line => line.trim()) .filter(line => line.length > 0); return list.length > 0 ? list : null; + })(), + client_bandwidth_multiplier: (() => { + const value = parseFloat(document.getElementById("clientBandwidthMultiplier").value); + return value === 1.0 ? null : value; // Store as null for default to save space })() }; } @@ -54,6 +66,8 @@ loadConfig(() => { // Promote to root field const promoteRoot = integration.promote_to_root ? integration.promote_to_root.join('\n') : ''; document.getElementById("promoteToRoot").value = promoteRoot; + document.getElementById("clientBandwidthMultiplier").value = + (integration.client_bandwidth_multiplier ?? 1.0).toFixed(1); // Add save button click handler document.getElementById('saveButton').addEventListener('click', () => { diff --git a/src/rust/lqosd/src/node_manager/static2/config_integration.html b/src/rust/lqosd/src/node_manager/static2/config_integration.html index b8dddbca..08456c06 100644 --- a/src/rust/lqosd/src/node_manager/static2/config_integration.html +++ b/src/rust/lqosd/src/node_manager/static2/config_integration.html @@ -49,6 +49,12 @@
Enter one circuit ID per line to promote to root nodes
+
+ + +
Multiplier applied to client bandwidth values (1.0 = 100%)
+
+ From 610c6882c2e5e1796ab61ccdd5c99efde6866bdc Mon Sep 17 00:00:00 2001 From: Herbert Wolverson Date: Sat, 12 Apr 2025 10:14:43 -0500 Subject: [PATCH 2/3] Feat: Add `client_bandwidth_multiplier` to the "integration common" section of the config. --- src/rust/lqos_config/src/etc/v15/integration_common.rs | 4 ++++ src/rust/lqos_python/src/lib.rs | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/src/rust/lqos_config/src/etc/v15/integration_common.rs b/src/rust/lqos_config/src/etc/v15/integration_common.rs index 4f3039a7..c2803233 100644 --- a/src/rust/lqos_config/src/etc/v15/integration_common.rs +++ b/src/rust/lqos_config/src/etc/v15/integration_common.rs @@ -15,6 +15,9 @@ pub struct IntegrationConfig { /// Root node promotion pub promote_to_root: Option>, + + /// Client bandwidth multiplier + pub client_bandwidth_multiplier: Option, } impl Default for IntegrationConfig { @@ -24,6 +27,7 @@ impl Default for IntegrationConfig { always_overwrite_network_json: false, queue_refresh_interval_mins: 30, promote_to_root: None, + client_bandwidth_multiplier: None, } } } diff --git a/src/rust/lqos_python/src/lib.rs b/src/rust/lqos_python/src/lib.rs index 20780adc..07933483 100644 --- a/src/rust/lqos_python/src/lib.rs +++ b/src/rust/lqos_python/src/lib.rs @@ -99,6 +99,7 @@ fn liblqos_python(_py: Python, m: &PyModule) -> PyResult<()> { m.add_wrapped(wrap_pyfunction!(wispgate_api_token))?; m.add_wrapped(wrap_pyfunction!(wispgate_api_url))?; m.add_wrapped(wrap_pyfunction!(promote_to_root_list))?; + m.add_wrapped(wrap_pyfunction!(client_bandwidth_multiplier))?; Ok(()) } @@ -782,4 +783,10 @@ fn promote_to_root_list() -> PyResult> { return Ok(vec![]); }; Ok(promote_to_root.clone()) +} + +#[pyfunction] +fn client_bandwidth_multiplier() -> PyResult { + let config = lqos_config::load_config().unwrap(); + Ok(config.integration_common.client_bandwidth_multiplier.unwrap_or(1.0)) } \ No newline at end of file From 334ff30899d1fd622c6b77913eea47e52b40001a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Chac=C3=B3n?= Date: Sat, 12 Apr 2025 09:32:12 -0600 Subject: [PATCH 3/3] Update integrationCommon.py --- src/integrationCommon.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/integrationCommon.py b/src/integrationCommon.py index 2f8c5ec1..f57f574e 100644 --- a/src/integrationCommon.py +++ b/src/integrationCommon.py @@ -5,7 +5,7 @@ from typing import List, Any from liblqos_python import allowed_subnets, ignore_subnets, generated_pn_download_mbps, generated_pn_upload_mbps, \ circuit_name_use_address, upstream_bandwidth_capacity_download_mbps, upstream_bandwidth_capacity_upload_mbps, \ find_ipv6_using_mikrotik, exclude_sites, bandwidth_overhead_factor, committed_bandwidth_multiplier, \ - exception_cpes, promote_to_root_list + exception_cpes, promote_to_root_list, client_bandwidth_multiplier import ipaddress import enum import os @@ -403,7 +403,6 @@ class NetworkGraph: circuit["devices"].append(device) if len(circuit["devices"]) > 0: circuits.append(circuit) - with open('ShapedDevices.csv', 'w', newline='') as csvfile: wr = csv.writer(csvfile, quoting=csv.QUOTE_ALL) wr.writerow(['Circuit ID', 'Circuit Name', 'Device ID', 'Device Name', 'Parent Node', 'MAC', @@ -428,8 +427,8 @@ class NetworkGraph: device["ipv6"], int(1), int(1), - int(float(circuit["download"]) * bandwidth_overhead_factor()), - int(float(circuit["upload"]) * bandwidth_overhead_factor()), + int(float(circuit["download"]) * client_bandwidth_multiplier()), + int(float(circuit["upload"]) * client_bandwidth_multiplier()), "" ] wr.writerow(row)