diff --git a/Cargo.toml b/Cargo.toml index 61510c1..972abbf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,11 +20,11 @@ publish = false # cargo [dependencies] # backend-dispatcher = { path = "../backend-dispatcher" } # Only for development purposes -backend-dispatcher = "0.1.7" +backend-dispatcher = "0.1.8" # mesa = { path = "../mesa" } # Only for development purposes -mesa = "0.42.3-beta.7" +mesa = "0.42.3-beta.8" # ochami-rs = { path = "../ochami-rs" } # Only for development purposes -ochami-rs = "0.1.5" +ochami-rs = "0.1.6" hostlist-parser = "0.1.6" strum = "0.25.0" strum_macros = "0.25" diff --git a/src/cli/build.rs b/src/cli/build.rs index a318d14..dba9074 100644 --- a/src/cli/build.rs +++ b/src/cli/build.rs @@ -609,12 +609,19 @@ pub fn subcommand_add() -> Command { Command::new("add") .arg_required_else_help(true) .about("Add hw components to cluster") + .subcommand( + Command::new("node") + .visible_alias("n") + .about("Add/Create new group") + .arg_required_else_help(true) + .arg(arg!(-i --id "xname").required(true)) + ) .subcommand( Command::new("group") .visible_alias("g") .about("Add/Create new group") .arg_required_else_help(true) - .arg(arg!(-l --"label" "Group name").required(true)) + .arg(arg!(-l --label "Group name").required(true)) .arg(arg!(-x --xnames "Comma separated list of nodes to set in new group.\neg 'x1003c1s7b0n0,1003c1s7b0n1,x1003c1s7b1n0'")) ) .subcommand(Command::new("hw-component") diff --git a/src/cli/process.rs b/src/cli/process.rs index c66b83e..855e785 100644 --- a/src/cli/process.rs +++ b/src/cli/process.rs @@ -1,4 +1,7 @@ -use backend_dispatcher::contracts::BackendTrait; +use backend_dispatcher::{ + contracts::BackendTrait, + types::{ComponentArrayPostArray, ComponentCreate}, +}; use std::{io::IsTerminal, path::PathBuf}; use clap::ArgMatches; @@ -422,7 +425,35 @@ pub async fn process_cli( } } } else if let Some(cli_add) = cli_root.subcommand_matches("add") { - if let Some(cli_add_group) = cli_add.subcommand_matches("group") { + if let Some(cli_add_node) = cli_add.subcommand_matches("node") { + let shasta_token = backend.get_api_token(&site_name).await?; + + let id = cli_add_node + .get_one::("id") + .expect("ERROR - 'id' argument is mandatory"); + + let component: ComponentCreate = ComponentCreate { + id: id.to_string(), + state: "Unknown".to_string(), + flag: None, + enabled: None, + software_status: None, + role: None, + sub_role: None, + nid: None, + subtype: None, + net_type: None, + arch: None, + class: None, + }; + + let components = ComponentArrayPostArray { + components: vec![component], + force: Some(true), + }; + + backend.post_nodes(shasta_token.as_str(), components).await; + } else if let Some(cli_add_group) = cli_add.subcommand_matches("group") { let shasta_token = backend.get_api_token(&site_name).await?; let label = cli_add_group