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 0E8841FF15C for ; Wed, 11 Dec 2024 11:41:30 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 8990B76D8; Wed, 11 Dec 2024 11:41:34 +0100 (CET) From: Hannes Laimer To: pbs-devel@lists.proxmox.com Date: Wed, 11 Dec 2024 11:40:48 +0100 Message-Id: <20241211104050.69441-6-h.laimer@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241211104050.69441-1-h.laimer@proxmox.com> References: <20241211104050.69441-1-h.laimer@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.028 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 5/7] 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" 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 --- src/bin/proxmox_backup_manager/datastore.rs | 42 +++++++++++++-------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/src/bin/proxmox_backup_manager/datastore.rs b/src/bin/proxmox_backup_manager/datastore.rs index 0918af3a4..e9fc1b93e 100644 --- a/src/bin/proxmox_backup_manager/datastore.rs +++ b/src/bin/proxmox_backup_manager/datastore.rs @@ -49,24 +49,31 @@ fn list_datastores(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result 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/{}/mount", store).as_str(), + None, + ) + .await?; + + view_task_result(&client, result, &output_format).await?; - crate::wait_for_local_worker(result.as_str().unwrap()).await?; Ok(()) } @@ -252,10 +259,6 @@ async fn update_datastore(name: String, mut param: Value) -> Result<(), Error> { type: String, description: "The UUID of the device that should be mounted", }, - "output-format": { - schema: OUTPUT_FORMAT, - optional: true, - }, }, }, )] @@ -282,7 +285,16 @@ async fn uuid_mount(param: Value, _rpcenv: &mut dyn RpcEnvironment) -> Result