From: Lukas Wagner <l.wagner@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup] manager: use view_task_result function for realm sync
Date: Mon, 13 Feb 2023 15:29:31 +0100 [thread overview]
Message-ID: <20230213142931.904152-1-l.wagner@proxmox.com> (raw)
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(¶m, "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
next reply other threads:[~2023-02-13 14:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-13 14:29 Lukas Wagner [this message]
2023-03-27 12:25 ` [pbs-devel] applied: " Wolfgang Bumiller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230213142931.904152-1-l.wagner@proxmox.com \
--to=l.wagner@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal