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 090571FF187 for ; Mon, 22 Sep 2025 13:10:20 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id BC7F818B58; Mon, 22 Sep 2025 13:10:47 +0200 (CEST) From: Christian Ebner To: pdm-devel@lists.proxmox.com Date: Mon, 22 Sep 2025 13:09:56 +0200 Message-ID: <20250922110958.369653-5-c.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922110958.369653-1-c.ebner@proxmox.com> References: <20250922110958.369653-1-c.ebner@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1758539402932 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.043 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 Subject: [pdm-devel] [PATCH datacenter-manager 4/6] pdm client: add method to scan remote PBS instances 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" 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 --- 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 PdmClient { authid: &str, token: &str, ) -> Result { - 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 PdmClient { } 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 { + 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 { + 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 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel