Hotfix: handle node "type" entry

Adding "type" to `network.json` is awesome, but it broke a bit of
Rust. This patch adds support for the `type` field, and fixes
a rare "none" issue that mostly seems to affect my UISP setup.
This commit is contained in:
Herbert Wolverson 2023-04-24 13:28:37 +00:00
parent 125ef55e35
commit 629ebb0293
3 changed files with 6 additions and 1 deletions

View File

@ -285,7 +285,7 @@ def handleMultipleInternetNodes(sites, dataLinks, uispSite):
internetConnectedSites = []
for link in dataLinks:
if link['canDelete'] == False:
if link['from']['device']['identification']['id'] == link['to']['device']['identification']['id']:
if link['from']['device'] is not None and link['to']['device'] is not None and link['from']['device']['identification']['id'] == link['to']['device']['identification']['id']:
siteID = link['from']['site']['identification']['id']
# Found internet link
internetConnectedSites.append(siteID)

View File

@ -48,6 +48,7 @@ impl NetworkJsonNode {
rtts: self.rtts.iter().map(|n| *n as f32 / 100.0).collect(),
parents: self.parents.clone(),
immediate_parent: self.immediate_parent,
node_type: String::new(),
}
}
}
@ -69,6 +70,9 @@ pub struct NetworkJsonTransport {
pub parents: Vec<usize>,
/// The immediate parent node in the tree
pub immediate_parent: Option<usize>,
/// The type of node (site, ap, etc.)
#[serde(rename = "type")]
pub node_type: String,
}
/// Holder for the network.json representation.

View File

@ -96,6 +96,7 @@ pub fn get_top_n_root_queues(n_queues: usize) -> BusResponse {
rtts: Vec::new(),
parents: Vec::new(),
immediate_parent: None,
node_type: String::new(),
},
));
}