diff --git a/Cargo.lock b/Cargo.lock index 6ac2599..d825f9c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -859,13 +859,6 @@ dependencies = [ "url", ] -[[package]] -name = "example-topology" -version = "0.1.0" -dependencies = [ - "rand", -] - [[package]] name = "example-tui" version = "0.1.0" diff --git a/examples/nanodc/src/main.rs b/examples/nanodc/src/main.rs index 3a683d0..66a5de5 100644 --- a/examples/nanodc/src/main.rs +++ b/examples/nanodc/src/main.rs @@ -12,6 +12,12 @@ async fn main() { let mut maestro = Maestro::new(inventory, topology); maestro.register_all(vec![ + // ADD scores : + // 1. OPNSense setup scores + // 2. Bootstrap node setup + // 3. Control plane setup + // 4. Workers setup + // 5. Various tools and apps setup Box::new(SuccessScore {}), Box::new(ErrorScore {}), Box::new(PanicScore {}), diff --git a/examples/opnsense/src/main.rs b/examples/opnsense/src/main.rs index 6315390..ddf781d 100644 --- a/examples/opnsense/src/main.rs +++ b/examples/opnsense/src/main.rs @@ -12,7 +12,7 @@ use harmony::{ modules::{ dummy::{ErrorScore, PanicScore, SuccessScore}, http::HttpScore, - okd::{dhcp::OKDDhcpScore, dns::OKDDnsScore}, + okd::{dhcp::OKDDhcpScore, dns::OKDDnsScore, load_balancer::OKDLoadBalancerScore}, opnsense::OPNsenseShellCommandScore, tftp::TftpScore, }, @@ -78,8 +78,7 @@ async fn main() { let dhcp_score = OKDDhcpScore::new(&topology, &inventory); let dns_score = OKDDnsScore::new(&topology); - let load_balancer_score = - harmony::modules::okd::load_balancer::OKDLoadBalancerScore::new(&topology); + let load_balancer_score = OKDLoadBalancerScore::new(&topology); let tftp_score = TftpScore::new(Url::LocalFolder("./data/watchguard/tftpboot".to_string())); let http_score = HttpScore::new(Url::LocalFolder( diff --git a/harmony/src/domain/score.rs b/harmony/src/domain/score.rs index 6e4eed4..f1b9378 100644 --- a/harmony/src/domain/score.rs +++ b/harmony/src/domain/score.rs @@ -19,3 +19,5 @@ where Box::new(self.clone()) } } + +pub trait FrontendScore: Score + std::fmt::Display {} diff --git a/harmony/src/domain/topology/ha_cluster.rs b/harmony/src/domain/topology/ha_cluster.rs index 0e9230b..b6c1c9a 100644 --- a/harmony/src/domain/topology/ha_cluster.rs +++ b/harmony/src/domain/topology/ha_cluster.rs @@ -334,6 +334,7 @@ impl TftpServer for DummyInfra { #[async_trait] impl HttpServer for DummyInfra { async fn serve_files(&self, _url: &Url) -> Result<(), ExecutorError> { + unimplemented!("{}", UNIMPLEMENTED_DUMMY_INFRA) } fn get_ip(&self) -> IpAddress { diff --git a/harmony/src/modules/load_balancer.rs b/harmony/src/modules/load_balancer.rs index f590fa1..91ff16b 100644 --- a/harmony/src/modules/load_balancer.rs +++ b/harmony/src/modules/load_balancer.rs @@ -5,7 +5,7 @@ use crate::{ data::{Id, Version}, interpret::{Interpret, InterpretError, InterpretName, InterpretStatus, Outcome}, inventory::Inventory, - score::Score, + score::{FrontendScore, Score}, topology::{LoadBalancer, LoadBalancerService, Topology}, }; @@ -19,6 +19,8 @@ pub struct LoadBalancerScore { // uuid? } +impl FrontendScore for LoadBalancerScore {} + impl Score for LoadBalancerScore { fn create_interpret(&self) -> Box> { Box::new(LoadBalancerInterpret::new(self.clone())) diff --git a/harmony/src/modules/okd/load_balancer.rs b/harmony/src/modules/okd/load_balancer.rs index c3b5264..47185e1 100644 --- a/harmony/src/modules/okd/load_balancer.rs +++ b/harmony/src/modules/okd/load_balancer.rs @@ -3,12 +3,20 @@ use std::net::SocketAddr; use crate::{ interpret::Interpret, modules::load_balancer::LoadBalancerScore, - score::Score, + score::{FrontendScore, Score}, topology::{ BackendServer, HAClusterTopology, HealthCheck, HttpMethod, HttpStatusCode, LoadBalancer, LoadBalancerService, Topology }, }; +impl std::fmt::Display for OKDLoadBalancerScore { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + todo!() + } +} + +impl FrontendScore for OKDLoadBalancerScore {} + #[derive(Debug, Clone)] pub struct OKDLoadBalancerScore { load_balancer_score: LoadBalancerScore, diff --git a/harmony_tui/src/widget/score.rs b/harmony_tui/src/widget/score.rs index 514ab79..ea62249 100644 --- a/harmony_tui/src/widget/score.rs +++ b/harmony_tui/src/widget/score.rs @@ -1,7 +1,7 @@ use std::sync::{Arc, RwLock}; use crossterm::event::{Event, KeyCode, KeyEventKind}; -use harmony::{score::Score, topology::Topology}; +use harmony::{modules::okd::load_balancer::OKDLoadBalancerScore, score::Score, topology::{LoadBalancer, Topology}}; use log::{info, warn}; use ratatui::{ layout::Rect, style::{Style, Stylize}, widgets::{List, ListItem, ListState, StatefulWidget, Widget}, Frame @@ -23,10 +23,12 @@ struct Execution { score: Box>, } +impl FrontendScore for OKDLoadBalancerScore {} + #[derive(Debug)] pub(crate) struct ScoreListWidget { list_state: Arc>, - scores: Vec>>, + scores: Vec>>, execution: Option>, execution_history: Vec>, sender: mpsc::Sender>,