[pdm-devel] [PATCH datacenter-manager 5/6] ui: remote: check connection for PBS remotes in remote add wizard
Christian Ebner
c.ebner at proxmox.com
Mon Sep 22 13:09:57 CEST 2025
Adds the TLS connection check for PBS remotes currently not
implemented in the wizard.
Uses the PDM client to check the connection to a remote PBS instance
with the provided hostname (port) and fingerprint.
Since the pdm client will use the implementation based on the provided
remote type, pass it along from the wizard page props, which is
extended to provide this information.
Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
ui/src/remotes/add_wizard.rs | 2 +-
ui/src/remotes/wizard_page_connect.rs | 16 +++++++++++-----
ui/src/remotes/wizard_page_info.rs | 25 +++++++++++++++++--------
3 files changed, 29 insertions(+), 14 deletions(-)
diff --git a/ui/src/remotes/add_wizard.rs b/ui/src/remotes/add_wizard.rs
index 205d8ff..72ab9cb 100644
--- a/ui/src/remotes/add_wizard.rs
+++ b/ui/src/remotes/add_wizard.rs
@@ -114,7 +114,7 @@ impl Component for AddWizardState {
let info = self.connect_info.clone();
let link = ctx.link().clone();
move |p: &WizardPageRenderInfo| {
- WizardPageInfo::new(p.clone())
+ WizardPageInfo::new(p.clone(), remote_type)
.connect_info(info.clone())
.on_server_change(link.callback(Msg::ServerChange))
.into()
diff --git a/ui/src/remotes/wizard_page_connect.rs b/ui/src/remotes/wizard_page_connect.rs
index ce2a36b..e59a506 100644
--- a/ui/src/remotes/wizard_page_connect.rs
+++ b/ui/src/remotes/wizard_page_connect.rs
@@ -1,6 +1,6 @@
use std::rc::Rc;
-use anyhow::{bail, Error};
+use anyhow::Error;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use yew::html::IntoEventCallback;
@@ -45,16 +45,22 @@ pub struct ConnectParams {
}
async fn connect(form_ctx: FormContext, remote_type: RemoteType) -> Result<TlsProbeOutcome, Error> {
+ let hostname = normalize_hostname(form_ctx.read().get_field_text("hostname"));
+ let fingerprint = get_fingerprint(&form_ctx);
+ let pdm_client = crate::pdm_client();
match remote_type {
RemoteType::Pve => {
- let hostname = normalize_hostname(form_ctx.read().get_field_text("hostname"));
- let fingerprint = get_fingerprint(&form_ctx);
- crate::pdm_client()
+ pdm_client
.pve_probe_tls(&hostname, fingerprint.as_deref())
.await
.map_err(Error::from)
}
- RemoteType::Pbs => bail!("not implemented"),
+ RemoteType::Pbs => {
+ pdm_client
+ .pbs_probe_tls(&hostname, fingerprint.as_deref())
+ .await
+ .map_err(Error::from)
+ }
}
}
diff --git a/ui/src/remotes/wizard_page_info.rs b/ui/src/remotes/wizard_page_info.rs
index da7c38b..1e0bdf1 100644
--- a/ui/src/remotes/wizard_page_info.rs
+++ b/ui/src/remotes/wizard_page_info.rs
@@ -18,7 +18,7 @@ use pwt::{
AsyncPool,
};
-use pdm_api_types::remotes::{NodeUrl, Remote};
+use pdm_api_types::remotes::{NodeUrl, Remote, RemoteType};
use pwt_macros::builder;
@@ -37,11 +37,12 @@ pub struct WizardPageInfo {
#[builder]
#[prop_or_default]
connect_info: Option<ConnectParams>,
+ remote_type: RemoteType,
}
impl WizardPageInfo {
- pub fn new(info: WizardPageRenderInfo) -> Self {
- yew::props!(Self { info })
+ pub fn new(info: WizardPageRenderInfo, remote_type: RemoteType) -> Self {
+ yew::props!(Self { info, remote_type })
}
}
@@ -72,7 +73,7 @@ pub struct ScanParams {
fingerprint: Option<String>,
}
-async fn scan(connection_params: ConnectParams, form_ctx: FormContext) -> Result<Remote, Error> {
+async fn scan(connection_params: ConnectParams, form_ctx: FormContext, remote_type: RemoteType) -> Result<Remote, Error> {
let mut data = form_ctx.get_submit_data();
data["hostname"] = connection_params.hostname.into();
@@ -87,9 +88,15 @@ async fn scan(connection_params: ConnectParams, form_ctx: FormContext) -> Result
fingerprint,
} = serde_json::from_value(data.clone())?;
- let mut result = crate::pdm_client()
- .pve_scan_remote(&hostname, fingerprint.as_deref(), &authid, &token)
- .await?;
+ let client = crate::pdm_client();
+ let mut result = match remote_type {
+ RemoteType::Pve => client
+ .pve_scan_remote(&hostname, fingerprint.as_deref(), &authid, &token)
+ .await?,
+ RemoteType::Pbs => client
+ .pbs_scan_remote(&hostname, fingerprint.as_deref(), &authid, &token)
+ .await?,
+ };
// try to deduplicate the entered info from the first page with the nodelist here
// either via the hostname or the fingerprint. if none matches the entered info will
@@ -235,8 +242,10 @@ impl Component for PdmWizardPageInfo {
props.info.page_lock(true);
if let Some(connection_info) = props.connect_info.clone() {
+ let remote_type = props.remote_type;
+
self.async_pool.spawn(async move {
- let result = scan(connection_info, form_ctx).await;
+ let result = scan(connection_info, form_ctx, remote_type).await;
link.send_message(Msg::ConnectResult(result));
});
} else {
--
2.47.3
More information about the pdm-devel
mailing list