Some checks failed
Run Check Script / check (pull_request) Failing after 36s
51 lines
1.6 KiB
Rust
51 lines
1.6 KiB
Rust
mod topology;
|
|
|
|
use harmony::{
|
|
data::{FileContent, FilePath},
|
|
modules::{dhcp::DhcpScore, http::StaticFilesHttpScore, tftp::TftpScore},
|
|
score::Score,
|
|
topology::{HAClusterTopology, Url},
|
|
};
|
|
|
|
use crate::topology::{get_inventory, get_topology};
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
let inventory = get_inventory();
|
|
let topology = get_topology().await;
|
|
let gateway_ip = topology.router.get_gateway();
|
|
|
|
// TODO this should be a single IPXEScore instead of having the user do this step by step
|
|
let scores: Vec<Box<dyn Score<HAClusterTopology>>> = vec![
|
|
Box::new(DhcpScore {
|
|
host_binding: vec![],
|
|
next_server: Some(topology.router.get_gateway()),
|
|
boot_filename: None,
|
|
filename: Some("undionly.kpxe".to_string()),
|
|
filename64: Some("ipxe.efi".to_string()),
|
|
filenameipxe: Some(format!("http://{gateway_ip}:8080/boot.ipxe").to_string()),
|
|
}),
|
|
Box::new(TftpScore {
|
|
files_to_serve: Url::LocalFolder("./data/pxe/okd/tftpboot/".to_string()),
|
|
}),
|
|
Box::new(StaticFilesHttpScore {
|
|
folder_to_serve: None,
|
|
files: vec![FileContent {
|
|
path: FilePath::Relative("boot.ipxe".to_string()),
|
|
content: format!(
|
|
"#!ipxe
|
|
|
|
set base-url http://{gateway_ip}:8080
|
|
set hostfile ${{base-url}}/byMAC/01-${{mac:hexhyp}}.ipxe
|
|
|
|
chain ${{hostfile}} || chain ${{base-url}}/default.ipxe"
|
|
),
|
|
}],
|
|
}),
|
|
];
|
|
|
|
harmony_cli::run(inventory, topology, scores, None)
|
|
.await
|
|
.unwrap();
|
|
}
|