[pdm-devel] [PATCH datacenter-manager 4/6] pdm client: add method to scan remote PBS instances
Christian Ebner
c.ebner at proxmox.com
Mon Sep 22 13:09:56 CEST 2025
Adds the PDM client method to perform API calls to the servers
scan remote endpoint for PBS, analogous to the PVE implementation.
Since this is mostly the same for both remote types, common code is
factored into a generic private helper method.
Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
lib/pdm-client/src/lib.rs | 49 ++++++++++++++++++++++++++++-----------
1 file changed, 35 insertions(+), 14 deletions(-)
diff --git a/lib/pdm-client/src/lib.rs b/lib/pdm-client/src/lib.rs
index e8a4ee5..f81de67 100644
--- a/lib/pdm-client/src/lib.rs
+++ b/lib/pdm-client/src/lib.rs
@@ -987,20 +987,8 @@ impl<T: HttpApiClient> PdmClient<T> {
authid: &str,
token: &str,
) -> Result<Remote, Error> {
- let mut params = json!({
- "hostname": hostname,
- "authid": authid,
- "token": token,
- });
- if let Some(fp) = fingerprint {
- params["fingerprint"] = fp.into();
- }
- Ok(self
- .0
- .post("/api2/extjs/pve/scan", ¶ms)
- .await?
- .expect_json()?
- .data)
+ self.scan_remote(hostname, fingerprint, authid, token, RemoteType::Pve)
+ .await
}
pub async fn pve_sdn_list_controllers(
@@ -1083,6 +1071,39 @@ impl<T: HttpApiClient> PdmClient<T> {
}
Ok(self.0.post(&path, ¶ms).await?.expect_json()?.data)
}
+
+ /// Uses /pbs/scan to scan the remote cluster for node/fingerprint information
+ pub async fn pbs_scan_remote(
+ &self,
+ hostname: &str,
+ fingerprint: Option<&str>,
+ authid: &str,
+ token: &str,
+ ) -> Result<Remote, Error> {
+ self.scan_remote(hostname, fingerprint, authid, token, RemoteType::Pbs)
+ .await
+ }
+
+ /// Uses /{remote-type}/scan to scan the remote for node/fingerprint information
+ pub async fn scan_remote(
+ &self,
+ hostname: &str,
+ fingerprint: Option<&str>,
+ authid: &str,
+ token: &str,
+ remote_type: RemoteType,
+ ) -> Result<Remote, Error> {
+ let path = format!("/api2/extjs/{remote_type}/scan");
+ let mut params = json!({
+ "hostname": hostname,
+ "authid": authid,
+ "token": token,
+ });
+ if let Some(fp) = fingerprint {
+ params["fingerprint"] = fp.into();
+ }
+ Ok(self.0.post(&path, ¶ms).await?.expect_json()?.data)
+ }
}
/// Builder for migration parameters.
--
2.47.3
More information about the pdm-devel
mailing list