Handle exception CPE reparenting.

This commit is contained in:
Herbert Wolverson 2024-04-25 13:38:13 -05:00
parent 631b9672f5
commit 6f986f4cd1
2 changed files with 10 additions and 2 deletions

View File

@ -44,7 +44,7 @@ pub async fn build_full_network(
// Obtain the UISP data and transform it into easier to work with types // Obtain the UISP data and transform it into easier to work with types
let (sites_raw, devices_raw, data_links_raw) = load_uisp_data(config.clone()).await?; let (sites_raw, devices_raw, data_links_raw) = load_uisp_data(config.clone()).await?;
let (mut sites, data_links, devices) = parse_uisp_datasets( let (mut sites, data_links, mut devices) = parse_uisp_datasets(
&sites_raw, &sites_raw,
&data_links_raw, &data_links_raw,
&devices_raw, &devices_raw,

View File

@ -76,11 +76,19 @@ impl UispDevice {
ip_ranges.is_permitted(addr, subnet) ip_ranges.is_permitted(addr, subnet)
}); });
// Handle any "exception CPE" entries
let mut site_id = device.get_site_id().unwrap_or("".to_string());
for exception in config.uisp_integration.exception_cpes.iter() {
if exception.cpe == device.get_name().unwrap() {
site_id = exception.parent.clone();
}
}
Self { Self {
id: device.get_id(), id: device.get_id(),
name: device.get_name().unwrap(), name: device.get_name().unwrap(),
mac, mac,
site_id: device.get_site_id().unwrap_or("".to_string()), site_id,
upload, upload,
download, download,
ipv4, ipv4,