fix: autoload inventory and topology, update dhcp struct, add k8s deployment score

- Updated `Inventory` and `HAClusterTopology` to use `autoload` instead of `dummy`.
- Made fields in `DhcpScore` public for better access.
- Added `K8sDeploymentScore` to the list of modules registered with Maestro.
- Corrected logic in `Config::verify_package_installation` to check if package is installed.
- Updated `CaddyGeneral` struct to include `http_versions`.
This commit is contained in:
Jean-Gabriel Gill-Couture 2025-02-06 16:24:22 -05:00
parent 0b30d82793
commit 31e92a08a4
7 changed files with 19 additions and 16 deletions

View File

@ -1,15 +1,16 @@
use harmony::{
inventory::Inventory,
maestro::Maestro,
modules::dummy::{ErrorScore, PanicScore, SuccessScore},
modules::{dummy::{ErrorScore, PanicScore, SuccessScore}, k8s::deployment::K8sDeploymentScore},
topology::HAClusterTopology,
};
#[tokio::main]
async fn main() {
let inventory = Inventory::empty_inventory();
let topology = HAClusterTopology::dummy();
let inventory = Inventory::autoload();
let topology = HAClusterTopology::autoload();
let mut maestro = Maestro::new(inventory, topology);
maestro.register_all(vec![
Box::new(SuccessScore {}),
Box::new(ErrorScore {}),

View File

@ -34,7 +34,7 @@ pub struct Inventory {
}
impl Inventory {
pub fn empty_inventory() -> Self {
pub fn autoload() -> Self {
Self {
location: Location::test_building(),
switch: SwitchGroup::new(),

View File

@ -43,7 +43,7 @@ impl HAClusterTopology {
Ok(Arc::new(OpenshiftClient::try_default().await?))
}
pub fn dummy() -> Self {
pub fn autoload() -> Self {
let dummy_infra = Arc::new(DummyInfra {});
let dummy_host = LogicalHost {
ip: ip!("0.0.0.0"),

View File

@ -15,9 +15,9 @@ use crate::domain::score::Score;
#[derive(Debug, new, Clone)]
pub struct DhcpScore {
host_binding: Vec<HostBinding>,
next_server: Option<IpAddress>,
boot_filename: Option<String>,
pub host_binding: Vec<HostBinding>,
pub next_server: Option<IpAddress>,
pub boot_filename: Option<String>,
}
impl Score for DhcpScore {

View File

@ -27,13 +27,13 @@ impl OKDDhcpScore {
})
.collect();
Self {
dhcp_score: DhcpScore::new(
// TODO : we should add a tftp server to the topology instead of relying on the
// router address, this is leaking implementation details
dhcp_score: DhcpScore {
host_binding,
// TODO : we should add a tftp server to the topology instead of relying on the
// router address, this is leaking implementation details
Some(topology.router.get_gateway()),
Some("bootx64.efi".to_string()),
),
next_server: Some(topology.router.get_gateway()),
boot_filename: Some("bootx64.efi".to_string()),
},
}
}
}

View File

@ -49,7 +49,9 @@ pub struct CaddyGeneral {
#[yaserde(rename = "GracePeriod")]
pub grace_period: Option<u16>,
#[yaserde(rename = "HttpVersion")]
pub http_version: MaybeString,
pub http_version: Option<MaybeString>,
#[yaserde(rename = "HttpVersions")]
pub http_versions: Option<MaybeString>,
#[yaserde(rename = "LogCredentials")]
pub log_credentials: MaybeString,
#[yaserde(rename = "LogAccessPlain")]

View File

@ -105,7 +105,7 @@ impl Config {
let is_installed = self.is_package_installed(package_name);
debug!("Verifying package installed successfully {is_installed}");
if !is_installed {
if is_installed {
info!("Installation successful for {package_name}");
Ok(())
} else {