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 A51CE1FF14F for ; Fri, 08 May 2026 18:32:01 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 8AC661DED4; Fri, 8 May 2026 18:31:50 +0200 (CEST) From: Stefan Hanreich To: pve-devel@lists.proxmox.com Subject: [PATCH proxmox-perl-rs v6 06/24] sdn: route maps: add route map list method Date: Fri, 8 May 2026 18:31:15 +0200 Message-ID: <20260508163134.481912-7-s.hanreich@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260508163134.481912-1-s.hanreich@proxmox.com> References: <20260508163134.481912-1-s.hanreich@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1778257794686 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.635 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 SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: HAJK2QBFSHOWSC3RIPVFAODO7DDLYVGT X-Message-ID-Hash: HAJK2QBFSHOWSC3RIPVFAODO7DDLYVGT X-MailFrom: s.hanreich@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Exposes a new method that returns a list of all existing route maps. Used for implementing a new endpoint in PVE that only returns the IDs of route maps, which is used in the route map selector component. Signed-off-by: Stefan Hanreich --- pve-rs/src/bindings/sdn/route_maps.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/pve-rs/src/bindings/sdn/route_maps.rs b/pve-rs/src/bindings/sdn/route_maps.rs index efac7e1..73eb271 100644 --- a/pve-rs/src/bindings/sdn/route_maps.rs +++ b/pve-rs/src/bindings/sdn/route_maps.rs @@ -4,6 +4,7 @@ pub mod pve_rs_sdn_route_maps { use std::collections::hash_map::Entry; use std::collections::HashMap; + use std::collections::HashSet; use std::ops::Deref; use std::sync::Mutex; @@ -87,6 +88,32 @@ pub mod pve_rs_sdn_route_maps { Ok(hex::encode(hash)) } + #[derive(Clone, Serialize, Deserialize, Hash)] + pub(crate) struct RouteMap { + id: RouteMapId, + } + + /// Method: Returns all route maps. + #[export] + pub fn list_route_maps( + #[try_from_ref] this: &PerlRouteMapConfig, + ) -> Result, Error> { + let route_maps = this.route_maps.lock().unwrap(); + + let route_map_ids: HashSet<&RouteMapId> = route_maps + .iter() + .map(|(_id, route_map_entry)| { + let ConfigRouteMap::RouteMapEntry(route_map) = route_map_entry; + route_map.id().route_map_id() + }) + .collect(); + + Ok(route_map_ids + .into_iter() + .map(|id| RouteMap { id: id.clone() }) + .collect()) + } + /// Method: Returns all route map entries as a hash indexed with the IDs of the entries. #[export] pub fn list( -- 2.47.3