all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Christian Ebner <c.ebner@proxmox.com>
To: Lukas Wagner <l.wagner@proxmox.com>,
	pbs-devel@lists.proxmox.com, pve-devel@lists.proxmox.com
Subject: Re: [PATCH pve-storage 7/7] api: add /nodes/<node>/storage/<storage>/instance-id route
Date: Tue, 14 Apr 2026 16:38:13 +0200	[thread overview]
Message-ID: <9a4d051a-58a5-445f-a127-c11706d93194@proxmox.com> (raw)
In-Reply-To: <20260413121057.371772-8-l.wagner@proxmox.com>

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.
> 
> Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
> ---
> 
> 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 storage
>      types as well?
>      
>      Also could make sense to cache the response.
> 
>   src/PVE/API2/Storage/Status.pm | 50 +++++++++++++++++++++++++++++++++-
>   1 file changed, 49 insertions(+), 1 deletion(-)
> 
> diff --git a/src/PVE/API2/Storage/Status.pm b/src/PVE/API2/Storage/Status.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);
>   
>   use PVE::API2::Storage::Content;
>   use PVE::API2::Storage::FileRestore;
> @@ -308,6 +308,7 @@ __PACKAGE__->register_method({
>               { subdir => 'download-url' },
>               { subdir => 'file-restore' },
>               { subdir => 'import-metadata' },
> +            { subdir => 'instance-id' },
>               { subdir => 'oci-registry-pull' },
>               { subdir => 'prunebackups' },
>               { subdir => 'rrd' },
> @@ -1118,4 +1119,51 @@ __PACKAGE__->register_method({
>       },
>   });
>   
> +__PACKAGE__->register_method({
> +    name => 'instance_id',
> +    path => '{storage}/instance-id',
> +    method => 'GET',
> +    description => "Return unique storage instance ID (PBS only)",
> +    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 => {
> +            'instance-id' => {
> +                type => 'string',
> +                description => 'Unique instance ID',
> +            },
> +        },
> +    },
> +    code => sub {
> +        my ($param) = @_;
> +
> +        my $rpcenv = PVE::RPCEnvironment::get();
> +        my $user = $rpcenv->get_user();
> +
> +        my $storeid = extract_param($param, 'storage');
> +
> +        my $cfg = PVE::Storage::config();
> +        my $scfg = PVE::Storage::storage_config($cfg, $storeid);
> +
> +        raise_param_exc({ 'storage' => "Only PBS storages supported." })
> +            if $scfg->{type} ne 'pbs';
> +
> +        my $client = PVE::PBSClient->new($scfg, $storeid);
> +        my $ret = $client->get_instance_id();

nit: same as on previous patches, the client part should be called 
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 
as generic as possible for better future extensibility.

> +
> +        return $ret;
> +    },
> +});
> +
>   1;





  parent reply	other threads:[~2026-04-14 14:38 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-13 12:10 [RFC common/proxmox{,-backup}/storage 0/7] establish unique instance-id for PBS nodes Lukas Wagner
2026-04-13 12:10 ` [PATCH proxmox 1/7] pbs-api-types: add InstanceId response type Lukas Wagner
2026-04-13 12:10 ` [PATCH proxmox 2/7] systemd: add support for machine-id generation Lukas Wagner
2026-04-13 12:10 ` [PATCH proxmox-backup 3/7] api: add /nodes/localhost/instance-id Lukas Wagner
2026-04-14 14:23   ` Christian Ebner
2026-04-15  9:21     ` Lukas Wagner
2026-04-15  9:26       ` Christian Ebner
2026-04-13 12:10 ` [PATCH proxmox-backup 4/7] client: add 'instance-id' sub-command Lukas Wagner
2026-04-13 13:26   ` Shannon Sterz
2026-04-13 13:39     ` Lukas Wagner
2026-04-14 14:30   ` Christian Ebner
2026-04-13 12:10 ` [PATCH proxmox-backup 5/7] manager: add instance-id subcommand Lukas Wagner
2026-04-13 13:26   ` Shannon Sterz
2026-04-13 13:38     ` Lukas Wagner
2026-04-13 12:10 ` [PATCH common 6/7] pbs-client: add support for the 'instance id' command Lukas Wagner
2026-04-13 12:10 ` [PATCH pve-storage 7/7] api: add /nodes/<node>/storage/<storage>/instance-id route Lukas Wagner
2026-04-13 13:26   ` Shannon Sterz
2026-04-13 13:37     ` Lukas Wagner
2026-04-14 14:38   ` Christian Ebner [this message]
2026-04-15  8:41     ` Lukas Wagner
2026-04-15  8:44       ` Christian Ebner
2026-04-14 14:45 ` [RFC common/proxmox{,-backup}/storage 0/7] establish unique instance-id for PBS nodes Christian Ebner

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=9a4d051a-58a5-445f-a127-c11706d93194@proxmox.com \
    --to=c.ebner@proxmox.com \
    --cc=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 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.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal