public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup] manager: use view_task_result function for realm sync
@ 2023-02-13 14:29 Lukas Wagner
  2023-03-27 12:25 ` [pbs-devel] applied: " Wolfgang Bumiller
  0 siblings, 1 reply; 2+ messages in thread
From: Lukas Wagner @ 2023-02-13 14:29 UTC (permalink / raw)
  To: pbs-devel

Previously, the same approach as in `proxmox-backup-debug` was used.
With the changes from this commit, realm syncing uses the same method for
waiting for task output as other parts of `proxmox-backup-manager`.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
Thx @ Fabian for the suggestion!

 src/bin/proxmox_backup_manager/ldap.rs | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/src/bin/proxmox_backup_manager/ldap.rs b/src/bin/proxmox_backup_manager/ldap.rs
index 538c313b..7ff4ad1d 100644
--- a/src/bin/proxmox_backup_manager/ldap.rs
+++ b/src/bin/proxmox_backup_manager/ldap.rs
@@ -1,14 +1,14 @@
 use anyhow::Error;
+use pbs_client::view_task_result;
+use pbs_tools::json::required_string_param;
 use serde_json::Value;
 
 use proxmox_router::{cli::*, ApiHandler, Permission, RpcEnvironment};
 use proxmox_schema::api;
 
-use pbs_api_types::{
-    Realm, PRIV_PERMISSIONS_MODIFY, PROXMOX_UPID_REGEX, REALM_ID_SCHEMA, REMOVE_VANISHED_SCHEMA,
-};
+use pbs_api_types::{Realm, PRIV_PERMISSIONS_MODIFY, REALM_ID_SCHEMA, REMOVE_VANISHED_SCHEMA};
 
-use proxmox_backup::api2;
+use proxmox_backup::{api2, client_helpers::connect_to_localhost};
 
 #[api(
     input: {
@@ -98,18 +98,13 @@ fn show_ldap_realm(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Valu
     },
 )]
 /// Sync a given LDAP realm
-async fn sync_ldap_realm(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
-    let info = &api2::access::domain::API_METHOD_SYNC_REALM;
-    let data = match info.handler {
-        ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?,
-        _ => unreachable!(),
-    };
+async fn sync_ldap_realm(param: Value) -> Result<Value, Error> {
+    let realm = required_string_param(&param, "realm")?;
+    let client = connect_to_localhost()?;
 
-    if let Some(upid) = data.as_str() {
-        if PROXMOX_UPID_REGEX.is_match(upid) {
-            proxmox_rest_server::handle_worker(upid).await?;
-        }
-    }
+    let path = format!("api2/json/access/domains/{}/sync", realm);
+    let result = client.post(&path, Some(param)).await?;
+    view_task_result(&client, result, "text").await?;
 
     Ok(Value::Null)
 }
-- 
2.30.2





^ permalink raw reply	[flat|nested] 2+ messages in thread

* [pbs-devel] applied: [PATCH proxmox-backup] manager: use view_task_result function for realm sync
  2023-02-13 14:29 [pbs-devel] [PATCH proxmox-backup] manager: use view_task_result function for realm sync Lukas Wagner
@ 2023-03-27 12:25 ` Wolfgang Bumiller
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Bumiller @ 2023-03-27 12:25 UTC (permalink / raw)
  To: Lukas Wagner; +Cc: pbs-devel

applied, thanks




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-27 12:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-13 14:29 [pbs-devel] [PATCH proxmox-backup] manager: use view_task_result function for realm sync Lukas Wagner
2023-03-27 12:25 ` [pbs-devel] applied: " Wolfgang Bumiller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal