[pdm-devel] [PATCH datacenter-manager 2/2] cli/admin: add a versions command to show current package versions
Shannon Sterz
s.sterz at proxmox.com
Fri Sep 5 11:59:06 CEST 2025
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 <s.sterz at proxmox.com>
---
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<Value, anyhow::Error> {
+ 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
More information about the pdm-devel
mailing list