Skip to content

Commit 490f921

Browse files
authored
Merge pull request #14 from powerapi-ng/enable-inventory-skip
Add command-line arguments capability with skip_inventory option
2 parents d0cf136 + 1db749e commit 490f921

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ flate2 = { version = "1.0.34", features = ["zlib"] }
2727
tar = "0.4.43"
2828
bytes = "1.8.0"
2929
subprocess = "0.2.9"
30+
clap = { version = "4.5.21", features = ["derive"] }

src/main.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ mod ssh;
77

88
use crate::jobs::Jobs;
99
use chrono::Local;
10+
use clap::Parser;
1011
use derive_more::Display;
1112
use env_logger::Builder;
1213
use inventories::StrOrFloat;
@@ -28,7 +29,16 @@ const JOBS_FILE: &str = "jobs.yaml";
2829
const SCRIPTS_DIRECTORY: &str = "scripts.d";
2930
const RESULTS_DIRECTORY: &str = "results.d";
3031
const CONFIG_FILE: &str = "config/events_by_vendor.json";
31-
//
32+
33+
#[derive(Parser, Debug)]
34+
#[command(version, about = "Benchmark tool for PowerAPI Framework")]
35+
struct BenchmarkArgs {
36+
/// Skip the scrapping against Grid5000 API refreshing node configurations
37+
#[arg(short, long)]
38+
skip_inventory: bool,
39+
}
40+
41+
3242
type BenchmarkResult = Result<(), BenchmarkError>;
3343
#[derive(Error, Debug)]
3444
pub enum BenchmarkError {
@@ -209,19 +219,24 @@ fn load_or_init_jobs() -> Result<Jobs, BenchmarkError> {
209219

210220
#[tokio::main]
211221
async fn main() -> Result<(), BenchmarkError> {
222+
let benchmark_args = BenchmarkArgs::parse();
223+
212224
dotenv::dotenv().ok();
213225
let log_level = env::var("LOG_LEVEL").unwrap_or_else(|_| "debug".to_string());
214226
build_logger(&log_level).unwrap();
215227
info!("Starting Benchmarks!");
216228
debug!("LOG_LEVEL is : {:?}", &log_level);
217229

230+
231+
218232
init_directories()?;
219233

220234
let events_by_vendor = load_events_config()?;
221235
let mut jobs: Jobs = load_or_init_jobs()?;
222-
223-
inventories::generate_inventory(INVENTORIES_DIRECTORY).await?;
224-
236+
237+
if ! benchmark_args.skip_inventory {
238+
inventories::generate_inventory(INVENTORIES_DIRECTORY).await?;
239+
}
225240
// If we loaded existing jobs, check their status
226241
if jobs.jobs.len() != 0 {
227242
let client = reqwest::Client::builder().build()?;

0 commit comments

Comments
 (0)