From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 336FE1FF0AF for ; Thu, 10 Sep 2026 18:20:48 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 9860F215AB; Thu, 10 Sep 2026 18:20:38 +0200 (CEST) From: =?UTF-8?q?Michael=20K=C3=B6ppl?= To: pve-devel@lists.proxmox.com Subject: [PATCH test-tools 2/4] instance: register PDM remotes without pdm-client Date: Thu, 10 Sep 2026 18:20:28 +0200 Message-ID: <20260910162030.1776719-3-m.koeppl@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260910162030.1776719-1-m.koeppl@proxmox.com> References: <20260910162030.1776719-1-m.koeppl@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1789057223596 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.727 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: 5RJGESRJFOB56KARGZUQOBTRF756T5JJ X-Message-ID-Hash: 5RJGESRJFOB56KARGZUQOBTRF756T5JJ X-MailFrom: m.koeppl@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: pdm-client was pulled in only for add_remote(), which the repository can express directly through the proxmox-client HttpApiClient trait that the PVE client already uses. Declare the request body locally instead. Only the fields the call actually sends are kept. The format constants on NodeUrl are dropped as well, since they only validate input that is constructed here from the instance address and the fingerprint fetched just before. Authid keeps coming from proxmox-auth-api, which is where pdm-api-types re-exported it from. Signed-off-by: Michael Köppl --- proxmox-test-instance/Cargo.toml | 4 +- proxmox-test-instance/src/api/pdm_client.rs | 76 +++++++++++++++++---- 2 files changed, 66 insertions(+), 14 deletions(-) diff --git a/proxmox-test-instance/Cargo.toml b/proxmox-test-instance/Cargo.toml index 0c5d207..5a7c333 100644 --- a/proxmox-test-instance/Cargo.toml +++ b/proxmox-test-instance/Cargo.toml @@ -10,7 +10,6 @@ repository.workspace = true [dependencies] proxmox-test-common = { workspace = true } pdm-api-types = { workspace = true } -pdm-client = { workspace = true } anyhow.workspace = true dirs-next.workspace = true @@ -30,10 +29,11 @@ tokio = { workspace = true, features = [ "rt" ]} toml.workspace = true proxmox-async.workspace = true +proxmox-auth-api = { workspace = true, features = [ "api-types" ] } proxmox-client = { workspace = true, features = ["hyper-client"] } proxmox-config-digest = { workspace = true, features = [ "openssl" ] } proxmox-http = { workspace = true, features = ["client-sync"] } proxmox-login = { workspace = true } -proxmox-schema = { workspace = true } +proxmox-schema = { workspace = true, features = [ "api-macro" ] } pve-api-types = { workspace = true, features = ["client"] } diff --git a/proxmox-test-instance/src/api/pdm_client.rs b/proxmox-test-instance/src/api/pdm_client.rs index 9c79923..8067f37 100644 --- a/proxmox-test-instance/src/api/pdm_client.rs +++ b/proxmox-test-instance/src/api/pdm_client.rs @@ -1,16 +1,62 @@ use anyhow::{Error, bail}; -use pdm_api_types::{ - Authid, - remotes::{NodeUrl, RemoteType}, -}; -use pdm_client::{PdmClient as ExistingPdmClient, types::Remote}; -use proxmox_client::Client; +use proxmox_auth_api::types::Authid; +use proxmox_client::{Client, HttpApiClient}; use proxmox_login::Login; +use proxmox_schema::api; use proxmox_schema::property_string::PropertyString; +use serde::Serialize; + use proxmox_test_common::types::TestInstance; +/// The type of a remote entry. +#[derive(Clone, Copy, Serialize)] +#[serde(rename_all = "lowercase")] +enum RemoteType { + /// A Proxmox VE node. + Pve, +} + +#[api( + properties: { + fingerprint: { + type: String, + optional: true, + }, + }, + default_key: "hostname", +)] +/// A node and its certificate information. +#[derive(Clone, Serialize)] +struct NodeUrl { + /// The node address. + hostname: String, + + /// Certificate fingerprint. + #[serde(skip_serializing_if = "Option::is_none")] + fingerprint: Option, +} + +/// The part of PDM's remote configuration that registering a test instance needs. +#[derive(Serialize)] +struct Remote { + #[serde(rename = "type")] + ty: RemoteType, + id: String, + nodes: Vec>, + authid: Authid, + token: String, +} + +#[derive(Serialize)] +#[serde(rename_all = "kebab-case")] +struct AddRemoteParams<'a> { + #[serde(flatten)] + remote: &'a Remote, + create_token: &'a str, +} + pub struct PdmClient { - client: ExistingPdmClient, + client: Client, } impl PdmClient { @@ -33,9 +79,7 @@ impl PdmClient { bail!("two factor authentication is not supported"); } - Ok(PdmClient { - client: ExistingPdmClient(client), - }) + Ok(PdmClient { client }) } pub async fn add_remote( @@ -52,10 +96,18 @@ impl PdmClient { })], authid: Authid::root_auth_id().clone(), token: instance_pw.to_string(), - web_url: None, }; - self.client.add_remote(&remote, Some("pdm-admin")).await?; + self.client + .post( + "/api2/extjs/remotes/remote", + &AddRemoteParams { + remote: &remote, + create_token: "pdm-admin", + }, + ) + .await? + .nodata()?; Ok(()) } -- 2.47.3