Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
/logs.d/**/*
/logs*.d/**/*
.env
/Cargo.lock
/tasks.d/**/*
/jobs.d/**/*
/results.d/**/*
/scripts.d/**/*
/inventories.d/**/*
/results*.d/**/*
/scripts*.d/**/*
/inventories*.d/**/*
/backup/**/*
/test_results/**/*
/jobs.yaml
/jobs*.yaml
/menage.sh

/resources
/*.tar.*
/*ipynb*
/batches/**
/.ssh_g5k.pub

# Added by cargo

Expand Down
13 changes: 10 additions & 3 deletions src/configs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,17 @@ fn build_hwpc_system(hwpc_events: &HwpcEvents) -> HwpcSystem {
}
}

fn build_hwpc_config(name: String, system: HwpcSystem) -> HwpcConfig {
fn build_hwpc_config(name: String, system: HwpcSystem, os_flavor: &str) -> HwpcConfig {
let cgroup_basepath;
if os_flavor == "ubuntu2404-nfs" {
cgroup_basepath = "/sys/fs/cgroup";
} else {
cgroup_basepath = "/sys/fs/cgroup/perf_event";
}
HwpcConfig {
name,
verbose: true,
cgroup_basepath: "/sys/fs/cgroup/perf_event".to_owned(),
cgroup_basepath: cgroup_basepath.to_owned(),
frequency: 1000,
output: HwpcOutput {
r#type: "csv".to_owned(),
Expand All @@ -138,13 +144,14 @@ pub fn generate_hwpc_configs(
hwpc_events: &HwpcEvents,
core_values: &[u32],
prefix: &str,
os_flavor: &str,
) -> HashMap<u32, HwpcConfig> {
let hwpc_system = build_hwpc_system(hwpc_events);
core_values
.iter()
.map(|&core_value| {
let name = format!("{}_sensor_{}", prefix, core_value);
(core_value, build_hwpc_config(name, hwpc_system.clone()))
(core_value, build_hwpc_config(name, hwpc_system.clone(), os_flavor))
})
.collect()
}
Expand Down
37 changes: 35 additions & 2 deletions src/inventories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ pub async fn get_api_call(
let username = env::var("G5K_USERNAME").expect("G5K_USERNAME must be set");
let password = env::var("G5K_PASSWORD").expect("G5K_PASSWORD must be set");

debug!("Scraping {}", endpoint);
debug!("GET request to {}", endpoint);

let response = client
.get(endpoint)
Expand All @@ -211,6 +211,39 @@ pub async fn get_api_call(
}
}

pub async fn post_api_call(
client: &Client,
endpoint: &str,
data: &serde_json::Value
) -> Result<HashMap<String, serde_json::Value>, InventoryError> {
dotenv::dotenv().ok();
let username = env::var("G5K_USERNAME").expect("G5K_USERNAME must be set");
let password = env::var("G5K_PASSWORD").expect("G5K_PASSWORD must be set");

debug!("POST request to {}", endpoint);
debug!("with data {:?}", data);

let response = client
.post(endpoint)
.json(&data)
.basic_auth(username, Some(password))
.send()
.await;
let response_json = match response {
Ok(response_body) => {
response_body
.json()
.await
},
Err(e) => Err(e)
};

match response_json {
Ok(json) => Ok(json),
Err(e) => Err(InventoryError::HttpRequest(e)),
}
}

pub async fn generate_inventory(inventories_dir: &str) -> Result<(), InventoryError> {
dotenv::dotenv().ok(); // Charger les variables d'environnement
//
Expand Down Expand Up @@ -245,8 +278,8 @@ pub async fn generate_inventory(inventories_dir: &str) -> Result<(), InventoryEr
.await
.unwrap();
for node in nodes.iter_mut() {
node.cluster = Some(cluster.uid.clone().to_string());
if node.is_to_be_deployed() {
node.cluster = Some(cluster.uid.clone().to_string());
let node_specs_file_path = format!("{}/{}.json", cluster_dir, &node.uid);

if !Path::new(&node_specs_file_path).exists() {
Expand Down
Loading
Loading