Skip to content

Commit

Permalink
feat: add support for HSM components
Browse files Browse the repository at this point in the history
  • Loading branch information
Masber committed Jan 10, 2025
1 parent c94949b commit 69ba8e4
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 8 additions & 1 deletion src/cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <VALUE> "xname").required(true))
)
.subcommand(
Command::new("group")
.visible_alias("g")
.about("Add/Create new group")
.arg_required_else_help(true)
.arg(arg!(-l --"label" <VALUE> "Group name").required(true))
.arg(arg!(-l --label <VALUE> "Group name").required(true))
.arg(arg!(-x --xnames <XNAMES> "Comma separated list of nodes to set in new group.\neg 'x1003c1s7b0n0,1003c1s7b0n1,x1003c1s7b1n0'"))
)
.subcommand(Command::new("hw-component")
Expand Down
35 changes: 33 additions & 2 deletions src/cli/process.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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::<String>("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
Expand Down

0 comments on commit 69ba8e4

Please sign in to comment.