From: Christoph Heiss <c.heiss@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [PATCH proxmox 05/16] installer-types: systeminfo: add check for API token creation capability
Date: Fri, 31 Jul 2026 16:35:28 +0200 [thread overview]
Message-ID: <20260731143910.936881-6-c.heiss@proxmox.com> (raw)
In-Reply-To: <20260731143910.936881-1-c.heiss@proxmox.com>
Only newer installers support creating API tokens on (supported)
products, i.e. currently PVE and PBS only, for usage with PDM.
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
proxmox-installer-types/src/lib.rs | 73 +++++++++++++++++++++++++++++-
1 file changed, 72 insertions(+), 1 deletion(-)
diff --git a/proxmox-installer-types/src/lib.rs b/proxmox-installer-types/src/lib.rs
index 718867be..b04de27e 100644
--- a/proxmox-installer-types/src/lib.rs
+++ b/proxmox-installer-types/src/lib.rs
@@ -14,7 +14,10 @@ pub mod post_hook;
use proxmox_schema::api;
use serde::{Deserialize, Serialize};
-use std::collections::{BTreeMap, HashMap};
+use std::{
+ cmp::Ordering,
+ collections::{BTreeMap, HashMap},
+};
use proxmox_network_types::mac_address::MacAddress;
@@ -67,6 +70,17 @@ pub struct SystemInfo {
pub network_interfaces: Vec<NetworkInterface>,
}
+impl SystemInfo {
+ /// Determines whether the product supports creating an API token during installation.
+ pub fn supports_api_token_creation(&self) -> bool {
+ match self.product.product {
+ ProxmoxProduct::Pve => self.iso.product_version() >= ProductVersion(9, 2, 2),
+ ProxmoxProduct::Pbs => self.iso.product_version() >= ProductVersion(4, 2, 2),
+ _ => false,
+ }
+ }
+}
+
#[cfg_attr(feature = "api-types", api)]
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
/// The per-product configuration of the installer.
@@ -108,6 +122,19 @@ impl IsoInfo {
isorelease: String::from("mocked-1"),
}
}
+
+ /// Returns the product version contained in the ISO.
+ pub fn product_version(&self) -> ProductVersion {
+ let rel = self
+ .isorelease
+ .parse()
+ // some ALPHA-X, BETA-X release, treat them as 0
+ .unwrap_or(0);
+
+ parse_version(&self.release)
+ .map(|(maj, min)| ProductVersion(maj, min, rel))
+ .unwrap_or_else(|| ProductVersion(0, 0, 0))
+ }
}
#[cfg_attr(feature = "api-types", api(
@@ -178,6 +205,29 @@ impl ProxmoxProduct {
Self::Pdm => "Proxmox Datacenter Manager",
}
}
+
+ /// Determines whether the product supports creating an API token during installation.
+ pub fn supports_api_token_creation(&self) -> bool {
+ matches!(self, ProxmoxProduct::Pve | ProxmoxProduct::Pbs)
+ }
+}
+
+/// Represents a (major, minor, patch) product version tuple.
+#[derive(Debug, PartialEq, Eq)]
+pub struct ProductVersion(pub u32, pub u32, pub u32);
+
+impl PartialOrd for ProductVersion {
+ fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
+ match (
+ self.0.cmp(&other.0),
+ self.1.cmp(&other.1),
+ self.2.cmp(&other.2),
+ ) {
+ (Ordering::Equal, Ordering::Equal, ord) => Some(ord),
+ (Ordering::Equal, ord, _) => Some(ord),
+ (ord, _, _) => Some(ord),
+ }
+ }
}
pub(crate) fn parse_version(s: &str) -> Option<(u32, u32)> {
@@ -196,4 +246,25 @@ mod tests {
assert_eq!(parse_version("42.1"), Some((42, 1)));
assert_eq!(parse_version("a.1"), None);
}
+
+ #[test]
+ fn iso_is_version_at_least_works() {
+ let iso = IsoInfo {
+ release: "9.1".into(),
+ isorelease: "1".into(),
+ };
+
+ assert!(iso.product_version() >= ProductVersion(9, 0, 2));
+ assert!(iso.product_version() < ProductVersion(9, 2, 1));
+ assert!(iso.product_version() >= ProductVersion(9, 1, 1));
+ assert!(iso.product_version() < ProductVersion(9, 1, 2));
+
+ let iso = IsoInfo {
+ release: "9.1".into(),
+ isorelease: "ALPHA-1".into(),
+ };
+
+ assert!(iso.product_version() == ProductVersion(9, 1, 0));
+ assert!(iso.product_version() < ProductVersion(9, 1, 1));
+ }
}
--
2.54.0
next prev parent reply other threads:[~2026-07-31 14:39 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-31 14:35 [PATCH proxmox/installer/datacenter-manager 00/16] auto-installer: add installed target systems as new remotes Christoph Heiss
2026-07-31 14:35 ` [PATCH proxmox 01/16] installer-types: drop unnecessary clippy attribute Christoph Heiss
2026-07-31 14:35 ` [PATCH proxmox 02/16] installer-types: post-hook: factor schema version into proper struct Christoph Heiss
2026-07-31 14:35 ` [PATCH proxmox 03/16] installer-types: post-hook: allow additional properties on api schema Christoph Heiss
2026-07-31 14:35 ` [PATCH proxmox 04/16] installer-types: post-hook: add api-token and cert-fingerprint options Christoph Heiss
2026-07-31 14:35 ` Christoph Heiss [this message]
2026-07-31 14:35 ` [PATCH installer 06/16] chroot: print full error if bind-mounting fails Christoph Heiss
2026-07-31 14:35 ` [PATCH installer 07/16] post-hook: re-use low-level config retrieval from proxmox-chroot Christoph Heiss
2026-07-31 14:35 ` [PATCH installer 08/16] post-hook: generate and retrieve node certificate fingerprint Christoph Heiss
2026-07-31 14:35 ` [PATCH installer 09/16] post-hook: support creating API token if requested in answer file Christoph Heiss
2026-07-31 14:35 ` [PATCH installer 10/16] auto: enforce https for post hook when generating an API token Christoph Heiss
2026-07-31 14:35 ` [PATCH installer 11/16] assistant: validate-answer: also verify post-hook settings if set Christoph Heiss
2026-07-31 14:35 ` [PATCH datacenter-manager 12/16] ui: auto-installer: spell out Proxmox Datacenter Manager Christoph Heiss
2026-07-31 14:35 ` [PATCH datacenter-manager 13/16] config: auto-install: add optional `post-hook-add-as-remote` field Christoph Heiss
2026-07-31 14:35 ` [PATCH datacenter-manager 14/16] api: auto-installer: add option for adding new remotes to PDM Christoph Heiss
2026-07-31 14:35 ` [PATCH datacenter-manager 15/16] ui: auto-installer: wizard: add checkbox to add target as new remote Christoph Heiss
2026-07-31 14:35 ` [PATCH datacenter-manager 16/16] docs: auto-installer: document adding targets as remotes afterwards Christoph Heiss
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=20260731143910.936881-6-c.heiss@proxmox.com \
--to=c.heiss@proxmox.com \
--cc=pdm-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