82 lines
2.2 KiB
Rust
82 lines
2.2 KiB
Rust
use crate::{
|
|
data::Version,
|
|
interpret::{Interpret, InterpretError, InterpretName, InterpretStatus, Outcome},
|
|
inventory::Inventory,
|
|
score::Score,
|
|
topology::HAClusterTopology,
|
|
};
|
|
use async_trait::async_trait;
|
|
use derive_new::new;
|
|
use harmony_types::id::Id;
|
|
use log::info;
|
|
use serde::Serialize;
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
// Step 05: Sanity Check
|
|
// - Validate API reachability, ClusterOperators, ingress, and SDN status.
|
|
// -------------------------------------------------------------------------------------------------
|
|
|
|
#[derive(Debug, Clone, Serialize, new)]
|
|
pub struct OKDSetup05SanityCheckScore {}
|
|
|
|
impl Score<HAClusterTopology> for OKDSetup05SanityCheckScore {
|
|
fn create_interpret(&self) -> Box<dyn Interpret<HAClusterTopology>> {
|
|
Box::new(OKDSetup05SanityCheckInterpret::new(self.clone()))
|
|
}
|
|
|
|
fn name(&self) -> String {
|
|
"OKDSetup05SanityCheckScore".to_string()
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct OKDSetup05SanityCheckInterpret {
|
|
score: OKDSetup05SanityCheckScore,
|
|
version: Version,
|
|
status: InterpretStatus,
|
|
}
|
|
|
|
impl OKDSetup05SanityCheckInterpret {
|
|
pub fn new(score: OKDSetup05SanityCheckScore) -> Self {
|
|
let version = Version::from("1.0.0").unwrap();
|
|
Self {
|
|
version,
|
|
score,
|
|
status: InterpretStatus::QUEUED,
|
|
}
|
|
}
|
|
|
|
async fn run_checks(&self) -> Result<(), InterpretError> {
|
|
info!("[Sanity] Checking API, COs, Ingress, and SDN health …");
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
#[async_trait]
|
|
impl Interpret<HAClusterTopology> for OKDSetup05SanityCheckInterpret {
|
|
fn get_name(&self) -> InterpretName {
|
|
InterpretName::Custom("OKDSetup05SanityCheck")
|
|
}
|
|
|
|
fn get_version(&self) -> Version {
|
|
self.version.clone()
|
|
}
|
|
|
|
fn get_status(&self) -> InterpretStatus {
|
|
self.status.clone()
|
|
}
|
|
|
|
fn get_children(&self) -> Vec<Id> {
|
|
vec![]
|
|
}
|
|
|
|
async fn execute(
|
|
&self,
|
|
_inventory: &Inventory,
|
|
_topology: &HAClusterTopology,
|
|
) -> Result<Outcome, InterpretError> {
|
|
self.run_checks().await?;
|
|
Ok(Outcome::success("Sanity checks passed".into()))
|
|
}
|
|
}
|