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 E47121FF2A6 for ; Fri, 7 Nov 2025 09:59:27 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1B2B5BAB3; Fri, 7 Nov 2025 10:00:10 +0100 (CET) From: Stefan Hanreich To: pdm-devel@lists.proxmox.com Date: Fri, 7 Nov 2025 09:59:25 +0100 Message-ID: <20251107085934.118815-6-s.hanreich@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251107085934.118815-1-s.hanreich@proxmox.com> References: <20251107085934.118815-1-s.hanreich@proxmox.com> MIME-Version: 1.0 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 KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods 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 Subject: [pdm-devel] [PATCH proxmox-datacenter-manager 2/5] server: api: sdn: add mac-vrf endpoint X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Datacenter Manager development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" Calls the respective Proxmox VE endpoint to obtain status information about the MAC-VRF of an EVPN vnet. Since the status is per-node, use the existing nodes subdirectory instead of the general SDN subdirectory, mirroring the API path from Proxmox VE. Signed-off-by: Stefan Hanreich --- lib/pdm-client/src/lib.rs | 13 +++++++++- server/src/api/nodes/sdn.rs | 47 +++++++++++++++++++++++++++++++++++-- 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/lib/pdm-client/src/lib.rs b/lib/pdm-client/src/lib.rs index e22d139..3b0af86 100644 --- a/lib/pdm-client/src/lib.rs +++ b/lib/pdm-client/src/lib.rs @@ -67,7 +67,7 @@ pub mod types { pub use pve_api_types::StorageStatus as PveStorageStatus; - pub use pve_api_types::SdnZoneIpVrf; + pub use pve_api_types::{SdnVnetMacVrf, SdnZoneIpVrf}; } pub struct PdmClient(pub T); @@ -1063,6 +1063,17 @@ impl PdmClient { Ok(self.0.get(&path).await?.expect_json()?.data) } + pub async fn pve_sdn_vnet_get_mac_vrf( + &self, + remote: &str, + node: &str, + vnet: &str, + ) -> Result, Error> { + let path = + format!("/api2/extjs/pve/remotes/{remote}/nodes/{node}/sdn/vnets/{vnet}/mac-vrf"); + Ok(self.0.get(&path).await?.expect_json()?.data) + } + /// uses /pbs/probe-tls to probe the tls connection to the given host pub async fn pbs_probe_tls( &self, diff --git a/server/src/api/nodes/sdn.rs b/server/src/api/nodes/sdn.rs index 9ca6130..065ebe0 100644 --- a/server/src/api/nodes/sdn.rs +++ b/server/src/api/nodes/sdn.rs @@ -4,7 +4,7 @@ use http::StatusCode; use pdm_api_types::{remotes::REMOTE_ID_SCHEMA, sdn::SDN_ID_SCHEMA, NODE_SCHEMA}; use proxmox_router::{list_subdirs_api_method, Router, SubdirMap}; use proxmox_schema::api; -use pve_api_types::SdnZoneIpVrf; +use pve_api_types::{SdnVnetMacVrf, SdnZoneIpVrf}; use crate::api::pve::{connect, get_remote}; @@ -51,7 +51,50 @@ mod zones { } } -const SUBDIRS: SubdirMap = &[("zone", &zones::ROUTER)]; +mod vnets { + use super::*; + + const VNET_SUBDIRS: SubdirMap = &[("mac-vrf", &Router::new().get(&API_METHOD_GET_MAC_VRF))]; + + const VNET_ROUTER: Router = Router::new() + .get(&list_subdirs_api_method!(VNET_SUBDIRS)) + .subdirs(VNET_SUBDIRS); + + pub const ROUTER: Router = Router::new().match_all("vnet", &VNET_ROUTER); + + #[api( + input: { + properties: { + remote: { schema: REMOTE_ID_SCHEMA }, + node: { schema: NODE_SCHEMA }, + vnet: { schema: SDN_ID_SCHEMA }, + }, + }, + returns: { type: SdnVnetMacVrf }, + )] + /// Get the MAC-VRF for an EVPN vnet for a node on a given remote + async fn get_mac_vrf( + remote: String, + node: String, + vnet: String, + ) -> Result, Error> { + let (remote_config, _) = pdm_config::remotes::config()?; + let remote = get_remote(&remote_config, &remote)?; + let client = connect(&remote)?; + + client + .get_vnet_mac_vrf(&node, &vnet) + .await + .map_err(|err| match err { + proxmox_client::Error::Api(StatusCode::NOT_IMPLEMENTED, _msg) => { + anyhow!("remote {} does not support the vnet mac-vrf API call, please upgrade to the newest version!", remote.id) + } + _ => err.into() + }) + } +} + +const SUBDIRS: SubdirMap = &[("vnets", &vnets::ROUTER), ("zones", &zones::ROUTER)]; pub const ROUTER: Router = Router::new() .get(&list_subdirs_api_method!(SUBDIRS)) -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel