From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 847951FF165 for ; Thu, 17 Jul 2025 17:28:12 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id DFA183ED86; Thu, 17 Jul 2025 17:29:14 +0200 (CEST) From: Stefan Hanreich To: pve-devel@lists.proxmox.com Date: Thu, 17 Jul 2025 17:28:36 +0200 Message-Id: <20250717152841.397830-2-s.hanreich@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250717152841.397830-1-s.hanreich@proxmox.com> References: <20250717152841.397830-1-s.hanreich@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.212 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RDNS_NONE 0.793 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [self.name, openfabric.rs, ospf.rs, mod.rs] Subject: [pve-devel] [PATCH proxmox-ve-rs 1/1] ve-config: fabrics: add helpers for proxmox-network-interface-pinning X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" 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 --- 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 { + self.fabrics.values_mut() + } + /// Delete a fabric with the specified fabric_id from the [`FabricConfig`]. pub fn delete_fabric(&mut self, id: &FabricId) -> Result { 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 { 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 { + self.interfaces + .iter_mut() + .map(|property_string| property_string.deref_mut()) + } } impl Validatable for NodeSection { @@ -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 { 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 { 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 { + self.interfaces + .iter_mut() + .map(|property_string| property_string.deref_mut()) + } } impl Validatable for NodeSection { @@ -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 { self.ip -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel