From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id EB7961FF141 for ; Mon, 13 Apr 2026 15:39:05 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 160662774C; Mon, 13 Apr 2026 15:39:54 +0200 (CEST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 13 Apr 2026 15:39:18 +0200 Message-Id: Subject: Re: [PATCH proxmox-backup 4/7] client: add 'instance-id' sub-command From: "Lukas Wagner" To: "Shannon Sterz" , "Lukas Wagner" , , X-Mailer: aerc 0.21.0-0-g5549850facc2-dirty References: <20260413121057.371772-1-l.wagner@proxmox.com> <20260413121057.371772-5-l.wagner@proxmox.com> In-Reply-To: X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1776087484646 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.055 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 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: WHO56GGP3MA3E3CPMR73K7TOPU5F7TKA X-Message-ID-Hash: WHO56GGP3MA3E3CPMR73K7TOPU5F7TKA 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: On Mon Apr 13, 2026 at 3:26 PM CEST, Shannon Sterz wrote: > On Mon Apr 13, 2026 at 2:10 PM CEST, Lukas Wagner wrote: >> This allows users to query the instance-id from the >> proxmox-backup-client tool. This will also be used by the PBS client in >> PVE to lookup the instance-id from a yet to be introduced API endpoint >> that returns the instance-id for a given PBS storage. >> >> Signed-off-by: Lukas Wagner >> --- >> proxmox-backup-client/src/main.rs | 41 +++++++++++++++++++++++++++++-- >> 1 file changed, 39 insertions(+), 2 deletions(-) >> >> diff --git a/proxmox-backup-client/src/main.rs b/proxmox-backup-client/s= rc/main.rs >> index 2ada87bdd..9f4a82e26 100644 >> --- a/proxmox-backup-client/src/main.rs >> +++ b/proxmox-backup-client/src/main.rs >> @@ -25,8 +25,8 @@ use pxar::accessor::{MaybeReady, ReadAt, ReadAtOperati= on}; >> >> use pbs_api_types::{ >> ArchiveType, Authid, BackupArchiveName, BackupDir, BackupGroup, Bac= kupNamespace, BackupPart, >> - BackupType, ClientRateLimitConfig, CryptMode, Fingerprint, GroupLis= tItem, PathPattern, >> - PruneJobOptions, PruneListItem, RateLimitConfig, SnapshotListItem, = StorageStatus, >> + BackupType, ClientRateLimitConfig, CryptMode, Fingerprint, GroupLis= tItem, InstanceId, >> + PathPattern, PruneJobOptions, PruneListItem, RateLimitConfig, Snaps= hotListItem, StorageStatus, >> BACKUP_ID_SCHEMA, BACKUP_NAMESPACE_SCHEMA, BACKUP_TIME_SCHEMA, BACK= UP_TYPE_SCHEMA, >> CATALOG_NAME, ENCRYPTED_KEY_BLOB_NAME, MANIFEST_BLOB_NAME, >> }; >> @@ -139,6 +139,39 @@ fn record_repository(repo: &BackupRepository) { >> ); >> } >> >> +#[api( >> + input: { >> + properties: { >> + repository: { >> + schema: REPO_URL_SCHEMA, >> + optional: true, >> + }, >> + "output-format": { >> + schema: OUTPUT_FORMAT, >> + optional: true, >> + }, >> + }, >> + }, >> +)] >> +/// Start garbage collection for a specific repository. > > nit: that description probably should read "Get the instance ID of a PBS > host." instead ^^ > absolutely, this was a copy-paste oversight, thanks! >> +async fn get_instance_id(param: Value) -> Result { >> + let repo =3D extract_repository_from_value(¶m)?; >> + let output_format =3D get_output_format(¶m); >> + let client =3D connect(&repo)?; >> + >> + let path =3D format!("api2/json/nodes/localhost/instance-id"); >> + let mut result =3D client.get(&path, None).await?; >> + >> + let id: InstanceId =3D serde_json::from_value(result["data"].take()= )?; >> + >> + if output_format =3D=3D "text" { >> + println!("instance-id: {}", id.instance_id); >> + } else { >> + format_and_print_result(&id, &output_format); >> + } >> + Ok(Value::Null) >> +} >> + >> async fn api_datastore_list_snapshots( >> client: &HttpClient, >> store: &str, >> @@ -2076,6 +2109,9 @@ fn main() { >> let version_cmd_def =3D >> CliCommand::new(&API_METHOD_API_VERSION).completion_cb("reposit= ory", complete_repository); >> >> + let instance_id_cmd_def =3D CliCommand::new(&API_METHOD_GET_INSTANC= E_ID) >> + .completion_cb("repository", complete_repository); >> + >> let change_owner_cmd_def =3D CliCommand::new(&API_METHOD_CHANGE_BAC= KUP_OWNER) >> .arg_param(&["group", "new-owner"]) >> .completion_cb("ns", complete_namespace) >> @@ -2086,6 +2122,7 @@ fn main() { >> let cmd_def =3D CliCommandMap::new() >> .insert("backup", backup_cmd_def) >> .insert("garbage-collect", garbage_collect_cmd_def) >> + .insert("instance-id", instance_id_cmd_def) >> .insert("list", list_cmd_def) >> .insert("login", login_cmd_def) >> .insert("logout", logout_cmd_def)