try out ipmi and redfish rust crates

This commit is contained in:
Jean-Gabriel Gill-Couture 2024-08-30 11:44:25 -04:00
parent 7d69ac447a
commit 1881428a63
5 changed files with 1480 additions and 0 deletions

1
harmony-rs/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
target

1434
harmony-rs/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

9
harmony-rs/Cargo.toml Normal file
View File

@ -0,0 +1,9 @@
[package]
name = "harmony-rs"
version = "0.1.0"
edition = "2021"
[dependencies]
libredfish = "0.1.1"
reqwest = {version = "0.11", features = ["blocking", "json"] }
rust-ipmi = "0.1.1"

20
harmony-rs/src/main.rs Normal file
View File

@ -0,0 +1,20 @@
use libredfish::{Config, Redfish};
use reqwest::blocking::Client;
pub fn main() {
let client = Client::builder().danger_accept_invalid_certs(true).build().expect("Failed to build reqwest client");
let redfish = Redfish::new(
client,
Config {
user: Some(String::from("Administrator")),
endpoint: String::from("10.10.8.104/redfish/v1"),
// password: Some(String::from("YOUR_PASSWORD")),
password: Some(String::from("wrongpass")),
port: None,
},
);
let response = redfish.get_power_status().expect("Failed redfish request");
println!("Got power {:?}", response);
}

View File

@ -0,0 +1,16 @@
use rust_ipmi::{IPMIClient, NetFn};
fn main() {
let connection_string = "192.168.11.132:443";
println!("Hello, world! {}", connection_string);
let mut client: IPMIClient = IPMIClient::new(connection_string).expect("Failed to create ipmi client");
client.establish_connection("root", "YOUR_PASSWORD")
.expect("Failed to establish connection with the BMC");
let response = client.send_raw_request(NetFn::App, 0x3b, Some(vec![0x04]));
match response {
Ok(response) => println!("{}", response),
Err(err) => println!("Got error {:?}", err),
}
}