From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH pmg-api 6/8] subscription: adapt to multiple server ID variants
Date: Thu, 7 May 2026 13:59:27 +0200 [thread overview]
Message-ID: <20260507115957.1497272-7-f.gruenbichler@proxmox.com> (raw)
In-Reply-To: <20260507115957.1497272-1-f.gruenbichler@proxmox.com>
if there already is a subscription info with ID, reusite. if not, use the first
candidate.
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
Notes:
requires bumped pmg-rs with proxmox-subscription changes included
src/PMG/API2/Subscription.pm | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/src/PMG/API2/Subscription.pm b/src/PMG/API2/Subscription.pm
index edc1d18..3004b90 100644
--- a/src/PMG/API2/Subscription.pm
+++ b/src/PMG/API2/Subscription.pm
@@ -33,7 +33,7 @@ sub parse_key {
}
sub read_etc_subscription {
- my $server_id = PMG::Utils::get_hwaddress();
+ my $server_id_candidates = Proxmox::RS::Subscription::get_hardware_address_candidates();
my $info = Proxmox::RS::Subscription::read_subscription($filename);
return $info if !$info;
@@ -50,7 +50,7 @@ sub read_etc_subscription {
sub write_etc_subscription {
my ($info) = @_;
- my $server_id = PMG::Utils::get_hwaddress();
+ my $server_id_candidates = Proxmox::RS::Subscription::get_hardware_address_candidates();
Proxmox::RS::Subscription::write_subscription(
$filename,
@@ -77,7 +77,8 @@ __PACKAGE__->register_method({
code => sub {
my ($param) = @_;
- my $server_id = PMG::Utils::get_hwaddress();
+ my $server_id_candidates = Proxmox::RS::Subscription::get_hardware_address_candidates();
+ my $server_id = $server_id_candidates->[0]->[1];
my $url = "https://www.proxmox.com/proxmox-mail-gateway/pricing";
my $info = read_etc_subscription();
if (!$info) {
@@ -89,7 +90,13 @@ __PACKAGE__->register_method({
};
}
- $info->{serverid} = $server_id;
+ # none set yet
+ $info->{serverid} = $server_id if !defined($info->{serverid});
+
+ if ((grep { my $id = $_->[1]; $id eq $info->{serverid} } $server_id_candidates->@*) < 1) {
+ # mismatch, reset
+ $info->{serverid} = $server_id;
+ }
$info->{url} = $url;
return $info;
@@ -124,8 +131,13 @@ __PACKAGE__->register_method({
my $info = read_etc_subscription();
return undef if !$info;
- my $server_id = PMG::Utils::get_hwaddress();
+ my $server_id_candidates = Proxmox::RS::Subscription::get_hardware_address_candidates();
my $key = $info->{key};
+ my $server_id = $info->{serverid} // $server_id_candidates->[0]->[1];
+ if ((grep { my $id = $_->[1]; $id eq $server_id } $server_id_candidates->@*) < 1) {
+ die "no matching server ID found\n";
+ }
+
# key has been recently checked
return undef
@@ -179,7 +191,10 @@ __PACKAGE__->register_method({
checktime => time(),
};
- my $server_id = PMG::Utils::get_hwaddress();
+ my $server_id_candidates = Proxmox::RS::Subscription::get_hardware_address_candidates();
+ my $server_id = $server_id_candidates->[0]->[1];
+
+ die "Failed to generate server ID\n" if !$server_id;
write_etc_subscription($info);
--
2.47.3
next prev parent reply other threads:[~2026-05-07 12:00 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 ` Fabian Grünbichler [this message]
2026-05-07 11:59 ` [PATCH pmg-api 7/8] utils: drop now " Fabian Grünbichler
2026-05-07 11:59 ` [PATCH proxmox-offline-mirror 8/8] subscription handling: adapt to multiple server ID candidates 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=20260507115957.1497272-7-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.