public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Michael Köppl" <m.koeppl@proxmox.com>
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	[thread overview]
Message-ID: <20260910162030.1776719-3-m.koeppl@proxmox.com> (raw)
In-Reply-To: <20260910162030.1776719-1-m.koeppl@proxmox.com>

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 <m.koeppl@proxmox.com>
---
 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<String>,
+}
+
+/// 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<PropertyString<NodeUrl>>,
+    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: 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





  parent reply	other threads:[~2026-09-10 16:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-10 16:20 [PATCH test-tools 0/4] remove PDM submodule Michael Köppl
2026-09-10 16:20 ` [PATCH test-tools 1/4] scheduler: drop the unused pdm-api-types dependency Michael Köppl
2026-09-10 16:20 ` Michael Köppl [this message]
2026-09-10 16:20 ` [PATCH test-tools 3/4] instance: source certificate and task types directly Michael Köppl
2026-09-10 16:20 ` [PATCH test-tools 4/4] buildsys: drop the proxmox-datacenter-manager submodule Michael Köppl

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=20260910162030.1776719-3-m.koeppl@proxmox.com \
    --to=m.koeppl@proxmox.com \
    --cc=pve-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 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