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 0EA181FF13E for ; Fri, 03 Apr 2026 18:55:41 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id CBD1B7FF5; Fri, 3 Apr 2026 18:56:11 +0200 (CEST) From: Christoph Heiss To: pdm-devel@lists.proxmox.com Subject: [PATCH proxmox v3 10/38] installer-types: add common types used by the installer Date: Fri, 3 Apr 2026 18:53:42 +0200 Message-ID: <20260403165437.2166551-11-c.heiss@proxmox.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260403165437.2166551-1-c.heiss@proxmox.com> References: <20260403165437.2166551-1-c.heiss@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1775235277507 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.064 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 Message-ID-Hash: 5RJ73E67RQZQ6PCJMO6MDT3ADY7DBHJ4 X-Message-ID-Hash: 5RJ73E67RQZQ6PCJMO6MDT3ADY7DBHJ4 X-MailFrom: c.heiss@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 Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: These moves common type definitions used throughout in the installer in it's own crate, so they can be re-used in other places. Some types are also renamed to improve clarity: - `NetdevWithMac` -> `NetworkInterface` - `SysInfo` -> `SystemInfo` Signed-off-by: Christoph Heiss --- Changes v2 -> v3: * changed `ProxmoxProduct` variants to PascalCase * fixed typo in `Display` impl Changes v1 -> v2: * no changes Note: The custom `BootType` enum was retained, as using an existing variant proved to be much more work/hacky due to different (de-)serialization expectations. Cargo.toml | 1 + proxmox-installer-types/Cargo.toml | 20 +++ proxmox-installer-types/debian/changelog | 5 + proxmox-installer-types/debian/control | 38 +++++ proxmox-installer-types/debian/debcargo.toml | 7 + proxmox-installer-types/src/lib.rs | 142 +++++++++++++++++++ 6 files changed, 213 insertions(+) create mode 100644 proxmox-installer-types/Cargo.toml create mode 100644 proxmox-installer-types/debian/changelog create mode 100644 proxmox-installer-types/debian/control create mode 100644 proxmox-installer-types/debian/debcargo.toml create mode 100644 proxmox-installer-types/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index 762fae36..bb1091a6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,6 +22,7 @@ members = [ "proxmox-http-error", "proxmox-human-byte", "proxmox-ini", + "proxmox-installer-types", "proxmox-io", "proxmox-lang", "proxmox-ldap", diff --git a/proxmox-installer-types/Cargo.toml b/proxmox-installer-types/Cargo.toml new file mode 100644 index 00000000..7b4db506 --- /dev/null +++ b/proxmox-installer-types/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "proxmox-installer-types" +description = "Type definitions used within the installer" +version = "0.1.0" + +authors.workspace = true +edition.workspace = true +license.workspace = true +repository.workspace = true +homepage.workspace = true +exclude.workspace = true +rust-version.workspace = true + +[dependencies] +serde = { workspace = true, features = ["derive"] } +serde_plain.workspace = true +proxmox-network-types.workspace = true + +[features] +default = [] diff --git a/proxmox-installer-types/debian/changelog b/proxmox-installer-types/debian/changelog new file mode 100644 index 00000000..d2415aa0 --- /dev/null +++ b/proxmox-installer-types/debian/changelog @@ -0,0 +1,5 @@ +rust-proxmox-installer-types (0.1.0-1) unstable; urgency=medium + + * Initial release. + + -- Proxmox Support Team Tue, 25 Nov 2025 10:23:32 +0200 diff --git a/proxmox-installer-types/debian/control b/proxmox-installer-types/debian/control new file mode 100644 index 00000000..d7e72f64 --- /dev/null +++ b/proxmox-installer-types/debian/control @@ -0,0 +1,38 @@ +Source: rust-proxmox-installer-types +Section: rust +Priority: optional +Build-Depends: debhelper-compat (= 13), + dh-sequence-cargo +Build-Depends-Arch: cargo:native , + rustc:native (>= 1.85) , + libstd-rust-dev , + librust-proxmox-network-types-1+default-dev (>= 1.0.2-~~) , + librust-serde-1+default-dev , + librust-serde-1+derive-dev , + librust-serde-plain-1+default-dev +Maintainer: Proxmox Support Team +Standards-Version: 4.7.2 +Vcs-Git: git://git.proxmox.com/git/proxmox.git +Vcs-Browser: https://git.proxmox.com/?p=proxmox.git +Homepage: https://proxmox.com +X-Cargo-Crate: proxmox-installer-types + +Package: librust-proxmox-installer-types-dev +Architecture: any +Multi-Arch: same +Depends: + ${misc:Depends}, + librust-proxmox-network-types-1+default-dev (>= 1.0.2-~~), + librust-serde-1+default-dev, + librust-serde-1+derive-dev, + librust-serde-plain-1+default-dev +Provides: + librust-proxmox-installer-types+default-dev (= ${binary:Version}), + librust-proxmox-installer-types-0-dev (= ${binary:Version}), + librust-proxmox-installer-types-0+default-dev (= ${binary:Version}), + librust-proxmox-installer-types-0.1-dev (= ${binary:Version}), + librust-proxmox-installer-types-0.1+default-dev (= ${binary:Version}), + librust-proxmox-installer-types-0.1.0-dev (= ${binary:Version}), + librust-proxmox-installer-types-0.1.0+default-dev (= ${binary:Version}) +Description: Type definitions used within the installer - Rust source code + Source code for Debianized Rust crate "proxmox-installer-types" diff --git a/proxmox-installer-types/debian/debcargo.toml b/proxmox-installer-types/debian/debcargo.toml new file mode 100644 index 00000000..b7864cdb --- /dev/null +++ b/proxmox-installer-types/debian/debcargo.toml @@ -0,0 +1,7 @@ +overlay = "." +crate_src_path = ".." +maintainer = "Proxmox Support Team " + +[source] +vcs_git = "git://git.proxmox.com/git/proxmox.git" +vcs_browser = "https://git.proxmox.com/?p=proxmox.git" diff --git a/proxmox-installer-types/src/lib.rs b/proxmox-installer-types/src/lib.rs new file mode 100644 index 00000000..adce4166 --- /dev/null +++ b/proxmox-installer-types/src/lib.rs @@ -0,0 +1,142 @@ +//! Defines API types used within the installer, primarily for interacting +//! with proxmox-auto-installer. +//! +//! [`BTreeMap`]s are used to store certain properties to keep the order of +//! them stable, compared to storing them in an ordinary [`HashMap`]. + +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] +#![deny(unsafe_code, missing_docs)] + +use serde::{Deserialize, Serialize}; +use std::collections::{BTreeMap, HashMap}; + +use proxmox_network_types::mac_address::MacAddress; + +/// Default placeholder value for the administrator email address. +pub const EMAIL_DEFAULT_PLACEHOLDER: &str = "mail@example.invalid"; + +#[derive(Copy, Clone, Eq, Deserialize, PartialEq, Serialize)] +#[serde(rename_all = "lowercase")] +/// Whether the system boots using legacy BIOS or (U)EFI. +pub enum BootType { + /// System boots using legacy BIOS. + Bios, + /// System boots using (U)EFI. + Efi, +} + +/// Uses a BTreeMap to have the keys sorted +pub type UdevProperties = BTreeMap; + +#[derive(Clone, Deserialize, Debug)] +/// Information extracted from udev about devices present in the system. +pub struct UdevInfo { + /// udev information for each disk. + pub disks: BTreeMap, + /// udev information for each network interface card. + pub nics: BTreeMap, +} + +#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] +/// Information about the hardware and installer in use. +pub struct SystemInfo { + /// Information about the product to be installed. + pub product: ProductConfig, + /// Information about the ISO. + pub iso: IsoInfo, + /// Raw DMI information of the system. + pub dmi: SystemDMI, + /// Network devices present on the system. + pub network_interfaces: Vec, +} + +#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] +/// The per-product configuration of the installer. +pub struct ProductConfig { + /// Full name of the product. + pub fullname: String, + /// The actual product the installer is for. + pub product: ProxmoxProduct, + /// Whether to enable installations on Btrfs. + pub enable_btrfs: bool, +} + +impl ProductConfig { + /// A mocked ProductConfig simulating a Proxmox VE environment. + pub fn mocked() -> Self { + Self { + fullname: String::from("Proxmox VE (mocked)"), + product: ProxmoxProduct::Pve, + enable_btrfs: true, + } + } +} + +#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] +/// Information about the ISO itself. +pub struct IsoInfo { + /// Version of the product. + pub release: String, + /// Version of the ISO itself, e.g. the spin. + pub isorelease: String, +} + +impl IsoInfo { + /// A mocked IsoInfo with some edge case to convey that this is not necessarily purely numeric. + pub fn mocked() -> Self { + Self { + release: String::from("42.1"), + isorelease: String::from("mocked-1"), + } + } +} + +#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] +/// Collection of various DMI information categories. +pub struct SystemDMI { + /// Information about the system baseboard. + pub baseboard: HashMap, + /// Information about the system chassis. + pub chassis: HashMap, + /// Information about the hardware itself, mostly identifiers. + pub system: HashMap, +} + +#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] +/// A unique network interface. +pub struct NetworkInterface { + /// The network link name + pub link: String, + /// The MAC address of the network device + pub mac: MacAddress, +} + +#[allow(clippy::upper_case_acronyms)] +#[derive(Debug, Clone, Copy, Deserialize, PartialEq, Eq, PartialOrd, Ord, Serialize)] +#[serde(rename_all = "lowercase")] +/// The name of the product. +pub enum ProxmoxProduct { + /// Proxmox Virtual Environment + Pve, + /// Proxmox Backup Server + Pbs, + /// Proxmox Mail Gateway + Pmg, + /// Proxmox Datacenter Manager + Pdm, +} + +serde_plain::derive_fromstr_from_deserialize!(ProxmoxProduct); +serde_plain::derive_display_from_serialize!(ProxmoxProduct); + +impl ProxmoxProduct { + /// Returns the full name for the given product. + pub fn full_name(&self) -> &str { + match self { + Self::Pve => "Proxmox Virtual Environment", + Self::Pbs => "Proxmox Backup Server", + Self::Pmg => "Proxmox Mail Gateway", + Self::Pdm => "Proxmox Datacenter Manager", + } + } +} -- 2.53.0