From 680902e45017a6dd3197bb95224a736128c5cca9 Mon Sep 17 00:00:00 2001 From: Jean-Gabriel Gill-Couture Date: Wed, 3 Sep 2025 13:07:00 -0400 Subject: [PATCH] fix: Use ssh key from FileContent in OKDIpxe score instead of hardcoded path --- examples/nanodc/src/main.rs | 6 +++--- examples/okd_installation/src/main.rs | 16 ++++++++++------ examples/okd_pxe/src/main.rs | 6 +++--- harmony/src/modules/okd/ipxe.rs | 18 ++++++++++-------- 4 files changed, 26 insertions(+), 20 deletions(-) diff --git a/examples/nanodc/src/main.rs b/examples/nanodc/src/main.rs index 993a8fe..5b04bf3 100644 --- a/examples/nanodc/src/main.rs +++ b/examples/nanodc/src/main.rs @@ -13,7 +13,7 @@ use harmony::{ okd::{ bootstrap_dhcp::OKDBootstrapDhcpScore, bootstrap_load_balancer::OKDBootstrapLoadBalancerScore, dhcp::OKDDhcpScore, - dns::OKDDnsScore, ipxe::OkdIpxeScore, + dns::OKDDnsScore, ipxe::OKDIpxeScore, }, tftp::TftpScore, }, @@ -136,10 +136,10 @@ async fn main() { let cluster_pubkey_filename = "cluster_ssh_key.pub".to_string(); let harmony_inventory_agent = "harmony_inventory_agent".to_string(); - let ipxe_score = OkdIpxeScore { + let ipxe_score = OKDIpxeScore { kickstart_filename, harmony_inventory_agent, - cluster_pubkey_filename, + cluster_pubkey, }; harmony_tui::run( diff --git a/examples/okd_installation/src/main.rs b/examples/okd_installation/src/main.rs index 0d99c15..04bf853 100644 --- a/examples/okd_installation/src/main.rs +++ b/examples/okd_installation/src/main.rs @@ -2,21 +2,25 @@ mod topology; use crate::topology::{get_inventory, get_topology}; use harmony::{ - modules::okd::{installation::OKDInstallationScore, ipxe::OkdIpxeScore}, - score::Score, - topology::HAClusterTopology, + config::secret::SshKeyPair, data::{FileContent, FilePath}, modules::okd::{installation::OKDInstallationScore, ipxe::OKDIpxeScore}, score::Score, topology::HAClusterTopology }; +use harmony_secret::SecretManager; #[tokio::main] async fn main() { let inventory = get_inventory(); let topology = get_topology().await; + let ssh_key = SecretManager::get_or_prompt::().await.unwrap(); + let scores: Vec>> = vec![ - Box::new(OkdIpxeScore { + Box::new(OKDIpxeScore { kickstart_filename: "inventory.kickstart".to_string(), - harmony_inventory_agent: "cluster_ssh_key.pub".to_string(), - cluster_pubkey_filename: "harmony_inventory_agent".to_string(), + harmony_inventory_agent: "harmony_inventory_agent".to_string(), + cluster_pubkey: FileContent { + path: FilePath::Relative("cluster_ssh_key.pub".to_string()), + content: ssh_key.public, + }, }), Box::new(OKDInstallationScore {}), ]; diff --git a/examples/okd_pxe/src/main.rs b/examples/okd_pxe/src/main.rs index 42e4729..97e6f74 100644 --- a/examples/okd_pxe/src/main.rs +++ b/examples/okd_pxe/src/main.rs @@ -1,7 +1,7 @@ mod topology; use crate::topology::{get_inventory, get_topology}; -use harmony::modules::okd::ipxe::OkdIpxeScore; +use harmony::modules::okd::ipxe::OKDIpxeScore; #[tokio::main] async fn main() { @@ -12,10 +12,10 @@ async fn main() { let cluster_pubkey_filename = "cluster_ssh_key.pub".to_string(); let harmony_inventory_agent = "harmony_inventory_agent".to_string(); - let ipxe_score = OkdIpxeScore { + let ipxe_score = OKDIpxeScore { kickstart_filename, harmony_inventory_agent, - cluster_pubkey_filename, + cluster_pubkey, }; harmony_cli::run(inventory, topology, vec![Box::new(ipxe_score)], None) diff --git a/harmony/src/modules/okd/ipxe.rs b/harmony/src/modules/okd/ipxe.rs index 743efab..a4dcd18 100644 --- a/harmony/src/modules/okd/ipxe.rs +++ b/harmony/src/modules/okd/ipxe.rs @@ -16,15 +16,15 @@ use crate::{ use harmony_types::id::Id; #[derive(Debug, new, Clone, Serialize)] -pub struct OkdIpxeScore { +pub struct OKDIpxeScore { pub kickstart_filename: String, pub harmony_inventory_agent: String, - pub cluster_pubkey_filename: String, + pub cluster_pubkey: FileContent, } -impl Score for OkdIpxeScore { +impl Score for OKDIpxeScore { fn create_interpret(&self) -> Box> { - Box::new(IpxeInterpret::new(self.clone())) + Box::new(OKDIpxeInterpret::new(self.clone())) } fn name(&self) -> String { @@ -33,12 +33,12 @@ impl Score for O } #[derive(Debug, new, Clone)] -pub struct IpxeInterpret { - score: OkdIpxeScore, +pub struct OKDIpxeInterpret { + score: OKDIpxeScore, } #[async_trait] -impl Interpret for IpxeInterpret { +impl Interpret for OKDIpxeInterpret { async fn execute( &self, inventory: &Inventory, @@ -81,6 +81,7 @@ impl Interpret f folder_to_serve: None, // folder_to_serve: Some(Url::LocalFolder("./data/pxe/okd/http_files/".to_string())), files: vec![ + FileContent { path: FilePath::Relative("boot.ipxe".to_string()), content: BootIpxeTpl { @@ -93,7 +94,7 @@ impl Interpret f content: InventoryKickstartTpl { gateway_ip: &gateway_ip, harmony_inventory_agent: &self.score.harmony_inventory_agent, - cluster_pubkey_filename: &self.score.cluster_pubkey_filename, + cluster_pubkey_filename: &self.score.cluster_pubkey.path.to_string(), } .to_string(), }, @@ -105,6 +106,7 @@ impl Interpret f } .to_string(), }, + self.score.cluster_pubkey.clone(), ], }), ];