mirror of
https://github.com/LibreQoE/LibreQoS.git
synced 2025-02-25 18:55:32 -06:00
* Add a new configuration item to the [uisp_integration] tree, squash_sites = ["site1", "site2"]. It's optional, so it's ok to not have it.
* Modify UISP integration so that sites in this list - when the system is in Full strategy - will be promoted to directly parent off the root. This should be useful for CPU management when you have a hierarchy that concentrates too much load in one place. It's an interim fix until the next full version after this one that adds "virtual node" support.
This commit is contained in:
@@ -11,6 +11,7 @@ pub struct UispIntegration {
|
||||
pub airmax_capacity: f32,
|
||||
pub ltu_capacity: f32,
|
||||
pub exclude_sites: Vec<String>,
|
||||
pub squash_sites: Option<Vec<String>>,
|
||||
pub ipv6_with_mikrotik: bool,
|
||||
pub bandwidth_overhead_factor: f32,
|
||||
pub commit_bandwidth_multiplier: f32,
|
||||
@@ -42,6 +43,7 @@ impl Default for UispIntegration {
|
||||
airmax_capacity: 0.0,
|
||||
ltu_capacity: 0.0,
|
||||
exclude_sites: vec![],
|
||||
squash_sites: None,
|
||||
ipv6_with_mikrotik: false,
|
||||
bandwidth_overhead_factor: 1.0,
|
||||
commit_bandwidth_multiplier: 1.0,
|
||||
|
||||
@@ -26,7 +26,7 @@ use crate::strategies::full::parse::parse_uisp_datasets;
|
||||
use crate::strategies::full::root_site::{find_root_site, set_root_site};
|
||||
use crate::strategies::full::routes_override::get_route_overrides;
|
||||
use crate::strategies::full::shaped_devices_writer::write_shaped_devices;
|
||||
use crate::strategies::full::squash_single_entry_aps::squash_single_aps;
|
||||
use crate::strategies::full::squash_single_entry_aps::{squash_squashed_sites, squash_single_aps};
|
||||
use crate::strategies::full::tree_walk::walk_tree_for_routing;
|
||||
use crate::strategies::full::uisp_fetch::load_uisp_data;
|
||||
use crate::strategies::full::utils::{print_sites, warn_of_no_parents_and_promote};
|
||||
@@ -121,6 +121,9 @@ pub async fn build_full_network(
|
||||
// Correct any sites with zero capacity
|
||||
correct_zero_capacity_sites(&mut sites, &config);
|
||||
|
||||
// Squash any sites that are in the squash list
|
||||
squash_squashed_sites(&mut sites, config.clone(), &root_site)?;
|
||||
|
||||
// Print Sites
|
||||
if let Some(root_idx) = sites.iter().position(|s| s.name == root_site) {
|
||||
// Issue No Parent Warnings
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
use std::sync::Arc;
|
||||
use tracing::info;
|
||||
use lqos_config::Config;
|
||||
use crate::errors::UispIntegrationError;
|
||||
use crate::uisp_types::{UispSite, UispSiteType};
|
||||
|
||||
@@ -45,3 +48,44 @@ pub fn squash_single_aps(sites: &mut [UispSite]) -> Result<(), UispIntegrationEr
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn squash_squashed_sites(sites: &mut [UispSite], config: Arc<Config>, root_name: &str) -> Result<(), UispIntegrationError> {
|
||||
let Some(squash_sites) = &config.uisp_integration.squash_sites else {
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
let Some(root_index) = sites.iter().position(|s| s.name == root_name) else {
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
info!("Squashing excluded sites.");
|
||||
info!("Squashing sites: {:?}", config.uisp_integration.squash_sites);
|
||||
let mut squashable = Vec::new();
|
||||
for (idx, site) in sites.iter().enumerate().filter(|(_,s)| s.site_type == UispSiteType::Site || s.site_type == UispSiteType::AccessPoint ) {
|
||||
if squash_sites.contains(&site.name) {
|
||||
squashable.push(idx);
|
||||
info!("Squashing site {} due to exclusion list.", site.name);
|
||||
}
|
||||
}
|
||||
|
||||
let mut squashed = Vec::new();
|
||||
for squash_idx in squashable {
|
||||
sites[squash_idx].site_type = UispSiteType::SquashDeleted;
|
||||
sites[squash_idx].name += " (SQUASHED)";
|
||||
println!("Squashing site {}", sites[squash_idx].name);
|
||||
let parent = root_index;
|
||||
sites.iter_mut().for_each(|s| {
|
||||
if let Some(their_parent) = s.selected_parent {
|
||||
if their_parent == squash_idx {
|
||||
info!("Re-parenting site {} to {} ({})", s.name, root_name, parent);
|
||||
s.selected_parent = Some(parent);
|
||||
squashed.push(s.id.clone());
|
||||
}
|
||||
}
|
||||
});
|
||||
sites[squash_idx].parent_indices.clear();
|
||||
}
|
||||
info!("Squashed sites: {:?}", squashed);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user