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 9C6A81FF13F for ; Thu, 07 May 2026 14:01:14 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 475BC16C78; Thu, 7 May 2026 14:01:00 +0200 (CEST) From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= To: pve-devel@lists.proxmox.com Subject: [PATCH proxmox-offline-mirror 8/8] subscription handling: adapt to multiple server ID candidates Date: Thu, 7 May 2026 13:59:29 +0200 Message-ID: <20260507115957.1497272-9-f.gruenbichler@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260507115957.1497272-1-f.gruenbichler@proxmox.com> References: <20260507115957.1497272-1-f.gruenbichler@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1778155098518 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.054 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: LDKMBXRKD4MKDMOMAYDVBFNN5XCPXTTC X-Message-ID-Hash: LDKMBXRKD4MKDMOMAYDVBFNN5XCPXTTC X-MailFrom: f.gruenbichler@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 VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: when setting a new POM key, pick the first candidate. when a key is already configured, keep re-using its server ID. for managed offline keys, set any matching key. Signed-off-by: Fabian Grünbichler --- requires bumped proxmox-subscription src/bin/proxmox-offline-mirror-helper.rs | 36 +++++++++++++++---- src/bin/proxmox-offline-mirror.rs | 6 +++- .../subscription.rs | 5 ++- 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/src/bin/proxmox-offline-mirror-helper.rs b/src/bin/proxmox-offline-mirror-helper.rs index 0c40338..dff41c5 100644 --- a/src/bin/proxmox-offline-mirror-helper.rs +++ b/src/bin/proxmox-offline-mirror-helper.rs @@ -252,11 +252,20 @@ async fn setup(_param: Value) -> Result<(), Error> { println!(); } Action::UpdateOfflineSubscription => { - let server_id = proxmox_subscription::get_hardware_address()?; + let server_id_candidates = proxmox_subscription::get_hardware_address_candidates()? + .into_iter() + .map(|server_id| server_id.to_string()) + .collect::>(); let mut subscriptions: Vec<((ProductType, &SubscriptionInfo), &str)> = state .subscriptions .iter() - .filter(|sub| sub.serverid.as_ref() == Some(&server_id)) + .filter(|sub| { + if let Some(server_id) = sub.serverid.as_ref() { + server_id_candidates.contains(server_id) + } else { + false + } + }) .filter_map(|sub| { sub.get_product_type() .ok() @@ -277,7 +286,10 @@ async fn setup(_param: Value) -> Result<(), Error> { }); if subscriptions.is_empty() { - println!("No matching subscription key found for server ID '{server_id}'"); + println!("No matching subscription key found for server ID candidates:"); + for server_id in server_id_candidates { + println!("- {server_id}"); + } } else { let (product, info) = read_selection_from_tty("Select key", &subscriptions, None)?; @@ -327,12 +339,21 @@ async fn setup_offline_key( epoch_to_rfc3339_utc(state.last_sync)? ); - let server_id = proxmox_subscription::get_hardware_address()?; + let server_id_candidates = proxmox_subscription::get_hardware_address_candidates()? + .into_iter() + .map(|server_id| server_id.to_string()) + .collect::>(); let subscriptions: HashMap = state .subscriptions .iter() - .filter(|sub| sub.serverid.as_ref() == Some(&server_id)) + .filter(|sub| { + if let Some(server_id) = sub.serverid.as_ref() { + server_id_candidates.contains(server_id) + } else { + false + } + }) .filter_map(|sub| sub.get_product_type().ok().map(|prod| (prod, sub))) .filter(|(found_product, _)| { (product.is_none() || Some(found_product) == product.as_ref()) @@ -350,7 +371,10 @@ async fn setup_offline_key( }); if subscriptions.is_empty() { - bail!("No matching subscription key found for server ID '{server_id}'"); + bail!( + "No matching subscription key found for server ID candidates:\n{}", + server_id_candidates.join(", ") + ); } for (product, subscription) in subscriptions { diff --git a/src/bin/proxmox-offline-mirror.rs b/src/bin/proxmox-offline-mirror.rs index 1a752d2..750bedb 100644 --- a/src/bin/proxmox-offline-mirror.rs +++ b/src/bin/proxmox-offline-mirror.rs @@ -703,7 +703,11 @@ fn action_add_key(config: &SectionConfigData) -> Result } let server_id = if product == &ProductType::Pom { - let server_id = proxmox_subscription::get_hardware_address()?; + let server_id_candidates = proxmox_subscription::get_hardware_address_candidates()?; + let server_id = server_id_candidates + .first() + .ok_or_else(|| format_err!("Failed to generate server ID for this system."))? + .to_string(); println!("Server ID of this system is '{server_id}'"); server_id } else { diff --git a/src/bin/proxmox_offline_mirror_cmds/subscription.rs b/src/bin/proxmox_offline_mirror_cmds/subscription.rs index eea7f9a..b486278 100644 --- a/src/bin/proxmox_offline_mirror_cmds/subscription.rs +++ b/src/bin/proxmox_offline_mirror_cmds/subscription.rs @@ -220,7 +220,10 @@ async fn add_mirror_key(config: Option, key: String, _param: Value) -> R ); } - let server_id = proxmox_subscription::get_hardware_address()?; + let server_id = proxmox_subscription::get_hardware_address_candidates()? + .first() + .ok_or_else(|| format_err!("Failed to generate server ID."))? + .to_string(); let mut data = SubscriptionKey { key, server_id, -- 2.47.3