public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Lukas Wagner <l.wagner@proxmox.com>
To: pbs-devel@lists.proxmox.com, pve-devel@lists.proxmox.com
Subject: [PATCH pve-storage v2 9/9] api: add /nodes/<node>/storage/<storage>/identity route
Date: Fri, 24 Apr 2026 10:29:43 +0200	[thread overview]
Message-ID: <20260424082943.89614-10-l.wagner@proxmox.com> (raw)
In-Reply-To: <20260424082943.89614-1-l.wagner@proxmox.com>

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 <l.wagner@proxmox.com>
---

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





  parent reply	other threads:[~2026-04-24  8:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-24  8:29 [PATCH common/proxmox{,-backup}/storage v2 0/9] establish unique instance-id for PBS nodes Lukas Wagner
2026-04-24  8:29 ` [PATCH proxmox v2 1/9] pbs-api-types: add ServerIdentity response type Lukas Wagner
2026-04-24  8:29 ` [PATCH proxmox v2 2/9] systemd: add support for machine-id generation Lukas Wagner
2026-04-24  8:29 ` [PATCH proxmox-backup v2 3/9] api: add /nodes/localhost/identity Lukas Wagner
2026-04-24  8:29 ` [PATCH proxmox-backup v2 4/9] client: add 'server-identity' sub-command Lukas Wagner
2026-04-24  8:29 ` [PATCH proxmox-backup v2 5/9] manager: add 'server-identity' subcommand Lukas Wagner
2026-04-24  8:29 ` [PATCH common v2 6/9] pbs-client: add support for the 'server-identity' command Lukas Wagner
2026-04-24  8:29 ` [PATCH pve-storage v2 7/9] plugin: add get_identity method Lukas Wagner
2026-04-24  8:29 ` [PATCH pve-storage v2 8/9] bump storage plugin APIVER and reset APIAGE Lukas Wagner
2026-04-24  8:29 ` Lukas Wagner [this message]
2026-04-24 21:24 ` partially-applied: [PATCH common/proxmox{,-backup}/storage v2 0/9] establish unique instance-id for PBS nodes Thomas Lamprecht

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=20260424082943.89614-10-l.wagner@proxmox.com \
    --to=l.wagner@proxmox.com \
    --cc=pbs-devel@lists.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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal