[pve-devel] [PATCH proxmox-ve-rs 1/1] ve-config: fabrics: add helpers for proxmox-network-interface-pinning
Stefan Hanreich
s.hanreich at proxmox.com
Thu Jul 17 17:28:36 CEST 2025
In order to map interface names via the new
proxmox-network-interface-pinning tool, pve-rs needs mutable access to
the interfaces as well as all fabrics in the configuration. Add
helpers for iterating mutably over all fabrics, as well as all
interfaces.
Signed-off-by: Stefan Hanreich <s.hanreich at proxmox.com>
---
proxmox-ve-config/src/sdn/fabric/mod.rs | 5 +++++
.../fabric/section_config/protocol/openfabric.rs | 16 ++++++++++++++--
.../sdn/fabric/section_config/protocol/ospf.rs | 15 ++++++++++++++-
3 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/proxmox-ve-config/src/sdn/fabric/mod.rs b/proxmox-ve-config/src/sdn/fabric/mod.rs
index cac7490..9ec2f61 100644
--- a/proxmox-ve-config/src/sdn/fabric/mod.rs
+++ b/proxmox-ve-config/src/sdn/fabric/mod.rs
@@ -611,6 +611,11 @@ impl FabricConfig {
.ok_or_else(|| FabricConfigError::FabricDoesNotExist(id.to_string()))
}
+ /// 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()
+ }
+
/// Delete a fabric with the specified fabric_id from the [`FabricConfig`].
pub fn delete_fabric(&mut self, id: &FabricId) -> Result<FabricEntry, FabricConfigError> {
self.fabrics
diff --git a/proxmox-ve-config/src/sdn/fabric/section_config/protocol/openfabric.rs b/proxmox-ve-config/src/sdn/fabric/section_config/protocol/openfabric.rs
index 9a9f862..c68147d 100644
--- a/proxmox-ve-config/src/sdn/fabric/section_config/protocol/openfabric.rs
+++ b/proxmox-ve-config/src/sdn/fabric/section_config/protocol/openfabric.rs
@@ -1,4 +1,4 @@
-use std::ops::Deref;
+use std::ops::{Deref, DerefMut};
use proxmox_network_types::ip_address::{Ipv4Cidr, Ipv6Cidr};
use serde::{Deserialize, Serialize};
@@ -72,12 +72,19 @@ pub struct OpenfabricNodeProperties {
}
impl OpenfabricNodeProperties {
- /// Returns an interator over all the interfaces.
+ /// Returns an iterator over all the interfaces.
pub fn interfaces(&self) -> impl Iterator<Item = &OpenfabricInterfaceProperties> {
self.interfaces
.iter()
.map(|property_string| property_string.deref())
}
+
+ /// Returns an iterator over all the interfaces (mutable).
+ pub fn interfaces_mut(&mut self) -> impl Iterator<Item = &mut OpenfabricInterfaceProperties> {
+ self.interfaces
+ .iter_mut()
+ .map(|property_string| property_string.deref_mut())
+ }
}
impl Validatable for NodeSection<OpenfabricNodeProperties> {
@@ -127,6 +134,11 @@ impl OpenfabricInterfaceProperties {
&self.name
}
+ /// Set the name of the interface.
+ pub fn set_name(&mut self, name: InterfaceName) {
+ self.name = name
+ }
+
/// Get the IPv4 of the interface.
pub fn ip(&self) -> Option<Ipv4Cidr> {
self.ip
diff --git a/proxmox-ve-config/src/sdn/fabric/section_config/protocol/ospf.rs b/proxmox-ve-config/src/sdn/fabric/section_config/protocol/ospf.rs
index 1c8ce1d..df0be95 100644
--- a/proxmox-ve-config/src/sdn/fabric/section_config/protocol/ospf.rs
+++ b/proxmox-ve-config/src/sdn/fabric/section_config/protocol/ospf.rs
@@ -1,4 +1,4 @@
-use std::ops::Deref;
+use std::ops::{Deref, DerefMut};
use proxmox_network_types::ip_address::Ipv4Cidr;
use proxmox_sdn_types::area::Area;
@@ -75,11 +75,19 @@ pub struct OspfNodeProperties {
}
impl OspfNodeProperties {
+ /// Returns an iterator over all the interfaces.
pub fn interfaces(&self) -> impl Iterator<Item = &OspfInterfaceProperties> {
self.interfaces
.iter()
.map(|property_string| property_string.deref())
}
+
+ /// Returns an iterator over all the interfaces (mutable).
+ pub fn interfaces_mut(&mut self) -> impl Iterator<Item = &mut OspfInterfaceProperties> {
+ self.interfaces
+ .iter_mut()
+ .map(|property_string| property_string.deref_mut())
+ }
}
impl Validatable for NodeSection<OspfNodeProperties> {
@@ -124,6 +132,11 @@ impl OspfInterfaceProperties {
&self.name
}
+ /// Set the name of the interface.
+ pub fn set_name(&mut self, name: InterfaceName) {
+ self.name = name
+ }
+
/// Get the ip (IPv4) of the OSPF interface.
pub fn ip(&self) -> Option<Ipv4Cidr> {
self.ip
--
2.39.5
More information about the pve-devel
mailing list