From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 78E631FF164 for ; Fri, 4 Jul 2025 15:34:25 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5A00538D82; Fri, 4 Jul 2025 15:35:05 +0200 (CEST) Date: Fri, 4 Jul 2025 15:34:31 +0200 From: Wolfgang Bumiller To: Gabriel Goller Message-ID: References: <20250702145101.894299-1-g.goller@proxmox.com> <20250702145101.894299-34-g.goller@proxmox.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20250702145101.894299-34-g.goller@proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL -0.180 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 POISEN_SPAM_PILL 0.1 Meta: its spam POISEN_SPAM_PILL_1 0.1 random spam to be learned in bayes POISEN_SPAM_PILL_3 0.1 random spam to be learned in bayes RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.218 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. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pve-devel] [PATCH proxmox-perl-rs v4 5/5] pve-rs: sdn: fabrics: add helper for network API endpoint 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 Cc: pve-devel@lists.proxmox.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" On Wed, Jul 02, 2025 at 04:50:18PM +0200, Gabriel Goller wrote: > From: Stefan Hanreich > > In PVE we use the GET /nodes/{node}/network API endpoint to return all > currently configured network interfaces on a specific node. In order > to be able to use SDN fabrics in Ceph and the migration settings, we > add a helper method that returns all fabrics formatted in the same > format as the pre-existing PVE API call. This enables us to return the > SDN fabrics in the endpoint so users can select the fabrics from the > UI, integrating the fabrics with the existing UI components. > > Co-authored-by: Gabriel Goller > Signed-off-by: Stefan Hanreich > --- > pve-rs/src/bindings/sdn/fabrics.rs | 54 ++++++++++++++++++++++++++++-- > 1 file changed, 52 insertions(+), 2 deletions(-) > > diff --git a/pve-rs/src/bindings/sdn/fabrics.rs b/pve-rs/src/bindings/sdn/fabrics.rs > index 099c1a7ab515..f5abb1b72099 100644 > --- a/pve-rs/src/bindings/sdn/fabrics.rs > +++ b/pve-rs/src/bindings/sdn/fabrics.rs > @@ -17,7 +17,7 @@ pub mod pve_rs_sdn_fabrics { > > use perlmod::Value; > use proxmox_frr::serializer::to_raw_config; > - use proxmox_network_types::ip_address::Cidr; > + use proxmox_network_types::ip_address::{Cidr, Ipv4Cidr, Ipv6Cidr}; > use proxmox_section_config::typed::SectionConfigData; > use proxmox_ve_config::common::valid::Validatable; > > @@ -25,7 +25,7 @@ pub mod pve_rs_sdn_fabrics { > section_config::{ > fabric::{ > api::{Fabric, FabricUpdater}, > - FabricId, > + Fabric as ConfigFabric, FabricId, > }, > node::{ > api::{Node, NodeUpdater}, > @@ -46,6 +46,34 @@ pub mod pve_rs_sdn_fabrics { > > perlmod::declare_magic!(Box : &PerlFabricConfig as "PVE::RS::SDN::Fabrics::Config"); > > + /// Represents a interface as returned by the `GET /nodes/{node}/network` endpoint in PVE. an* > + /// > + /// This is used for returning fabrics in the endpoint, so they can be used from various places > + /// in the PVE UI (e.g. migration network settings). > + #[derive(Serialize, Deserialize)] It seems we currently only serialize this, so could drop the `Deserialize` here since it's a private helper type anyway right now. > + struct PveInterface { > + iface: String, > + #[serde(rename = "type")] > + ty: String, > + active: bool, > + #[serde(skip_serializing_if = "Option::is_none")] > + cidr: Option, > + #[serde(skip_serializing_if = "Option::is_none")] > + cidr6: Option, > + } > + > + impl From for PveInterface { > + fn from(fabric: ConfigFabric) -> Self { > + Self { > + iface: fabric.id().to_string(), > + ty: "fabric".to_string(), > + active: true, > + cidr: fabric.ip_prefix(), > + cidr6: fabric.ip6_prefix(), > + } > + } > + } > + > /// Parse the raw configuration from `/etc/pve/sdn/fabrics.cfg`. > #[export] > fn config(#[raw] class: Value, raw_config: &[u8]) -> Result { > @@ -308,6 +336,28 @@ pub mod pve_rs_sdn_fabrics { > Ok(hex::encode(hash)) > } > > + /// Class method: Return all interfaces of a node, that are part of a fabric. > + #[export] > + fn get_interfaces_for_node( > + #[try_from_ref] this: &PerlFabricConfig, > + node_id: NodeId, > + ) -> BTreeMap { > + let config = this.fabric_config.lock().unwrap(); > + > + let mut ifaces = BTreeMap::new(); > + > + for entry in config.values() { > + if entry.get_node(&node_id).is_ok() { > + ifaces.insert( > + entry.fabric().id().to_string(), > + entry.fabric().clone().into(), > + ); > + } > + } > + > + ifaces > + } > + > /// Class method: Return all FRR daemons that need to be enabled for this fabric configuration > /// instance. > #[export] > -- > 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel