From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <pdm-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 CBE821FF191 for <inbox@lore.proxmox.com>; Mon, 16 Jun 2025 15:57:40 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 27E9395D1; Mon, 16 Jun 2025 15:58:09 +0200 (CEST) From: Dominik Csapak <d.csapak@proxmox.com> To: pdm-devel@lists.proxmox.com Date: Mon, 16 Jun 2025 15:58:04 +0200 Message-Id: <20250616135804.3212548-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.022 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] cli: fix adding remotes X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion <pdm-devel.lists.proxmox.com> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pdm-devel>, <mailto:pdm-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/pdm-devel/> List-Post: <mailto:pdm-devel@lists.proxmox.com> List-Help: <mailto:pdm-devel-request@lists.proxmox.com?subject=help> List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel>, <mailto:pdm-devel-request@lists.proxmox.com?subject=subscribe> Reply-To: Proxmox Datacenter Manager development discussion <pdm-devel@lists.proxmox.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" <pdm-devel-bounces@lists.proxmox.com> three things needed fixing here: * type is already included in the remote type, so no need to have it externally * the api call uses `async` so change the handler matching * the api call needs the proxmox_product_config to be initialized noticed by a user in the forum: https://forum.proxmox.com/threads/167483/ Signed-off-by: Dominik Csapak <d.csapak@proxmox.com> --- cli/admin/Cargo.toml | 2 ++ cli/admin/src/main.rs | 4 ++++ cli/admin/src/remotes.rs | 12 ++---------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/cli/admin/Cargo.toml b/cli/admin/Cargo.toml index 7ac8965..17155a8 100644 --- a/cli/admin/Cargo.toml +++ b/cli/admin/Cargo.toml @@ -15,8 +15,10 @@ serde_json.workspace = true proxmox-async.workspace = true proxmox-log.workspace = true +proxmox-product-config.workspace = true proxmox-router = { workspace = true, features = [ "cli" ], default-features = false } proxmox-schema = { workspace = true, features = [ "api-macro" ] } pdm-api-types.workspace = true +pdm-config.workspace = true server.workspace = true diff --git a/cli/admin/src/main.rs b/cli/admin/src/main.rs index 91b93f3..7170471 100644 --- a/cli/admin/src/main.rs +++ b/cli/admin/src/main.rs @@ -5,6 +5,10 @@ mod remotes; fn main() { //pbs_tools::setup_libc_malloc_opts(); // TODO: move from PBS to proxmox-sys and uncomment + let api_user = pdm_config::api_user().expect("cannot get api user"); + let priv_user = pdm_config::priv_user().expect("cannot get privileged user"); + proxmox_product_config::init(api_user, priv_user); + proxmox_log::Logger::from_env("PDM_LOG", proxmox_log::LevelFilter::INFO) .stderr() .init() diff --git a/cli/admin/src/remotes.rs b/cli/admin/src/remotes.rs index 2ef77b7..fc61f04 100644 --- a/cli/admin/src/remotes.rs +++ b/cli/admin/src/remotes.rs @@ -92,7 +92,6 @@ fn list_remotes(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<(), Err #[api( input: { properties: { - type: { type: RemoteType }, remote: { flatten: true, type: Remote, @@ -101,17 +100,10 @@ fn list_remotes(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<(), Err } )] /// Add a new remote. -fn add_remote( - r#type: RemoteType, - remote: pdm_api_types::remotes::Remote, - rpcenv: &mut dyn RpcEnvironment, -) -> Result<(), Error> { - let mut param = serde_json::to_value(remote)?; - param["type"] = serde_json::to_value(r#type)?; - +async fn add_remote(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<(), Error> { let info = &dc_api::remotes::API_METHOD_ADD_REMOTE; match info.handler { - ApiHandler::Sync(handler) => (handler)(param, info, rpcenv).map(drop), + ApiHandler::Async(handler) => (handler)(param, info, rpcenv).await.map(drop), _ => unreachable!(), } } -- 2.39.5 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel