From: Gabriel Goller <[email protected]>

Add helper function to iterate over all nodes in all fabrics. This is
especially useful e.g. when retrieving the stats as we need to find all
the fabrics on the current node (and their node config).

Signed-off-by: Gabriel Goller <[email protected]>
Signed-off-by: Stefan Hanreich <[email protected]>
---
 proxmox-ve-config/src/sdn/fabric/mod.rs | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/proxmox-ve-config/src/sdn/fabric/mod.rs 
b/proxmox-ve-config/src/sdn/fabric/mod.rs
index 58a06f9..677a309 100644
--- a/proxmox-ve-config/src/sdn/fabric/mod.rs
+++ b/proxmox-ve-config/src/sdn/fabric/mod.rs
@@ -618,6 +618,11 @@ impl FabricConfig {
             .ok_or_else(|| 
FabricConfigError::FabricDoesNotExist(id.to_string()))
     }
 
+    /// Get an iterator over all the nodes in all fabrics.
+    pub fn all_nodes(&self) -> impl Iterator<Item = (&NodeId, &Node)> + '_ {
+        self.values().flat_map(|entry| entry.nodes())
+    }
+
     /// Returns an iterator over mutable references to all [`FabricEntry`] in 
the config
     pub fn get_fabrics_mut(&mut self) -> impl Iterator<Item = &mut 
FabricEntry> {
         self.fabrics.values_mut()
-- 
2.47.3


_______________________________________________
pve-devel mailing list
[email protected]
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to