diff --git a/harmony-rs/harmony/src/infra/opnsense/mod.rs b/harmony-rs/harmony/src/infra/opnsense/mod.rs index 66b00e6..deca92a 100644 --- a/harmony-rs/harmony/src/infra/opnsense/mod.rs +++ b/harmony-rs/harmony/src/infra/opnsense/mod.rs @@ -1,5 +1,5 @@ mod management; -use std::sync::{Arc, Mutex, RwLock, RwLockWriteGuard}; +use std::sync::{Arc, RwLock }; use async_trait::async_trait; use log::debug; diff --git a/harmony-rs/harmony/src/lib.rs b/harmony-rs/harmony/src/lib.rs index be55110..3c2dff0 100644 --- a/harmony-rs/harmony/src/lib.rs +++ b/harmony-rs/harmony/src/lib.rs @@ -2,3 +2,8 @@ mod domain; pub use domain::*; pub mod infra; pub mod modules; + +#[cfg(test)] +mod test { + use crate::infra::opnsense::OPNSenseFirewall; +} diff --git a/harmony-rs/harmony/src/modules/dhcp.rs b/harmony-rs/harmony/src/modules/dhcp.rs index 37e49cb..c569354 100644 --- a/harmony-rs/harmony/src/modules/dhcp.rs +++ b/harmony-rs/harmony/src/modules/dhcp.rs @@ -16,42 +16,43 @@ use crate::{ use crate::domain::score::Score; -/// OPNSenseDhcpScore will set static DHCP entries using index based hostname -/// and ip addresses. -/// -/// For example : -/// ```rust -/// -/// let node1 = todo!(); // Node pointing to clustermember controlplane0 with ip 10.10.0.20 and host with mac 01 -/// let node2 = todo!(); // Node pointing to clustermember controlplane1 with ip 10.10.0.21 and host with mac 02 -/// let node3 = todo!(); // Node pointing to clustermember controlplane2 with ip 10.10.0.22 and host with mac 03 -/// -/// let score = OPNSenseDhcpScore { -/// nodes: vec![node1, node2, node3], -/// } -/// ``` -/// -/// Running such a score would create these static entries : -/// -/// ```rust -/// let entries = vec![ -/// DHCPEntry { -/// mac: 01, -/// ip: 10.10.0.20, -/// hostname: "controlplane0" -/// } -/// DHCPEntry { -/// mac: 02, -/// ip: 10.10.0.21, -/// hostname: "controlplane0" -/// } -/// DHCPEntry { -/// mac: 03, -/// ip: 10.10.0.22, -/// hostname: "controlplane2" -/// } -/// ] -/// ``` +/** +OPNSenseDhcpScore will set static DHCP entries using index based hostname +and ip addresses. + +For example : +```rust +let node1 = todo!(); // Node pointing to clustermember controlplane0 with ip 10.10.0.20 and host with mac 01 +let node2 = todo!(); // Node pointing to clustermember controlplane1 with ip 10.10.0.21 and host with mac 02 +let node3 = todo!(); // Node pointing to clustermember controlplane2 with ip 10.10.0.22 and host with mac 03 + +let score = OPNSenseDhcpScore { + nodes: vec![node1, node2, node3], +} +``` + +Running such a score would create these static entries : + +```rust +let entries = vec![ + DHCPEntry { + mac: 01, + ip: 10.10.0.20, + hostname: "controlplane0" + } + DHCPEntry { + mac: 02, + ip: 10.10.0.21, + hostname: "controlplane0" + } + DHCPEntry { + mac: 03, + ip: 10.10.0.22, + hostname: "controlplane2" + } +] +``` +*/ #[derive(Debug, new, Clone)] pub struct DhcpScore { host_binding: Vec, @@ -78,7 +79,7 @@ pub struct DhcpInterpret { impl DhcpInterpret { pub fn new(score: DhcpScore) -> Self { let version = Version::from("1.0.0").expect("Version should be valid"); - let name = "OPNSenseDhcpScore".to_string(); + let name = "DhcpInterpret".to_string(); let id = Id::from_string(format!("{name}_{version}")); Self {