From: Stefan Hanreich <s.hanreich@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH proxmox-datacenter-manager 2/5] server: api: sdn: add mac-vrf endpoint
Date: Fri, 7 Nov 2025 09:59:25 +0100 [thread overview]
Message-ID: <20251107085934.118815-6-s.hanreich@proxmox.com> (raw)
In-Reply-To: <20251107085934.118815-1-s.hanreich@proxmox.com>
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 <s.hanreich@proxmox.com>
---
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<T: HttpApiClient>(pub T);
@@ -1063,6 +1063,17 @@ impl<T: HttpApiClient> PdmClient<T> {
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<Vec<SdnVnetMacVrf>, 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<Vec<SdnVnetMacVrf>, 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
next prev parent reply other threads:[~2025-11-07 8:59 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-07 8:59 [pdm-devel] [PATCH proxmox{, -datacenter-manager} 0/8] Integration of IP-VRF and MAC-VRF status to EVPN panel Stefan Hanreich
2025-11-07 8:59 ` [pdm-devel] [PATCH proxmox 1/3] pve-api-types: add zone / vnet status reporting endpoints Stefan Hanreich
2025-11-07 8:59 ` [pdm-devel] [PATCH proxmox 2/3] pve-api-types: generate ip-vrf / mac-vrf endpoints Stefan Hanreich
2025-11-07 8:59 ` [pdm-devel] [PATCH proxmox 3/3] pve-api-types: regenerate Stefan Hanreich
2025-11-07 8:59 ` [pdm-devel] [PATCH proxmox-datacenter-manager 1/5] server: api: sdn: add ip-vrf endpoint Stefan Hanreich
2025-11-07 8:59 ` Stefan Hanreich [this message]
2025-11-07 8:59 ` [pdm-devel] [PATCH proxmox-datacenter-manager 3/5] ui: sdn: evpn: add zone status panel Stefan Hanreich
2025-11-07 8:59 ` [pdm-devel] [PATCH proxmox-datacenter-manager 4/5] ui: sdn: evpn: add vnet " Stefan Hanreich
2025-11-07 8:59 ` [pdm-devel] [PATCH proxmox-datacenter-manager 5/5] sdn: evpn: add detail panel to the evpn panel 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=20251107085934.118815-6-s.hanreich@proxmox.com \
--to=s.hanreich@proxmox.com \
--cc=pdm-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