chore: Some cleanup in harmony repo

This commit is contained in:
jeangab 2024-12-03 10:43:50 -05:00
parent 58a4e7882b
commit 3592b176e5
3 changed files with 44 additions and 38 deletions

View File

@ -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;

View File

@ -2,3 +2,8 @@ mod domain;
pub use domain::*;
pub mod infra;
pub mod modules;
#[cfg(test)]
mod test {
use crate::infra::opnsense::OPNSenseFirewall;
}

View File

@ -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<HostBinding>,
@ -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 {