Files
harmony/examples/okd_add_node/src/main.rs
Sylvain Tremblay a906a51ef6 refactor(okd): rename AddOkdNodeScore to OKDAddNodeScore
Aligns with the rest of the OKD score namespace (OKDSetup01InventoryScore,
OKDBootstrap02…, OKDLoadBalancerScore, …). The Add prefix made this one
the odd name out. Renames the companion interpret (AddOkdNodeInterpret →
OKDAddNodeInterpret), the Score::name() debug string, and the
InterpretName::Custom tag for symmetry. AddNodeRole stays as-is (not a
Score, and its prefix still reads fine).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-21 15:41:40 -04:00

52 lines
1.4 KiB
Rust

//! Runnable example for [`OKDAddNodeScore`].
//!
//! Source `env.sh` first (sets `HARMONY_DATABASE_URL` / `KUBECONFIG`), then:
//!
//! ```bash
//! cargo run -p okd_add_node
//! ```
//!
//! The score will:
//! 1. read existing nodes of the target role from the live cluster,
//! 2. log the auto-derived hostname + IP,
//! 3. wait for the operator to PXE-boot the new machine,
//! 4. walk them through disk / bond / blacklist selection,
//! 5. publish the ignition + per-MAC iPXE + DHCP reservation on the firewall,
//! 6. ask the operator to power-cycle.
mod topology;
use harmony::{
modules::{
inventory::HarmonyDiscoveryStrategy,
okd::add_node::{AddNodeRole, OKDAddNodeScore},
},
score::Score,
topology::HAClusterTopology,
};
use harmony_macros::cidrv4;
use crate::topology::{get_inventory, get_topology};
#[tokio::main]
async fn main() {
harmony_cli::cli_logger::init();
let inventory = get_inventory();
let topology = get_topology().await;
let add_node = OKDAddNodeScore {
role: AddNodeRole::ControlPlane,
discovery_strategy: HarmonyDiscoveryStrategy::SUBNET {
cidr: cidrv4!("192.168.40.0/24"),
port: 25000,
},
};
let scores: Vec<Box<dyn Score<HAClusterTopology>>> = vec![Box::new(add_node)];
harmony_cli::run(inventory, topology, scores, None)
.await
.unwrap();
}