From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 1332D1FF13A for ; Wed, 15 Apr 2026 10:42:34 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A7B1F886A; Wed, 15 Apr 2026 10:42:33 +0200 (CEST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Wed, 15 Apr 2026 10:41:57 +0200 Message-Id: Subject: Re: [PATCH pve-storage 7/7] api: add /nodes//storage//instance-id route From: "Lukas Wagner" To: "Christian Ebner" , "Lukas Wagner" , , X-Mailer: aerc 0.21.0-0-g5549850facc2-dirty References: <20260413121057.371772-1-l.wagner@proxmox.com> <20260413121057.371772-8-l.wagner@proxmox.com> <9a4d051a-58a5-445f-a127-c11706d93194@proxmox.com> In-Reply-To: <9a4d051a-58a5-445f-a127-c11706d93194@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1776242440534 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.003 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 POISEN_SPAM_PILL_3 0.1 random spam to be learned in bayes RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [status.pm] Message-ID-Hash: CGCSUOAAOPXQZ4VON4FNUBQJWQRLV6FV X-Message-ID-Hash: CGCSUOAAOPXQZ4VON4FNUBQJWQRLV6FV X-MailFrom: l.wagner@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 Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Tue Apr 14, 2026 at 4:38 PM CEST, Christian Ebner wrote: > On 4/13/26 2:11 PM, Lukas Wagner wrote: >> This API allows us to retrieve the instance ID of PBS storages. This is >> useful to establish a mapping between PBS storage and PBS remotes in >> PDM. >>=20 >> Signed-off-by: Lukas Wagner >> --- >>=20 >> Notes: >> Maybe we want to make this more general and just call it /id or >> something, in case we want to use a similar mechanism for other sto= rage >> types as well? >> =20 >> Also could make sense to cache the response. >>=20 >> src/PVE/API2/Storage/Status.pm | 50 +++++++++++++++++++++++++++++++++- >> 1 file changed, 49 insertions(+), 1 deletion(-) >>=20 >> diff --git a/src/PVE/API2/Storage/Status.pm b/src/PVE/API2/Storage/Statu= s.pm >> index 8225c3a..52aa673 100644 >> --- a/src/PVE/API2/Storage/Status.pm >> +++ b/src/PVE/API2/Storage/Status.pm >> @@ -14,7 +14,7 @@ use PVE::JSONSchema qw(get_standard_option); >> use PVE::RESTHandler; >> use PVE::RPCEnvironment; >> use PVE::RRD; >> -use PVE::Tools qw(run_command); >> +use PVE::Tools qw(run_command extract_param); >> =20 >> use PVE::API2::Storage::Content; >> use PVE::API2::Storage::FileRestore; >> @@ -308,6 +308,7 @@ __PACKAGE__->register_method({ >> { subdir =3D> 'download-url' }, >> { subdir =3D> 'file-restore' }, >> { subdir =3D> 'import-metadata' }, >> + { subdir =3D> 'instance-id' }, >> { subdir =3D> 'oci-registry-pull' }, >> { subdir =3D> 'prunebackups' }, >> { subdir =3D> 'rrd' }, >> @@ -1118,4 +1119,51 @@ __PACKAGE__->register_method({ >> }, >> }); >> =20 >> +__PACKAGE__->register_method({ >> + name =3D> 'instance_id', >> + path =3D> '{storage}/instance-id', >> + method =3D> 'GET', >> + description =3D> "Return unique storage instance ID (PBS only)", >> + permissions =3D> { >> + check =3D> ['perm', '/storage/{storage}', ['Datastore.Audit']], >> + }, >> + protected =3D> 1, >> + proxyto =3D> 'node', >> + parameters =3D> { >> + additionalProperties =3D> 0, >> + properties =3D> { >> + node =3D> get_standard_option('pve-node'), >> + storage =3D> get_standard_option('pve-storage-id'), >> + }, >> + }, >> + returns =3D> { >> + type =3D> "object", >> + properties =3D> { >> + 'instance-id' =3D> { >> + type =3D> 'string', >> + description =3D> 'Unique instance ID', >> + }, With the changes described below, I'd=20 - rename the property to 'pbs-instance-id' - make it optional (as a preparation for other storages that could have some 'identity info' that would be stored in a different key) >> + }, >> + }, >> + code =3D> sub { >> + my ($param) =3D @_; >> + >> + my $rpcenv =3D PVE::RPCEnvironment::get(); >> + my $user =3D $rpcenv->get_user(); >> + >> + my $storeid =3D extract_param($param, 'storage'); >> + >> + my $cfg =3D PVE::Storage::config(); >> + my $scfg =3D PVE::Storage::storage_config($cfg, $storeid); >> + >> + raise_param_exc({ 'storage' =3D> "Only PBS storages supported."= }) >> + if $scfg->{type} ne 'pbs'; >> + >> + my $client =3D PVE::PBSClient->new($scfg, $storeid); >> + my $ret =3D $client->get_instance_id(); > > nit: same as on previous patches, the client part should be called=20 > get_pbs_instance_id() to reflect that this stems from the server. > > I do agree however that this API endpoint name for PVE should be chosen= =20 > as generic as possible for better future extensibility. > I think I'm going to rename the API path to `identity`, as this seems to be generic enough to be useful for other storages as well. Maybe the method in PBSClient could then be called `get_server_identity`? What do you think? >> + >> + return $ret; >> + }, >> +}); >> + >> 1;