From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id E102B1FF187 for ; Mon, 22 Sep 2025 13:09:50 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1079918A7E; Mon, 22 Sep 2025 13:10:18 +0200 (CEST) From: Christian Ebner To: pdm-devel@lists.proxmox.com Date: Mon, 22 Sep 2025 13:09:57 +0200 Message-ID: <20250922110958.369653-6-c.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922110958.369653-1-c.ebner@proxmox.com> References: <20250922110958.369653-1-c.ebner@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1758539403124 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.043 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 5/6] ui: remote: check connection for PBS remotes in remote add wizard X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Datacenter Manager development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" 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 --- 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 { + 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, + 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, } -async fn scan(connection_params: ConnectParams, form_ctx: FormContext) -> Result { +async fn scan(connection_params: ConnectParams, form_ctx: FormContext, remote_type: RemoteType) -> Result { 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 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel