From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [RFC proxmox-backup 3/6] subscription: adapt to multiple server ID variants
Date: Fri, 10 Apr 2026 12:02:20 +0200 [thread overview]
Message-ID: <20260410100326.3199377-4-f.gruenbichler@proxmox.com> (raw)
In-Reply-To: <20260410100326.3199377-1-f.gruenbichler@proxmox.com>
if there already is a subscription info, re-use the server ID contained within.
if not, use the first candidate.
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
Notes:
requires bumped librust-proxmox-subscription-dev
src/api2/node/subscription.rs | 38 ++++++++++++++++++++++++++---------
1 file changed, 28 insertions(+), 10 deletions(-)
diff --git a/src/api2/node/subscription.rs b/src/api2/node/subscription.rs
index 03d613ee2..6935e4e3f 100644
--- a/src/api2/node/subscription.rs
+++ b/src/api2/node/subscription.rs
@@ -102,7 +102,15 @@ pub fn check_subscription(force: bool) -> Result<(), Error> {
Ok(None) => return Ok(()),
};
- let server_id = proxmox_subscription::get_hardware_address()?;
+ let server_id = if let Some(existing) = info.serverid.as_ref() {
+ existing.to_owned()
+ } else {
+ proxmox_subscription::get_hardware_address_candidates()?
+ .first()
+ .ok_or_else(|| format_err!("Failed to generate serverid"))?
+ .to_string()
+ };
+
let key = if let Some(key) = info.key.as_ref() {
// always update apt auth if we have a key to ensure user can access enterprise repo
proxmox_subscription::files::update_apt_auth(
@@ -110,7 +118,7 @@ pub fn check_subscription(force: bool) -> Result<(), Error> {
apt_auth_file_opts(),
APT_AUTH_URL,
Some(key.to_owned()),
- Some(server_id.to_owned()),
+ Some(server_id.clone()),
)?;
key.to_owned()
} else {
@@ -124,6 +132,7 @@ pub fn check_subscription(force: bool) -> Result<(), Error> {
if !force && info.status == SubscriptionStatus::Active {
// will set to INVALID if last check too long ago
info.check_age(true);
+
if info.status == SubscriptionStatus::Active {
return Ok(());
}
@@ -156,13 +165,19 @@ pub fn get_subscription(
) {
Err(err) => bail!("could not read subscription status: {}", err),
Ok(Some(info)) => info,
- Ok(None) => SubscriptionInfo {
- status: SubscriptionStatus::NotFound,
- message: Some("There is no subscription key".into()),
- serverid: Some(proxmox_subscription::get_hardware_address()?),
- url: Some(PRODUCT_URL.into()),
- ..Default::default()
- },
+ Ok(None) => {
+ let candidates = proxmox_subscription::get_hardware_address_candidates()?;
+ let serverid = candidates
+ .first()
+ .ok_or_else(|| format_err!("Failed to generate serverid"))?;
+ SubscriptionInfo {
+ status: SubscriptionStatus::NotFound,
+ message: Some("There is no subscription key".into()),
+ serverid: Some(serverid.to_string()),
+ url: Some(PRODUCT_URL.into()),
+ ..Default::default()
+ }
+ }
};
let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
@@ -200,7 +215,10 @@ pub fn get_subscription(
)]
/// Set a subscription key and check it.
pub fn set_subscription(key: String) -> Result<(), Error> {
- 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 serverid"))?
+ .to_string();
check_and_write_subscription(key, server_id)
}
--
2.47.3
next prev parent reply other threads:[~2026-04-10 10:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-10 10:02 [RFC manager/proxmox{,-backup,-perl-rs} 0/6] adapt subscription handling to alternative server IDs Fabian Grünbichler
2026-04-10 10:02 ` [PATCH proxmox 1/6] systemd: add support for machine-id generation Fabian Grünbichler
2026-04-10 10:02 ` [RFC proxmox 2/6] proxmox-subscription: add new machine-id based serverid Fabian Grünbichler
2026-04-10 10:02 ` Fabian Grünbichler [this message]
2026-04-10 10:02 ` [RFC proxmox-perl-rs 4/6] common: subscription: expose server ID candidates Fabian Grünbichler
2026-04-10 10:02 ` [RFC manager 5/6] subscription: adapt to multiple server ID variants Fabian Grünbichler
2026-04-10 10:02 ` [RFC manager 6/6] api2tools: remove unused get_hwaddress Fabian Grünbichler
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=20260410100326.3199377-4-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