mirror of
https://github.com/LibreQoE/LibreQoS.git
synced 2025-02-25 18:55:32 -06:00
FIXES #351 - honour the UISP config "excluded sites" list, removing both sites and devices if they are excluded.
This commit is contained in:
parent
ea88d50d51
commit
ffb38fd16a
@ -17,12 +17,23 @@ pub use site::{Site, SiteId, Description};
|
||||
|
||||
/// Loads a complete list of all sites from UISP
|
||||
pub async fn load_all_sites(config: Config) -> Result<Vec<Site>> {
|
||||
Ok(nms_request_get_vec(
|
||||
let mut raw_sites = nms_request_get_vec(
|
||||
"sites",
|
||||
&config.uisp_integration.token,
|
||||
&config.uisp_integration.url,
|
||||
)
|
||||
.await?)
|
||||
.await?;
|
||||
|
||||
// Do not load sites from the excluded sites list.
|
||||
raw_sites.retain(|site: &Site|
|
||||
if let Some(name) = &site.name() {
|
||||
!config.uisp_integration.exclude_sites.contains(name)
|
||||
} else {
|
||||
true
|
||||
}
|
||||
);
|
||||
|
||||
Ok(raw_sites)
|
||||
}
|
||||
|
||||
/// Load all devices from UISP that are authorized, and include their full interface definitions
|
||||
|
@ -22,7 +22,7 @@ pub async fn load_uisp_data(
|
||||
error!("{:?}", devices);
|
||||
return Err(UispIntegrationError::UispConnectError);
|
||||
}
|
||||
let devices = devices.unwrap();
|
||||
let mut devices = devices.unwrap();
|
||||
|
||||
if sites.is_err() {
|
||||
error!("Error downloading sites list from UISP");
|
||||
@ -38,6 +38,19 @@ pub async fn load_uisp_data(
|
||||
}
|
||||
let data_links = data_links.unwrap();
|
||||
|
||||
// Remove any devices that are in excluded sites
|
||||
devices.retain(|dev| {
|
||||
if let Some(site_id) = dev.get_site_id() {
|
||||
if let Some(site) = sites.iter().find(|site| site.id == site_id) {
|
||||
!config.uisp_integration.exclude_sites.contains(&site.name_or_blank())
|
||||
} else {
|
||||
true
|
||||
}
|
||||
} else {
|
||||
true
|
||||
}
|
||||
});
|
||||
|
||||
info!(
|
||||
"Loaded backing data: {} sites, {} devices, {} links",
|
||||
sites.len(),
|
||||
|
Loading…
Reference in New Issue
Block a user