public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Stefan Hanreich <s.hanreich@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH proxmox-ve-rs 1/1] ve-config: fabrics: add helpers for proxmox-network-interface-pinning
Date: Thu, 17 Jul 2025 17:28:36 +0200	[thread overview]
Message-ID: <20250717152841.397830-2-s.hanreich@proxmox.com> (raw)
In-Reply-To: <20250717152841.397830-1-s.hanreich@proxmox.com>

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@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


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


  reply	other threads:[~2025-07-17 15:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-17 15:28 [pve-devel] [PATCH manager/proxmox{-ve-rs, -perl-rs} 0/6] proxmox-network-interface-pinning fixes Stefan Hanreich
2025-07-17 15:28 ` Stefan Hanreich [this message]
2025-07-17 19:27   ` [pve-devel] applied: [PATCH proxmox-ve-rs 1/1] ve-config: fabrics: add helpers for proxmox-network-interface-pinning Thomas Lamprecht
2025-07-17 15:28 ` [pve-devel] [PATCH proxmox-perl-rs 1/1] pve-rs: fabrics: helper for mapping interface names Stefan Hanreich
2025-07-17 19:00   ` [pve-devel] applied: " Thomas Lamprecht
2025-07-17 15:28 ` [pve-devel] [PATCH pve-manager 1/4] pve-sdn-commit: fix reloading logic Stefan Hanreich
2025-07-17 19:27   ` [pve-devel] applied-series: " Thomas Lamprecht
2025-07-17 15:28 ` [pve-devel] [PATCH pve-manager 2/4] proxmox-network-interface-pinning: add fabrics support Stefan Hanreich
2025-07-17 15:28 ` [pve-devel] [PATCH pve-manager 3/4] proxmox-network-interface-pinning: die on failing to write interfaces Stefan Hanreich
2025-07-17 15:28 ` [pve-devel] [PATCH pve-manager 4/4] proxmox-network-interface-pinning: fix pinning after reboot Stefan Hanreich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250717152841.397830-2-s.hanreich@proxmox.com \
    --to=s.hanreich@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal