Merge pull request #690 from LibreQoE/integration_common_client_bandwidth_multiplier

Integration common client bandwidth multiplier
This commit is contained in:
Robert Chacón authored and GitHub committed 2025-04-12 09:36:54 -06:00
commit 563bf59b92
5 files changed
+34 -4

No files matched your search

+3 -4
View File
@@ -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)
@@ -15,6 +15,9 @@ pub struct IntegrationConfig {
/// Root node promotion
pub promote_to_root: Option<Vec<String>>,
/// Client bandwidth multiplier
pub client_bandwidth_multiplier: Option<f32>,
}
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,
}
}
}
+7
View File
@@ -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<Vec<String>> {
return Ok(vec![]);
};
Ok(promote_to_root.clone())
}
#[pyfunction]
fn client_bandwidth_multiplier() -> PyResult<f32> {
let config = lqos_config::load_config().unwrap();
Ok(config.integration_common.client_bandwidth_multiplier.unwrap_or(1.0))
}
@@ -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', () => {
@@ -49,6 +49,12 @@
<div class="form-text">Enter one circuit ID per line to promote to root nodes</div>
</div>
<div class="mb-3">
<label for="clientBandwidthMultiplier" class="form-label">Client Bandwidth Multiplier</label>
<input type="number" class="form-control" id="clientBandwidthMultiplier" step="0.1" min="0.1" value="1.0">
<div class="form-text">Multiplier applied to client bandwidth values (1.0 = 100%)</div>
</div>
<button type="button" id="saveButton" class="btn btn-outline-primary">Save Changes</button>
</form>
</div>