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:
parent
0b30d82793
commit
31e92a08a4
@ -1,15 +1,16 @@
|
|||||||
use harmony::{
|
use harmony::{
|
||||||
inventory::Inventory,
|
inventory::Inventory,
|
||||||
maestro::Maestro,
|
maestro::Maestro,
|
||||||
modules::dummy::{ErrorScore, PanicScore, SuccessScore},
|
modules::{dummy::{ErrorScore, PanicScore, SuccessScore}, k8s::deployment::K8sDeploymentScore},
|
||||||
topology::HAClusterTopology,
|
topology::HAClusterTopology,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
let inventory = Inventory::empty_inventory();
|
let inventory = Inventory::autoload();
|
||||||
let topology = HAClusterTopology::dummy();
|
let topology = HAClusterTopology::autoload();
|
||||||
let mut maestro = Maestro::new(inventory, topology);
|
let mut maestro = Maestro::new(inventory, topology);
|
||||||
|
|
||||||
maestro.register_all(vec![
|
maestro.register_all(vec![
|
||||||
Box::new(SuccessScore {}),
|
Box::new(SuccessScore {}),
|
||||||
Box::new(ErrorScore {}),
|
Box::new(ErrorScore {}),
|
||||||
|
@ -34,7 +34,7 @@ pub struct Inventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Inventory {
|
impl Inventory {
|
||||||
pub fn empty_inventory() -> Self {
|
pub fn autoload() -> Self {
|
||||||
Self {
|
Self {
|
||||||
location: Location::test_building(),
|
location: Location::test_building(),
|
||||||
switch: SwitchGroup::new(),
|
switch: SwitchGroup::new(),
|
||||||
|
@ -43,7 +43,7 @@ impl HAClusterTopology {
|
|||||||
Ok(Arc::new(OpenshiftClient::try_default().await?))
|
Ok(Arc::new(OpenshiftClient::try_default().await?))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dummy() -> Self {
|
pub fn autoload() -> Self {
|
||||||
let dummy_infra = Arc::new(DummyInfra {});
|
let dummy_infra = Arc::new(DummyInfra {});
|
||||||
let dummy_host = LogicalHost {
|
let dummy_host = LogicalHost {
|
||||||
ip: ip!("0.0.0.0"),
|
ip: ip!("0.0.0.0"),
|
||||||
|
@ -15,9 +15,9 @@ use crate::domain::score::Score;
|
|||||||
|
|
||||||
#[derive(Debug, new, Clone)]
|
#[derive(Debug, new, Clone)]
|
||||||
pub struct DhcpScore {
|
pub struct DhcpScore {
|
||||||
host_binding: Vec<HostBinding>,
|
pub host_binding: Vec<HostBinding>,
|
||||||
next_server: Option<IpAddress>,
|
pub next_server: Option<IpAddress>,
|
||||||
boot_filename: Option<String>,
|
pub boot_filename: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Score for DhcpScore {
|
impl Score for DhcpScore {
|
||||||
|
@ -27,13 +27,13 @@ impl OKDDhcpScore {
|
|||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
Self {
|
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,
|
host_binding,
|
||||||
// TODO : we should add a tftp server to the topology instead of relying on the
|
next_server: Some(topology.router.get_gateway()),
|
||||||
// router address, this is leaking implementation details
|
boot_filename: Some("bootx64.efi".to_string()),
|
||||||
Some(topology.router.get_gateway()),
|
},
|
||||||
Some("bootx64.efi".to_string()),
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,9 @@ pub struct CaddyGeneral {
|
|||||||
#[yaserde(rename = "GracePeriod")]
|
#[yaserde(rename = "GracePeriod")]
|
||||||
pub grace_period: Option<u16>,
|
pub grace_period: Option<u16>,
|
||||||
#[yaserde(rename = "HttpVersion")]
|
#[yaserde(rename = "HttpVersion")]
|
||||||
pub http_version: MaybeString,
|
pub http_version: Option<MaybeString>,
|
||||||
|
#[yaserde(rename = "HttpVersions")]
|
||||||
|
pub http_versions: Option<MaybeString>,
|
||||||
#[yaserde(rename = "LogCredentials")]
|
#[yaserde(rename = "LogCredentials")]
|
||||||
pub log_credentials: MaybeString,
|
pub log_credentials: MaybeString,
|
||||||
#[yaserde(rename = "LogAccessPlain")]
|
#[yaserde(rename = "LogAccessPlain")]
|
||||||
|
@ -105,7 +105,7 @@ impl Config {
|
|||||||
let is_installed = self.is_package_installed(package_name);
|
let is_installed = self.is_package_installed(package_name);
|
||||||
debug!("Verifying package installed successfully {is_installed}");
|
debug!("Verifying package installed successfully {is_installed}");
|
||||||
|
|
||||||
if !is_installed {
|
if is_installed {
|
||||||
info!("Installation successful for {package_name}");
|
info!("Installation successful for {package_name}");
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user