From: Lukas Wagner <l.wagner@proxmox.com>
To: pbs-devel@lists.proxmox.com, pve-devel@lists.proxmox.com
Subject: [PATCH proxmox-backup 3/7] api: add /nodes/localhost/server-identity
Date: Wed, 15 Apr 2026 13:58:13 +0200 [thread overview]
Message-ID: <20260415115817.348947-4-l.wagner@proxmox.com> (raw)
In-Reply-To: <20260415115817.348947-1-l.wagner@proxmox.com>
This one returns a unique ID that can be used to uniquely identify a PBS
node. This will be used by PDM to match PBS storages in a PVE cluster to
PBS remotes in PDM, mainly for associating backup jobs with the
appropriate PBS remote. Later we can also use this to match PBS sync
jobs to their matching PBS remotes in PDM.
The instance ID is derived from /etc/machine-id as recommended by
systemd [1] by using proxmox_systemd::sd_id128::get_app_specific_id.
[1] https://www.freedesktop.org/software/systemd/man/latest/sd_id128_get_machine_app_specific.html
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
src/api2/node/mod.rs | 40 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 39 insertions(+), 1 deletion(-)
diff --git a/src/api2/node/mod.rs b/src/api2/node/mod.rs
index 42e1dbaa2..4695cb301 100644
--- a/src/api2/node/mod.rs
+++ b/src/api2/node/mod.rs
@@ -25,7 +25,7 @@ use proxmox_schema::*;
use proxmox_sortable_macro::sortable;
use proxmox_sys::fd::fd_change_cloexec;
-use pbs_api_types::{NodeShellTicket, NODE_SCHEMA, PRIV_SYS_CONSOLE};
+use pbs_api_types::{NodeShellTicket, ServerIdentity, NODE_SCHEMA, PRIV_SYS_CONSOLE};
use tracing::{info, warn};
use crate::auth::{private_auth_keyring, public_auth_keyring};
@@ -291,6 +291,40 @@ fn list_nodes() -> Result<Value, Error> {
Ok(json!([ { "node": proxmox_sys::nodename().to_string() } ]))
}
+/// Static key used for deriving a unique instance id from `/etc/machine-id` using
+/// [`proxmox_systemd::sd_id128::get_app_specific_id`].
+///
+/// This key was generated by `systemd-id128 new`.
+///
+const INSTANCE_ID_KEY: [u8; 16] = 0xe5415d9999c146399b8bdae1260e19d2_u128.to_le_bytes();
+
+#[api(
+ input: {
+ properties: {
+ node: {
+ schema: NODE_SCHEMA,
+ optional: true,
+ },
+ }
+ },
+ returns: {
+ type: ServerIdentity,
+ },
+ access: {
+ permission: &Permission::Anybody,
+ }
+)]
+/// Returns a unique server identity. The ID is derived from `/etc/machine-id`.
+pub fn get_server_identity() -> Result<ServerIdentity, Error> {
+ let machine_id_derived_app_id =
+ proxmox_systemd::sd_id128::get_app_specific_id(INSTANCE_ID_KEY)?;
+ let machine_id_derived_app_id = hex::encode(machine_id_derived_app_id);
+
+ Ok(ServerIdentity {
+ pbs_instance_id: machine_id_derived_app_id,
+ })
+}
+
pub const SUBDIRS: SubdirMap = &[
("apt", &apt::ROUTER),
("certificates", &certificates::ROUTER),
@@ -301,6 +335,10 @@ pub const SUBDIRS: SubdirMap = &[
("network", &network::ROUTER),
("report", &report::ROUTER),
("rrd", &rrd::ROUTER),
+ (
+ "server-identity",
+ &Router::new().get(&API_METHOD_GET_SERVER_IDENTITY),
+ ),
("services", &services::ROUTER),
("status", &status::ROUTER),
("subscription", &subscription::ROUTER),
--
2.47.3
next prev parent reply other threads:[~2026-04-15 11:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-15 11:58 [PATCH common/proxmox{,-backup}/storage 0/7] establish unique instance-id for PBS nodes Lukas Wagner
2026-04-15 11:58 ` [PATCH proxmox 1/7] pbs-api-types: add ServerIdentity response type Lukas Wagner
2026-04-15 11:58 ` [PATCH proxmox 2/7] systemd: add support for machine-id generation Lukas Wagner
2026-04-15 11:58 ` Lukas Wagner [this message]
2026-04-15 11:58 ` [PATCH proxmox-backup 4/7] client: add 'server-identity' sub-command Lukas Wagner
2026-04-15 11:58 ` [PATCH proxmox-backup 5/7] manager: add 'server-identity' subcommand Lukas Wagner
2026-04-15 11:58 ` [PATCH common 6/7] pbs-client: add support for the 'server-identity' command Lukas Wagner
2026-04-15 11:58 ` [PATCH pve-storage 7/7] api: add /nodes/<node>/storage/<storage>/identity route Lukas Wagner
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=20260415115817.348947-4-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