From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
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 [thread overview]
Message-ID: <20260507115957.1497272-9-f.gruenbichler@proxmox.com> (raw)
In-Reply-To: <20260507115957.1497272-1-f.gruenbichler@proxmox.com>
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 <f.gruenbichler@proxmox.com>
---
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::<Vec<_>>();
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::<Vec<_>>();
let subscriptions: HashMap<ProductType, &SubscriptionInfo> = 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<SubscriptionKey, Error>
}
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<String>, 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
prev parent reply other threads:[~2026-05-07 12:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-07 11:59 [PATCH manager/pmg-api/proxmox{,-backup,-perl-rs,-offline-mirror} 0/8] adapt subscription handling to alternative server IDs Fabian Grünbichler
2026-05-07 11:59 ` [PATCH proxmox 1/8] proxmox-subscription: add new machine-id based serverid Fabian Grünbichler
2026-05-07 11:59 ` [PATCH proxmox-backup 2/8] subscription: adapt to multiple server ID variants Fabian Grünbichler
2026-05-07 11:59 ` [PATCH proxmox-perl-rs 3/8] common: subscription: expose server ID candidates Fabian Grünbichler
2026-05-07 11:59 ` [PATCH manager 4/8] subscription: adapt to multiple server ID variants Fabian Grünbichler
2026-05-07 11:59 ` [PATCH manager 5/8] api2tools: remove unused get_hwaddress Fabian Grünbichler
2026-05-07 11:59 ` [PATCH pmg-api 6/8] subscription: adapt to multiple server ID variants Fabian Grünbichler
2026-05-07 11:59 ` [PATCH pmg-api 7/8] utils: drop now unused get_hwaddress Fabian Grünbichler
2026-05-07 11:59 ` Fabian Grünbichler [this message]
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=20260507115957.1497272-9-f.gruenbichler@proxmox.com \
--to=f.gruenbichler@proxmox.com \
--cc=pve-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