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 A798B1FF15C for ; Fri, 5 Sep 2025 11:58:57 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D01731106D; Fri, 5 Sep 2025 11:59:12 +0200 (CEST) From: Shannon Sterz To: pdm-devel@lists.proxmox.com Date: Fri, 5 Sep 2025 11:59:06 +0200 Message-ID: <20250905095906.204396-4-s.sterz@proxmox.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250905095906.204396-1-s.sterz@proxmox.com> References: <20250905095906.204396-1-s.sterz@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1757066331807 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.024 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 Subject: [pdm-devel] [PATCH datacenter-manager 2/2] cli/admin: add a versions command to show current package versions X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Datacenter Manager development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" similar to other proxmox products this shows the currently running version as well as offering a verbose option that can show versions for other relevant packages as well. Signed-off-by: Shannon Sterz --- cli/admin/src/main.rs | 53 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/cli/admin/src/main.rs b/cli/admin/src/main.rs index 91b93f3..aa0897a 100644 --- a/cli/admin/src/main.rs +++ b/cli/admin/src/main.rs @@ -1,4 +1,11 @@ -use proxmox_router::cli::{run_cli_command, CliCommandMap, CliEnvironment}; +use serde_json::{json, Value}; + +use proxmox_router::cli::{ + default_table_format_options, format_and_print_result_full, get_output_format, run_cli_command, + CliCommand, CliCommandMap, CliEnvironment, ColumnConfig, OUTPUT_FORMAT, +}; + +use proxmox_schema::api; mod remotes; @@ -12,7 +19,9 @@ fn main() { server::context::init().expect("could not set up server context"); - let cmd_def = CliCommandMap::new().insert("remote", remotes::cli()); + let cmd_def = CliCommandMap::new() + .insert("remote", remotes::cli()) + .insert("versions", CliCommand::new(&API_METHOD_GET_VERSIONS)); let rpcenv = CliEnvironment::new(); run_cli_command( @@ -21,3 +30,43 @@ fn main() { Some(|future| proxmox_async::runtime::main(future)), ); } + +#[api( + input: { + properties: { + verbose: { + type: Boolean, + optional: true, + default: false, + description: "Output verbose package information. It is ignored if output-format is specified.", + }, + "output-format": { + schema: OUTPUT_FORMAT, + optional: true, + } + } + } +)] +/// List package versions for important Proxmox Datacenter Manager packages. +async fn get_versions(verbose: bool, param: Value) -> Result { + let output_format = get_output_format(¶m); + + let packages = server::api::nodes::apt::get_versions()?; + let mut packages = json!(if verbose { + &packages[..] + } else { + &packages[1..2] + }); + + let options = default_table_format_options() + .disable_sort() + .noborder(true) // just not helpful for version info which gets copy pasted often + .column(ColumnConfig::new("Package")) + .column(ColumnConfig::new("Version")) + .column(ColumnConfig::new("ExtraInfo").header("Extra Info")); + let return_type = &server::api::nodes::apt::API_METHOD_GET_VERSIONS.returns; + + format_and_print_result_full(&mut packages, return_type, &output_format, &options); + + Ok(Value::Null) +} -- 2.47.2 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel