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 8B59E1FF137 for ; Tue, 14 Apr 2026 16:30:12 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D89E61BE2D; Tue, 14 Apr 2026 16:31:01 +0200 (CEST) Message-ID: Date: Tue, 14 Apr 2026 16:30:27 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH proxmox-backup 4/7] client: add 'instance-id' sub-command To: Lukas Wagner , pbs-devel@lists.proxmox.com, pve-devel@lists.proxmox.com References: <20260413121057.371772-1-l.wagner@proxmox.com> <20260413121057.371772-5-l.wagner@proxmox.com> Content-Language: en-US, de-DE From: Christian Ebner In-Reply-To: <20260413121057.371772-5-l.wagner@proxmox.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1776176951795 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.069 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 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [main.rs] Message-ID-Hash: J33P5URWBJGM3LPTBNY4W742HGHPO4HP X-Message-ID-Hash: J33P5URWBJGM3LPTBNY4W742HGHPO4HP X-MailFrom: c.ebner@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 Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On 4/13/26 2:10 PM, Lukas Wagner wrote: > This allows users to query the instance-id from the comment: IMHO using `instance-id` also on the client side is misleading, maybe `pbs-instance-id`, `host-instance-id` or `server-insance-id`? It should however be clear that this is not an `instance-id` from the client itself or the host it is executed on. Below should be adapted accordingly. > 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/src/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, ReadAtOperation}; > > use pbs_api_types::{ > ArchiveType, Authid, BackupArchiveName, BackupDir, BackupGroup, BackupNamespace, BackupPart, > - BackupType, ClientRateLimitConfig, CryptMode, Fingerprint, GroupListItem, PathPattern, > - PruneJobOptions, PruneListItem, RateLimitConfig, SnapshotListItem, StorageStatus, > + BackupType, ClientRateLimitConfig, CryptMode, Fingerprint, GroupListItem, InstanceId, > + PathPattern, PruneJobOptions, PruneListItem, RateLimitConfig, SnapshotListItem, StorageStatus, > BACKUP_ID_SCHEMA, BACKUP_NAMESPACE_SCHEMA, BACKUP_TIME_SCHEMA, BACKUP_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. > +async fn get_instance_id(param: Value) -> Result { > + let repo = extract_repository_from_value(¶m)?; > + let output_format = get_output_format(¶m); > + let client = connect(&repo)?; > + > + let path = format!("api2/json/nodes/localhost/instance-id"); nit: can use the plain `str`, no need to instantiate a `String` here. > + let mut result = client.get(&path, None).await?; > + > + let id: InstanceId = serde_json::from_value(result["data"].take())?; > + > + if output_format == "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 = > CliCommand::new(&API_METHOD_API_VERSION).completion_cb("repository", complete_repository); > > + let instance_id_cmd_def = CliCommand::new(&API_METHOD_GET_INSTANCE_ID) > + .completion_cb("repository", complete_repository); > + > let change_owner_cmd_def = CliCommand::new(&API_METHOD_CHANGE_BACKUP_OWNER) > .arg_param(&["group", "new-owner"]) > .completion_cb("ns", complete_namespace) > @@ -2086,6 +2122,7 @@ fn main() { > let cmd_def = 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)