From 278732fcc58719f38389c8da6053289148931b03 Mon Sep 17 00:00:00 2001 From: Manuel Sopena Ballesteros Date: Fri, 12 Jul 2024 17:10:17 +0200 Subject: [PATCH] fix: move deprecated messages in command get nodes to log when output is json --- Cargo.toml | 2 +- src/cli/build.rs | 4 ++-- .../commands/get_hw_configuration_cluster.rs | 2 +- src/cli/process.rs | 23 ++++++++----------- 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 43d2825..a37b58a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ publish = false # cargo # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -mesa = "0.38.0" +mesa = "0.38.1" # mesa = { path = "../mesa" } # Only for development purposes strum = "0.25.0" strum_macros = "0.25" diff --git a/src/cli/build.rs b/src/cli/build.rs index 8e28892..e20d690 100644 --- a/src/cli/build.rs +++ b/src/cli/build.rs @@ -356,7 +356,7 @@ pub fn subcommand_get_cluster_details(hsm_group: Option<&String>) -> Command { .arg(arg!(-n --"nids-only-one-line" "Prints nids in one line eg nidxxxxxx,nidyyyyyy,nidzzzzzz,...")) .arg(arg!(-x --"xnames-only-one-line" "Prints xnames in one line eg x1001c1s5b0n0,x1001c1s5b0n1,...")) .arg(arg!(-s --"status" "Get cluster status:\n - OK: All nodes are operational (booted and configured)\n - OFF: At least one node is OFF\n - ON: No nodes OFF and at least one is ON\n - STANDBY: At least one node's heartbeat is lost\n - UNCONFIGURED: All nodes are READY but at least one of them is being configured\n - FAILED: At least one node configuration failed")) - .arg(arg!(-o --output "Output format. If missing it will print output data in human redeable (tabular) format").value_parser(["json", "summary"])); + .arg(arg!(-o --output "Output format. If missing it will print output data in human readable (tabular) format").value_parser(["table", "json", "summary"]).default_value("table")); match hsm_group { None => { @@ -376,7 +376,7 @@ pub fn subcommand_get_node(hsm_group: Option<&String>) -> Command { .about("DEPRECATED - Please use 'manta get cluster' command instead.\nGet members of a HSM group") .arg(arg!(-n --"nids-only-one-line" "Prints nids in one line eg nidxxxxxx,nidyyyyyy,nidzzzzzz,...")) .arg(arg!(-x --"xnames-only-one-line" "Prints xnames in one line eg x1001c1s5b0n0,x1001c1s5b0n1,...")) - .arg(arg!(-o --output "Output format. If missing it will print output data in human redeable (tabular) format").value_parser(["json"])); + .arg(arg!(-o --output "Output format. If missing it will print output data in human readable (tabular) format").value_parser(["table", "json", "summary"]).default_value("table")); match hsm_group { None => { diff --git a/src/cli/commands/get_hw_configuration_cluster.rs b/src/cli/commands/get_hw_configuration_cluster.rs index cdef3cc..70e6f4f 100644 --- a/src/cli/commands/get_hw_configuration_cluster.rs +++ b/src/cli/commands/get_hw_configuration_cluster.rs @@ -54,7 +54,7 @@ pub async fn exec( // Get HW inventory details for target HSM group for (i, hsm_member) in hsm_group_target_members.iter().enumerate() { - print!( + log::info!( "\rGetting hw components for node '{hsm_member}' [{i:>width$}/{num_hsm_group_members}]" ); io::stdout().flush().unwrap(); diff --git a/src/cli/process.rs b/src/cli/process.rs index 02c9f11..78b24cd 100644 --- a/src/cli/process.rs +++ b/src/cli/process.rs @@ -822,9 +822,6 @@ pub async fn process_cli( ) .await; } else if let Some(cli_get_node) = cli_get.subcommand_matches("nodes") { - println!("Deprecated - Please use 'manta get cluster' command instead."); - log::warn!("Deprecated - Please use 'manta get cluster' command instead."); - let hsm_group_name_arg_opt = cli_get_node.get_one::("HSM_GROUP_NAME"); let target_hsm_group_vec = get_target_hsm_group_vec_or_all( @@ -836,6 +833,14 @@ pub async fn process_cli( ) .await; + let output_opt = cli_get_node.get_one::("output"); + + if output_opt.is_some_and(|output| output == "table" || output == "summary") { + println!("Deprecated - Please use 'manta get cluster' command instead."); + } else { + log::warn!("Deprecated - Please use 'manta get cluster' command instead."); + } + get_nodes::exec( shasta_token, shasta_base_url, @@ -847,12 +852,11 @@ pub async fn process_cli( *cli_get_node .get_one::("xnames-only-one-line") .unwrap_or(&false), - cli_get_node.get_one::("output"), + output_opt, false, ) .await; } else if let Some(cli_get_hsm_groups) = cli_get.subcommand_matches("hsm-groups") { - println!("Deprecated - Do not use this command."); log::warn!("Deprecated - Do not use this command."); let hsm_group_name_arg_opt = cli_get_hsm_groups.get_one::("HSM_GROUP_NAME"); @@ -968,7 +972,6 @@ pub async fn process_cli( } else if let Some(cli_apply_configuration) = cli_apply.subcommand_matches("configuration") { - println!("Deprecated - Please use 'manta apply sat-file' command instead."); log::warn!("Deprecated - Please use 'manta apply sat-file' command instead."); get_target_hsm_group_vec_or_all( @@ -1080,7 +1083,6 @@ pub async fn process_cli( ) .await; } else if let Some(cli_apply_image) = cli_apply.subcommand_matches("image") { - println!("Deprecated - Please use 'manta apply sat-file' command instead."); log::warn!("Deprecated - Please use 'manta apply sat-file' command instead."); get_target_hsm_group_vec_or_all( @@ -1148,7 +1150,6 @@ pub async fn process_cli( ) .await; } else if let Some(cli_apply_cluster) = cli_apply.subcommand_matches("cluster") { - println!("Deprecated - Please use 'manta apply sat-file' command instead."); log::warn!("Deprecated - Please use 'manta apply sat-file' command instead."); let target_hsm_group_vec = get_target_hsm_group_vec_or_all( @@ -1294,7 +1295,6 @@ pub async fn process_cli( .await; } else if let Some(cli_apply_node) = cli_apply.subcommand_matches("node") { if let Some(cli_apply_node_on) = cli_apply_node.subcommand_matches("on") { - println!("Deprecated - Please use 'manta power on' command instead."); log::warn!("Deprecated - Please use 'manta power on' command instead."); /* apply_node_on::exec( @@ -1336,7 +1336,6 @@ pub async fn process_cli( ) .await; } else if let Some(cli_apply_node_off) = cli_apply_node.subcommand_matches("off") { - println!("Deprecated - Please use 'manta power off' command instead."); log::warn!("Deprecated - Please use 'manta power off' command instead."); /* apply_node_off::exec( @@ -1382,7 +1381,6 @@ pub async fn process_cli( } else if let Some(cli_apply_node_reset) = cli_apply_node.subcommand_matches("reset") { - println!("Deprecated - Please use 'manta power reset' command instead."); log::warn!("Deprecated - Please use 'manta power reset' command instead."); /* apply_node_reset::exec( @@ -1450,7 +1448,6 @@ pub async fn process_cli( .await; } else if let Some(cli_apply_boot) = cli_apply.subcommand_matches("boot") { if let Some(cli_apply_boot_nodes) = cli_apply_boot.subcommand_matches("nodes") { - println!("Deprecated - Please use 'manta power' command instead."); log::warn!("Deprecated - Please use 'manta power' command instead."); let hsm_group_name_arg_opt = @@ -1512,7 +1509,6 @@ pub async fn process_cli( } } else if let Some(cli_update) = cli_root.subcommand_matches("update") { if let Some(cli_update_node) = cli_update.subcommand_matches("nodes") { - println!("Deprecated - Please use 'manta apply boot nodes' command instead."); log::warn!("Deprecated - Please use 'manta apply boot nodes' command instead."); let hsm_group_name_arg_opt = cli_update_node.get_one::("HSM_GROUP_NAME"); @@ -1545,7 +1541,6 @@ pub async fn process_cli( ) .await; } else if let Some(cli_update_hsm_group) = cli_update.subcommand_matches("hsm-group") { - println!("Deprecated - Please use 'manta apply boot cluster' command instead."); log::warn!("Deprecated - Please use 'manta apply boot cluster' command instead."); let hsm_group_name_arg_opt =