From ac3c83c2a7aa75dee8213261e1ccd002da8bd372 Mon Sep 17 00:00:00 2001 From: Manuel Sopena Ballesteros Date: Tue, 30 Jul 2024 14:14:17 +0200 Subject: [PATCH] fix: update mesa version --- Cargo.toml | 2 +- src/cli/build.rs | 2 +- src/common/config_ops.rs | 45 ++++++++++++++++++++-------------------- src/main.rs | 2 +- 4 files changed, 25 insertions(+), 26 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 518ecdc2..97ec0c93 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.40.1" +mesa = "0.40.3" # 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 43c8a5f1..37e11d1d 100644 --- a/src/cli/build.rs +++ b/src/cli/build.rs @@ -433,7 +433,7 @@ pub fn subcommand_get_images(hsm_group: Option<&String>) -> Command { pub fn subcommand_get_kernel_parameters(hsm_group: Option<&String>) -> Command { let mut get_cfs_session = Command::new("kernel-parameters") - .alias("k") + .aliases(["k", "kp", "kernel-params"]) .about("Get kernel-parameters information") .arg(arg!(-n --xnames "List of xnames to retreive the kernel parameters from")) .arg(arg!(-f --filter "List of kernel parameter keys to filter. eg: console bad_page crashkernel hugepagelist root")); diff --git a/src/common/config_ops.rs b/src/common/config_ops.rs index 3a628c42..52b43b22 100644 --- a/src/common/config_ops.rs +++ b/src/common/config_ops.rs @@ -84,7 +84,7 @@ pub fn get_default_mgmt_plane_ca_cert_file_path() -> PathBuf { /// Get Manta configuration full path. Configuration may be the default one or specified by user. /// This function also validates if the config file is TOML format -pub fn get_config_file_path() -> config::File { +pub async fn get_config_file_path() -> config::File { // Get config file path from ENV var let config_file_path = if let Ok(env_config_file_name) = std::env::var("MANTA_CONFIG") { let mut env_config_file = std::path::PathBuf::new(); @@ -98,7 +98,7 @@ pub fn get_config_file_path() -> config::File { // Validate if config file exists if !config_file_path.exists() { // Configuration file does not exists --> create a new configuration file - create_new_config_file(Some(&config_file_path)); + create_new_config_file(Some(&config_file_path)).await; } // Validate config file and check format (toml) is correct @@ -114,9 +114,9 @@ pub fn get_config_file_path() -> config::File { /// Reads configuration parameters related to manta from environment variables or file. If both /// defiend, then environment variables takes preference -pub fn get_configuration() -> Config { +pub async fn get_configuration() -> Config { // Get config file path - let config_file = get_config_file_path(); + let config_file = get_config_file_path().await; // Process config file let config_rslt = ::config::Config::builder() @@ -141,7 +141,7 @@ pub fn get_configuration() -> Config { } } -pub fn create_new_config_file(config_file_path_opt: Option<&PathBuf>) { +pub async fn create_new_config_file(config_file_path_opt: Option<&PathBuf>) { eprintln!("Confguration file not found. Please introduce values below:"); /* let log: String = Input::new() .with_prompt("Please enter a value for param 'log'") @@ -153,7 +153,7 @@ pub fn create_new_config_file(config_file_path_opt: Option<&PathBuf>) { let log_level_values = vec!["error", "info", "warning", "debug", "trace"]; let log_selection = Select::new() - .with_prompt("Select 'log verbosity' level from the options below") + .with_prompt("Please select 'log verbosity' level from the list below") .items(&log_level_values) .default(0) .interact() @@ -169,7 +169,7 @@ pub fn create_new_config_file(config_file_path_opt: Option<&PathBuf>) { stdin().read_line(&mut parent_hsm_group).unwrap(); */ let audit_file: String = Input::new() - .with_prompt("Type full path for the audit file") + .with_prompt("Please type full path for the audit file") .default( get_default_manta_audit_file_path() .to_string_lossy() @@ -181,58 +181,49 @@ pub fn create_new_config_file(config_file_path_opt: Option<&PathBuf>) { .unwrap(); let site: String = Input::new() - .with_prompt("Type site name") + .with_prompt("Please type site name") .default("alps".to_string()) .show_default(true) .interact_text() .unwrap(); - // TODO: test if client has network access from this machine to endpoints, if not, then ask to - // enter socks5 proxy value, otherwise leave it empty - let socks5_proxy: String = Input::new() - .with_prompt("Type socks5 proxy URL") - .with_initial_text("socks5h://127.0.0.1:1080".to_string()) - .allow_empty(true) - .interact_text() - .unwrap(); - let shasta_base_url: String = Input::new() - .with_prompt("Type site management plane URL") + .with_prompt("Please type site management plane URL") .default("https://api.cmn.alps.cscs.ch".to_string()) .show_default(true) .interact_text() .unwrap(); let k8s_api_url: String = Input::new() - .with_prompt("Type kubernetes api URL") + .with_prompt("Please type kubernetes api URL") .default("https://10.252.1.12:6442".to_string()) .show_default(true) .interact_text() .unwrap(); let vault_base_url: String = Input::new() - .with_prompt("Type Hashicorp Vault URL") + .with_prompt("Please type Hashicorp Vault URL") .default("https://hashicorp-vault.cscs.ch:8200".to_string()) .show_default(true) .interact_text() .unwrap(); let vault_secret_path: String = Input::new() - .with_prompt("Type Hashicorp Vault secret path") + .with_prompt("Please type Hashicorp Vault secret path") .default("shasta".to_string()) .show_default(true) .interact_text() .unwrap(); let vault_role_id: String = Input::new() - .with_prompt("Type Hashicorp Vault role id") + .with_prompt("Please type Hashicorp Vault role id") .default("b15517de-cabb-06ba-af98-633d216c6d99".to_string()) .show_default(true) .interact_text() .unwrap(); let root_ca_cert_file: String = Input::new() - .with_prompt("Type full path for the CA public certificate file") + .with_prompt("Please type full path for the CA public certificate file") .default( get_default_mgmt_plane_ca_cert_file_path() .to_string_lossy() @@ -242,6 +233,14 @@ pub fn create_new_config_file(config_file_path_opt: Option<&PathBuf>) { .interact_text() .unwrap(); + // Get the right socks5 proxy value based on if client can reach backend api or not + let socks5_proxy = Input::new() + .with_prompt("Note: If CSM backend API is not reacheable, then you may need a SOCKS5 proxy.\nPlease type socks5 proxy URL") + .with_initial_text("socks5h://127.0.0.1:1080".to_string()) + .allow_empty(true) + .interact_text() + .unwrap(); + let site_details = Site { socks5_proxy, shasta_base_url, diff --git a/src/main.rs b/src/main.rs index c973078e..efedd3de 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,7 +15,7 @@ async fn main() -> core::result::Result<(), Box> { // #[cfg(feature = "dhat-heap")] // let _profiler = dhat::Profiler::new_heap(); - let settings = common::config_ops::get_configuration(); + let settings = common::config_ops::get_configuration().await; let site_name = settings.get_string("site").unwrap(); let site_detail_hashmap = settings.get_table("sites").unwrap();