WIP: Create Upgradeable trait
This commit is contained in:
parent
c4f4a58dcf
commit
1eaae2016a
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -1343,6 +1343,7 @@ dependencies = [
|
||||
"cidr",
|
||||
"env_logger",
|
||||
"harmony",
|
||||
"harmony_cli",
|
||||
"harmony_macros",
|
||||
"harmony_tui",
|
||||
"harmony_types",
|
||||
|
||||
@ -16,3 +16,4 @@ harmony_macros = { path = "../../harmony_macros" }
|
||||
log = { workspace = true }
|
||||
env_logger = { workspace = true }
|
||||
url = { workspace = true }
|
||||
harmony_cli = { version = "0.1.0", path = "../../harmony_cli" }
|
||||
|
||||
@ -13,7 +13,7 @@ use harmony::{
|
||||
dummy::{ErrorScore, PanicScore, SuccessScore},
|
||||
http::StaticFilesHttpScore,
|
||||
okd::{dhcp::OKDDhcpScore, dns::OKDDnsScore, load_balancer::OKDLoadBalancerScore},
|
||||
opnsense::OPNsenseShellCommandScore,
|
||||
opnsense::{OPNSenseLaunchUpgrade, OPNsenseShellCommandScore},
|
||||
tftp::TftpScore,
|
||||
},
|
||||
topology::{LogicalHost, UnmanagedRouter, Url},
|
||||
@ -97,9 +97,12 @@ async fn main() {
|
||||
opnsense: opnsense.get_opnsense_config(),
|
||||
command: "touch /tmp/helloharmonytouching".to_string(),
|
||||
}),
|
||||
Box::new(OPNSenseLaunchUpgrade {
|
||||
opnsense: opnsense.get_opnsense_config(),
|
||||
}),
|
||||
Box::new(SuccessScore {}),
|
||||
Box::new(ErrorScore {}),
|
||||
Box::new(PanicScore {}),
|
||||
]);
|
||||
harmony_tui::init(maestro).await.unwrap();
|
||||
harmony_cli::init(maestro, None).await.unwrap();
|
||||
}
|
||||
|
||||
@ -1,11 +1,14 @@
|
||||
use async_trait::async_trait;
|
||||
use harmony_macros::ip;
|
||||
use harmony_types::net::MacAddress;
|
||||
use log::error;
|
||||
use log::info;
|
||||
|
||||
use crate::executors::ExecutorError;
|
||||
use crate::interpret::InterpretError;
|
||||
use crate::interpret::Outcome;
|
||||
use crate::inventory::Inventory;
|
||||
use crate::topology::upgradeable::Upgradeable;
|
||||
|
||||
use super::DHCPStaticEntry;
|
||||
use super::DhcpServer;
|
||||
@ -49,9 +52,10 @@ impl Topology for HAClusterTopology {
|
||||
"HAClusterTopology"
|
||||
}
|
||||
async fn ensure_ready(&self) -> Result<Outcome, InterpretError> {
|
||||
todo!(
|
||||
error!(
|
||||
"ensure_ready, not entirely sure what it should do here, probably something like verify that the hosts are reachable and all services are up and ready."
|
||||
)
|
||||
);
|
||||
Ok(Outcome::success("for now do nothing".to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
@ -417,3 +421,10 @@ impl DnsServer for DummyInfra {
|
||||
unimplemented!("{}", UNIMPLEMENTED_DUMMY_INFRA)
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl<T: Topology> Upgradeable<T> for HAClusterTopology {
|
||||
async fn upgrade(&self, inventory: &Inventory, topology: &T) -> Result<(), InterpretError> {
|
||||
todo!("implement upgrades for all parts of the cluster")
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ mod k8s_anywhere;
|
||||
mod localhost;
|
||||
pub mod oberservability;
|
||||
pub mod tenant;
|
||||
pub mod upgradeable;
|
||||
pub use k8s_anywhere::*;
|
||||
pub use localhost::*;
|
||||
pub mod k8s;
|
||||
|
||||
8
harmony/src/domain/topology/upgradeable.rs
Normal file
8
harmony/src/domain/topology/upgradeable.rs
Normal file
@ -0,0 +1,8 @@
|
||||
use async_trait::async_trait;
|
||||
|
||||
use crate::{interpret::InterpretError, inventory::Inventory};
|
||||
|
||||
#[async_trait]
|
||||
pub trait Upgradeable<T>: Send + Sync {
|
||||
async fn upgrade(&self, inventory: &Inventory, topology: &T) -> Result<(), InterpretError>;
|
||||
}
|
||||
@ -7,13 +7,18 @@ mod management;
|
||||
mod tftp;
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
pub use management::*;
|
||||
use opnsense_config_xml::Host;
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
use crate::{
|
||||
executors::ExecutorError,
|
||||
topology::{IpAddress, LogicalHost},
|
||||
interpret::InterpretError,
|
||||
inventory::Inventory,
|
||||
modules::opnsense::OPNSenseLaunchUpgrade,
|
||||
score::Score,
|
||||
topology::{IpAddress, LogicalHost, Topology, upgradeable::Upgradeable},
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@ -49,3 +54,17 @@ impl OPNSenseFirewall {
|
||||
.map_err(|e| ExecutorError::UnexpectedError(e.to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl<T: Topology> Upgradeable<T> for OPNSenseFirewall {
|
||||
async fn upgrade(&self, inventory: &Inventory, topology: &T) -> Result<(), InterpretError> {
|
||||
OPNSenseLaunchUpgrade {
|
||||
opnsense: self.get_opnsense_config(),
|
||||
}
|
||||
.create_interpret()
|
||||
.execute(inventory, topology)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user