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 178CC1FF296 for ; Fri, 10 Apr 2026 12:03:28 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3E6BD19F20; Fri, 10 Apr 2026 12:04:05 +0200 (CEST) From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= To: pve-devel@lists.proxmox.com Subject: [RFC manager 5/6] subscription: adapt to multiple server ID variants Date: Fri, 10 Apr 2026 12:02:22 +0200 Message-ID: <20260410100326.3199377-6-f.gruenbichler@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260410100326.3199377-1-f.gruenbichler@proxmox.com> References: <20260410100326.3199377-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: 1775815342758 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: VVFKUGCL4ZT2ZHRPYTGLLQSFMRX4MAJY X-Message-ID-Hash: VVFKUGCL4ZT2ZHRPYTGLLQSFMRX4MAJY 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: if there already is a subscription info with ID, reuse it. if not, use the first candidate. Signed-off-by: Fabian Grünbichler --- Notes: requires bumped libpve-rs-perl PVE/API2/Subscription.pm | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/PVE/API2/Subscription.pm b/PVE/API2/Subscription.pm index 59e7fe747..0a9e59810 100644 --- a/PVE/API2/Subscription.pm +++ b/PVE/API2/Subscription.pm @@ -58,7 +58,7 @@ sub check_key { sub read_etc_subscription { my $req_sockets = get_sockets(); - my $server_id = PVE::API2Tools::get_hwaddress(); + my $server_id_candidates = Proxmox::RS::Subscription::get_hardware_address_candidates(); my $info = Proxmox::RS::Subscription::read_subscription($filename); @@ -89,7 +89,7 @@ my sub cache_is_valid { sub write_etc_subscription { my ($info) = @_; - my $server_id = PVE::API2Tools::get_hwaddress(); + my $server_id_candidates = Proxmox::RS::Subscription::get_hardware_address_candidates(); mkdir "/etc/apt/auth.conf.d"; Proxmox::RS::Subscription::write_subscription( $filename, @@ -205,7 +205,8 @@ __PACKAGE__->register_method({ my $authuser = $rpcenv->get_user(); my $has_permission = $rpcenv->check($authuser, "/nodes/$node", ['Sys.Audit'], 1); - my $server_id = PVE::API2Tools::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/en/proxmox-virtual-environment/pricing"; my $info = read_etc_subscription(); @@ -227,7 +228,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->{sockets} = get_sockets(); $info->{url} = $url; @@ -264,8 +271,12 @@ __PACKAGE__->register_method({ my $info = read_etc_subscription(); return undef if !$info; - my $server_id = PVE::API2Tools::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"; + } die "Updating offline key not possible - please remove and re-add subscription key to switch to online key.\n" @@ -324,7 +335,10 @@ __PACKAGE__->register_method({ }; my $req_sockets = get_sockets(); - my $server_id = PVE::API2Tools::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; check_key($key, $req_sockets); -- 2.47.3