From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 98E161FF165 for ; Thu, 6 Nov 2025 13:42:59 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 393B115972; Thu, 6 Nov 2025 13:43:40 +0100 (CET) From: Shannon Sterz To: pdm-devel@lists.proxmox.com Date: Thu, 6 Nov 2025 13:43:30 +0100 Message-ID: <20251106124334.189955-3-s.sterz@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251106124334.189955-1-s.sterz@proxmox.com> References: <20251106124334.189955-1-s.sterz@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1762432997390 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.060 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 yew-comp 1/2] node info: extend NodeStatus enum to include NodeStatus from proxmox-rs 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" Signed-off-by: Shannon Sterz Reviewed-by: Dominik Csapak Tested-by: Dominik Csapak --- Cargo.toml | 1 + src/node_info.rs | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 39109c0..ecce886 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -84,6 +84,7 @@ proxmox-apt-api-types = { version = "2.0", optional = true } proxmox-access-control = "1.1" proxmox-dns-api = { version = "1", optional = true } proxmox-network-api = { version = "1", optional = true } +proxmox-node-status = { version = "1", features = [] } pve-api-types = "8" pbs-api-types = "1" diff --git a/src/node_info.rs b/src/node_info.rs index 17ba6cd..5604787 100644 --- a/src/node_info.rs +++ b/src/node_info.rs @@ -1,4 +1,5 @@ use proxmox_human_byte::HumanByte; +use proxmox_node_status::BootMode; use pwt::{prelude::*, widget::Container}; use crate::{MeterLabel, StatusRow}; @@ -7,6 +8,7 @@ use crate::{MeterLabel, StatusRow}; pub enum NodeStatus<'a> { Pve(&'a pve_api_types::NodeStatus), Pbs(&'a pbs_api_types::NodeStatus), + Common(&'a proxmox_node_status::NodeStatus), } impl<'a> From<&'a pve_api_types::NodeStatus> for NodeStatus<'a> { @@ -29,6 +31,7 @@ pub fn node_info(data: Option) -> Container { let (cpu, cpus_total) = match data { Some(NodeStatus::Pve(node_status)) => (node_status.cpu, node_status.cpuinfo.cpus as u64), Some(NodeStatus::Pbs(node_status)) => (node_status.cpu, node_status.cpuinfo.cpus as u64), + Some(NodeStatus::Common(node_status)) => (node_status.cpu, node_status.cpuinfo.cpus as u64), None => (0.0, 1), }; @@ -39,6 +42,7 @@ pub fn node_info(data: Option) -> Container { .and_then(|wait| wait.as_f64()) .unwrap_or_default(), Some(NodeStatus::Pbs(node_status)) => node_status.wait, + Some(NodeStatus::Common(node_status)) => node_status.wait, None => 0.0, }; @@ -48,6 +52,9 @@ pub fn node_info(data: Option) -> Container { node_status.memory.total as u64, ), Some(NodeStatus::Pbs(node_status)) => (node_status.memory.used, node_status.memory.total), + Some(NodeStatus::Common(node_status)) => { + (node_status.memory.used, node_status.memory.total) + } None => (0, 1), }; @@ -57,6 +64,10 @@ pub fn node_info(data: Option) -> Container { "{:.2} {:.2} {:.2}", node_status.loadavg[0], node_status.loadavg[1], node_status.loadavg[2] ), + Some(NodeStatus::Common(node_status)) => format!( + "{:.2} {:.2} {:.2}", + node_status.loadavg[0], node_status.loadavg[1], node_status.loadavg[2] + ), None => tr!("N/A"), }; @@ -66,6 +77,7 @@ pub fn node_info(data: Option) -> Container { node_status.rootfs.total as u64, ), Some(NodeStatus::Pbs(node_status)) => (node_status.root.used, node_status.root.total), + Some(NodeStatus::Common(node_status)) => (node_status.root.used, node_status.root.total), None => (0, 1), }; @@ -90,6 +102,7 @@ pub fn node_info(data: Option) -> Container { } } Some(NodeStatus::Pbs(node_status)) => (node_status.swap.used, node_status.swap.total), + Some(NodeStatus::Common(node_status)) => (node_status.swap.used, node_status.swap.total), None => (0, 1), }; @@ -102,6 +115,10 @@ pub fn node_info(data: Option) -> Container { node_status.cpuinfo.model.clone(), node_status.cpuinfo.sockets as u64, ), + Some(NodeStatus::Common(node_status)) => ( + node_status.cpuinfo.model.clone(), + node_status.cpuinfo.sockets as u64, + ), None => (String::new(), 1), }; @@ -121,9 +138,20 @@ pub fn node_info(data: Option) -> Container { node_status.current_kernel.release.clone(), node_status.current_kernel.version.clone(), ), + Some(NodeStatus::Common(node_status)) => ( + node_status.current_kernel.sysname.clone(), + node_status.current_kernel.release.clone(), + node_status.current_kernel.version.clone(), + ), None => (String::new(), String::new(), String::new()), }; + let boot_mode = if let Some(NodeStatus::Common(node_status)) = data { + Some(&node_status.boot_info) + } else { + None + }; + Container::new() .class("pwt-d-grid pwt-gap-2 pwt-align-items-center") .style("grid-template-columns", "1fr 20px 1fr") @@ -221,4 +249,14 @@ pub fn node_info(data: Option) -> Container { .style("grid-column", "1/-1") .status(format!("{} {} {}", k_sysname, k_release, k_version)), ) + .with_optional_child(boot_mode.map(|m| { + let mode = match m.mode { + BootMode::Efi => tr!("Legacy BIOS"), + BootMode::LegacyBios if m.secureboot => tr!("UEFI (Secure Boot Enabled)"), + BootMode::LegacyBios => tr!("UEFI"), + }; + StatusRow::new(tr!("Boot Mode")) + .style("grid-column", "1/-1") + .status(mode) + })) } -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel