From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <pbs-devel-bounces@lists.proxmox.com> Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 699F71FF170 for <inbox@lore.proxmox.com>; Thu, 15 May 2025 14:41:43 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id DC6C031C0C; Thu, 15 May 2025 14:42:01 +0200 (CEST) From: Hannes Laimer <h.laimer@proxmox.com> To: pbs-devel@lists.proxmox.com Date: Thu, 15 May 2025 14:41:36 +0200 Message-Id: <20250515124138.55436-7-h.laimer@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250515124138.55436-1-h.laimer@proxmox.com> References: <20250515124138.55436-1-h.laimer@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.026 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: [pbs-devel] [PATCH proxmox-backup v2 6/8] bin: manager: run uuid_mount/mount tasks on the proxy X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion <pbs-devel.lists.proxmox.com> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pbs-devel>, <mailto:pbs-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/pbs-devel/> List-Post: <mailto:pbs-devel@lists.proxmox.com> List-Help: <mailto:pbs-devel-request@lists.proxmox.com?subject=help> List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel>, <mailto:pbs-devel-request@lists.proxmox.com?subject=subscribe> Reply-To: Proxmox Backup Server development discussion <pbs-devel@lists.proxmox.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" <pbs-devel-bounces@lists.proxmox.com> Use the API instead of running uuid_mount/mount directly in the CLI binary. This ensures that all triggered tasks are handled by the proxy process. Signed-off-by: Hannes Laimer <h.laimer@proxmox.com> --- src/bin/proxmox_backup_manager/datastore.rs | 41 ++++++++++++++++----- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/src/bin/proxmox_backup_manager/datastore.rs b/src/bin/proxmox_backup_manager/datastore.rs index 1922a55a2..3fbb5fe5b 100644 --- a/src/bin/proxmox_backup_manager/datastore.rs +++ b/src/bin/proxmox_backup_manager/datastore.rs @@ -49,6 +49,10 @@ fn list_datastores(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Valu store: { schema: DATASTORE_SCHEMA, }, + "output-format": { + schema: OUTPUT_FORMAT, + optional: true, + }, digest: { optional: true, schema: PROXMOX_CONFIG_DIGEST_SCHEMA, @@ -57,16 +61,23 @@ fn list_datastores(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Valu }, )] /// Mount a removable datastore. -async fn mount_datastore(mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<(), Error> { - param["node"] = "localhost".into(); +async fn mount_datastore( + store: String, + mut param: Value, + _rpcenv: &mut dyn RpcEnvironment, +) -> Result<(), Error> { + let output_format = extract_output_format(&mut param); - let info = &api2::admin::datastore::API_METHOD_MOUNT; - let result = match info.handler { - ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?, - _ => unreachable!(), - }; + let client = connect_to_localhost()?; + let result = client + .post( + format!("api2/json/admin/datastore/{store}/mount").as_str(), + None, + ) + .await?; + + view_task_result(&client, result, &output_format).await?; - crate::wait_for_local_worker(result.as_str().unwrap()).await?; Ok(()) } @@ -260,7 +271,8 @@ async fn update_datastore(name: String, mut param: Value) -> Result<(), Error> { }, )] /// Try mounting a removable datastore given the UUID. -async fn uuid_mount(param: Value, _rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> { +async fn uuid_mount(mut param: Value, _rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> { + let output_format = extract_output_format(&mut param); let uuid = param["uuid"] .as_str() .ok_or_else(|| format_err!("uuid has to be specified"))?; @@ -282,7 +294,16 @@ async fn uuid_mount(param: Value, _rpcenv: &mut dyn RpcEnvironment) -> Result<Va } if let Some(store) = matching_stores.first() { - api2::admin::datastore::do_mount_device(store.clone())?; + let client = connect_to_localhost()?; + let result = client + .post( + format!("api2/json/admin/datastore/{}/mount", store.name).as_str(), + None, + ) + .await?; + + view_task_result(&client, result, &output_format).await?; + return Ok(Value::Null); } // we don't want to fail for UUIDs that are not associated with datastores, as that produces -- 2.39.5 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel