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 2A61D1FF140 for ; Fri, 24 Apr 2026 10:31:06 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 77D33E191; Fri, 24 Apr 2026 10:30:01 +0200 (CEST) From: Lukas Wagner To: pbs-devel@lists.proxmox.com, pve-devel@lists.proxmox.com Subject: [PATCH pve-storage v2 9/9] api: add /nodes//storage//identity route Date: Fri, 24 Apr 2026 10:29:43 +0200 Message-ID: <20260424082943.89614-10-l.wagner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260424082943.89614-1-l.wagner@proxmox.com> References: <20260424082943.89614-1-l.wagner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1777019298361 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.004 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 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: OAGFYHD3XHX3ONWFAVACYFN3WVMWWPZP X-Message-ID-Hash: OAGFYHD3XHX3ONWFAVACYFN3WVMWWPZP 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 VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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. Signed-off-by: Lukas Wagner --- Notes: Changes since v2: - Change the return value as proposed by Thomas (include a type discrimininant and rename pbs-instance-id to id) - retrieve the identifier through the PBS plugin Changes since RFC v1: - Change endpoint path from 'instance-id' to 'identity', as this is more generic and could make more sense for other storages, if they ever need such a thing - Remove unused RpcEnv code - Adapt PBSClient call to 'get_server_identity' src/PVE/API2/Storage/Status.pm | 57 +++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/src/PVE/API2/Storage/Status.pm b/src/PVE/API2/Storage/Status.pm index 8225c3a..fb921cb 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); use PVE::API2::Storage::Content; use PVE::API2::Storage::FileRestore; @@ -23,6 +23,8 @@ use PVE::Storage; use base qw(PVE::RESTHandler); +my $storage_type_enum = PVE::Storage::Plugin->lookup_types(); + __PACKAGE__->register_method({ subclass => "PVE::API2::Storage::PruneBackups", path => '{storage}/prunebackups', @@ -308,6 +310,7 @@ __PACKAGE__->register_method({ { subdir => 'download-url' }, { subdir => 'file-restore' }, { subdir => 'import-metadata' }, + { subdir => 'identity' }, { subdir => 'oci-registry-pull' }, { subdir => 'prunebackups' }, { subdir => 'rrd' }, @@ -1118,4 +1121,56 @@ __PACKAGE__->register_method({ }, }); +__PACKAGE__->register_method({ + name => 'identity', + path => '{storage}/identity', + method => 'GET', + description => "Return identity information for this storage instance.", + permissions => { + check => ['perm', '/storage/{storage}', ['Datastore.Audit']], + }, + protected => 1, + proxyto => 'node', + parameters => { + additionalProperties => 0, + properties => { + node => get_standard_option('pve-node'), + storage => get_standard_option('pve-storage-id'), + }, + }, + returns => { + type => "object", + properties => { + 'type' => { + type => 'string', + description => 'The type of the storage.', + enum => $storage_type_enum, + }, + 'id' => { + type => 'string', + description => 'Unique identifier for this storage instance." + . " The exact format and semantics depend on the storage plugin type.', + }, + }, + }, + code => sub { + my ($param) = @_; + + my $storeid = extract_param($param, 'storage'); + + my $cfg = PVE::Storage::config(); + my $scfg = PVE::Storage::storage_config($cfg, $storeid); + + my $type = $scfg->{type}; + my $plugin = PVE::Storage::Plugin->lookup($type); + + my $id = $plugin->get_identity($scfg, $storeid); + + return { + type => $type, + id => $id, + }; + }, +}); + 1; -- 2.47.3