forked from NationTech/harmony
feat: automatically discover inventory (#127)
## Fully automated inventory gathering now works! Boot up harmony_inventory_agent with `cargo run -p harmony_inventory_agent` Launch the DiscoverInventoryAgentScore , currently available this way : `RUST_LOG=info cargo run -p example-cli -- -f Discover -y` And you will have automatically all hosts saved to the database. Run `cargo sqlx setup` if you have not done it yet. Co-authored-by: Ian Letourneau <ian@noma.to> Reviewed-on: NationTech/harmony#127 Co-authored-by: Jean-Gabriel Gill-Couture <jg@nationtech.io> Co-committed-by: Jean-Gabriel Gill-Couture <jg@nationtech.io>
This commit is contained in:
15
harmony_inventory_agent/src/client.rs
Normal file
15
harmony_inventory_agent/src/client.rs
Normal file
@@ -0,0 +1,15 @@
|
||||
use crate::hwinfo::PhysicalHost;
|
||||
|
||||
pub async fn get_host_inventory(host: &str, port: u16) -> Result<PhysicalHost, String> {
|
||||
let url = format!("http://{host}:{port}/inventory");
|
||||
let client = reqwest::Client::new();
|
||||
let response = client
|
||||
.get(url)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| format!("Failed to download file: {e}"))?;
|
||||
|
||||
let host = response.json().await.map_err(|e| e.to_string())?;
|
||||
|
||||
Ok(host)
|
||||
}
|
||||
Reference in New Issue
Block a user