From 042ff7e7dda31910202722af6f01e56a311b9c5b Mon Sep 17 00:00:00 2001 From: Jean-Gabriel Gill-Couture Date: Fri, 13 Sep 2024 16:19:49 -0400 Subject: [PATCH] chore: Move client setups to private repos that can be cloned manually by the developer --- harmony-rs/.gitignore | 1 + harmony-rs/Cargo.lock | 11 +++ harmony-rs/Cargo.toml | 2 +- harmony-rs/fqm/Cargo.toml | 12 --- harmony-rs/fqm/src/inventory/mod.rs | 82 ------------------- harmony-rs/fqm/src/lib.rs | 16 ---- harmony-rs/fqm/src/main.rs | 20 ----- harmony-rs/fqm/src/topology.rs | 25 ------ .../harmony/src/domain/executors/mod.rs | 4 +- harmony-rs/harmony/src/domain/hardware/mod.rs | 11 +++ harmony-rs/harmony/src/domain/topology/mod.rs | 1 - .../harmony/src/infra/executors/russh/mod.rs | 6 +- harmony-rs/harmony/src/infra/intel_amt/mod.rs | 17 ++++ harmony-rs/harmony/src/infra/mod.rs | 1 + .../harmony/src/modules/opnsense_dhcp.rs | 10 +-- 15 files changed, 51 insertions(+), 168 deletions(-) delete mode 100644 harmony-rs/fqm/Cargo.toml delete mode 100644 harmony-rs/fqm/src/inventory/mod.rs delete mode 100644 harmony-rs/fqm/src/lib.rs delete mode 100644 harmony-rs/fqm/src/main.rs delete mode 100644 harmony-rs/fqm/src/topology.rs create mode 100644 harmony-rs/harmony/src/infra/intel_amt/mod.rs diff --git a/harmony-rs/.gitignore b/harmony-rs/.gitignore index eb5a316..c607ca7 100644 --- a/harmony-rs/.gitignore +++ b/harmony-rs/.gitignore @@ -1 +1,2 @@ target +private_repos diff --git a/harmony-rs/Cargo.lock b/harmony-rs/Cargo.lock index 241c91c..a0a529d 100644 --- a/harmony-rs/Cargo.lock +++ b/harmony-rs/Cargo.lock @@ -58,6 +58,17 @@ dependencies = [ "subtle", ] +[[package]] +name = "affilium" +version = "0.1.0" +dependencies = [ + "cidr", + "env_logger", + "harmony", + "log", + "tokio", +] + [[package]] name = "aho-corasick" version = "1.1.3" diff --git a/harmony-rs/Cargo.toml b/harmony-rs/Cargo.toml index 44002db..9e5cc19 100644 --- a/harmony-rs/Cargo.toml +++ b/harmony-rs/Cargo.toml @@ -1,7 +1,7 @@ [workspace] resolver = "2" members = [ - "fqm", + "private_repos/*", "harmony", ] diff --git a/harmony-rs/fqm/Cargo.toml b/harmony-rs/fqm/Cargo.toml deleted file mode 100644 index c04bebb..0000000 --- a/harmony-rs/fqm/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "fqm" -version = "0.1.0" -edition = "2021" - -[dependencies] -harmony = { path = "../harmony" } -log = { workspace = true } -env_logger = { workspace = true } -tokio = { workspace = true } -cidr = { workspace = true } - diff --git a/harmony-rs/fqm/src/inventory/mod.rs b/harmony-rs/fqm/src/inventory/mod.rs deleted file mode 100644 index 5f0bd53..0000000 --- a/harmony-rs/fqm/src/inventory/mod.rs +++ /dev/null @@ -1,82 +0,0 @@ -use harmony::{ - hardware::{Host, HostCategory, Label, Location, NetworkInterface, Storage, StorageConnectionType, StorageKind}, - inventory::Inventory, -}; - -pub fn get_inventory() -> Inventory { - Inventory { - location: Location::new( - "1134 Grande Allée Ouest 1er étage, Québec, Qc".into(), - "FQM 1134 1er étage".into(), - ), - host: vec![], - switch: vec![], - firewall: vec![get_firewall_1()], - } -} - -fn get_firewall_1() -> Host { - Host { - category: HostCategory::Firewall, - network: vec![ - NetworkInterface::new( - "igb0".to_string(), - "00:90:7f:df:2c:1f".to_string(), - 1_000_000_000, - true, - ), - NetworkInterface::new( - "igb1".to_string(), - "00:90:7f:df:2c:20".to_string(), - 1_000_000_000, - true, - ), - NetworkInterface::new( - "igb2".to_string(), - "00:90:7f:df:2c:21".to_string(), - 1_000_000_000, - true, - ), - NetworkInterface::new( - "igb3".to_string(), - "00:90:7f:df:2c:22".to_string(), - 1_000_000_000, - true, - ), - NetworkInterface::new( - "igb4".to_string(), - "00:90:7f:df:2c:23".to_string(), - 1_000_000_000, - true, - ), - NetworkInterface::new( - "igb5".to_string(), - "00:90:7f:df:2c:24".to_string(), - 1_000_000_000, - true, - ), - NetworkInterface::new( - "igb6".to_string(), - "00:90:7f:df:2c:25".to_string(), - 1_000_000_000, - true, - ), - NetworkInterface::new( - "igb7".to_string(), - "00:90:7f:df:2c:26".to_string(), - 1_000_000_000, - true, - ), - ], - storage: vec![Storage::new( - StorageConnectionType::Sata6g, - StorageKind::SSD, - 240_000_000_000, - "TODO".to_string(), - )], - labels: vec![Label::new( - "operatingSystem".to_string(), - "opnsense".to_string(), - )], - } -} diff --git a/harmony-rs/fqm/src/lib.rs b/harmony-rs/fqm/src/lib.rs deleted file mode 100644 index 266b60e..0000000 --- a/harmony-rs/fqm/src/lib.rs +++ /dev/null @@ -1,16 +0,0 @@ -pub mod inventory; -pub mod topology; -pub fn add(left: usize, right: usize) -> usize { - left + right -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn it_works() { - let result = add(2, 2); - assert_eq!(result, 4); - } -} diff --git a/harmony-rs/fqm/src/main.rs b/harmony-rs/fqm/src/main.rs deleted file mode 100644 index 76b679a..0000000 --- a/harmony-rs/fqm/src/main.rs +++ /dev/null @@ -1,20 +0,0 @@ -use fqm::{inventory::get_inventory, topology::fqm_topology}; -use harmony::{ - maestro::Maestro, - modules::opnsense_dhcp::OPNSenseDhcpScore, -}; -use log::info; - -#[tokio::main] -async fn main() { - env_logger::init(); - - tokio::spawn(async move { - info!("FQM Harmony Starting"); - let topology = fqm_topology(); - let maestro = Maestro::new(get_inventory(), topology.clone()); - let score = OPNSenseDhcpScore::new(topology); - let result = maestro.interpret(score).await.unwrap(); - info!("{result}"); - }).await.unwrap(); -} diff --git a/harmony-rs/fqm/src/topology.rs b/harmony-rs/fqm/src/topology.rs deleted file mode 100644 index 520a375..0000000 --- a/harmony-rs/fqm/src/topology.rs +++ /dev/null @@ -1,25 +0,0 @@ -use std::net::Ipv4Addr; -use std::sync::Arc; - -use cidr::Ipv4Cidr; -use harmony::infra::opnsense::OPNSenseFirewall; -use harmony::topology::{HAClusterTopology, IpAddress, UnmanagedRouter}; - -pub fn fqm_topology() -> HAClusterTopology { - let opnsense_firewall = Arc::new(OPNSenseFirewall::new(IpAddress::V4(Ipv4Addr::new(10, 10, 8, 2)))); - - HAClusterTopology { - firewall: opnsense_firewall.clone(), - control_plane: vec![], - ceph_hosts: vec![], - switch: vec![], - router: Arc::new(UnmanagedRouter::new( - IpAddress::V4(Ipv4Addr::new(10, 10, 8, 1)), - Ipv4Cidr::new(Ipv4Addr::new(10, 10, 8, 0), 22).expect("Subnet is valid"), - )), - load_balancer: opnsense_firewall.clone(), - dhcp_server: opnsense_firewall.clone(), - dns_server: opnsense_firewall.clone(), - workers: vec![], - } -} diff --git a/harmony-rs/harmony/src/domain/executors/mod.rs b/harmony-rs/harmony/src/domain/executors/mod.rs index 21de8d7..9e991cb 100644 --- a/harmony-rs/harmony/src/domain/executors/mod.rs +++ b/harmony-rs/harmony/src/domain/executors/mod.rs @@ -2,6 +2,8 @@ use std::fmt; use async_trait::async_trait; +use super::topology::IpAddress; + pub struct ExecutorResult { message: String, } @@ -29,5 +31,5 @@ impl std::error::Error for ExecutorError {} #[async_trait] pub trait SshClient { - async fn test_connection(&self, username: &str, password: &str) -> Result<(), ExecutorError>; + async fn test_connection(&self, address: IpAddress, username: &str, password: &str) -> Result<(), ExecutorError>; } diff --git a/harmony-rs/harmony/src/domain/hardware/mod.rs b/harmony-rs/harmony/src/domain/hardware/mod.rs index 4072946..cd88332 100644 --- a/harmony-rs/harmony/src/domain/hardware/mod.rs +++ b/harmony-rs/harmony/src/domain/hardware/mod.rs @@ -11,6 +11,17 @@ pub struct Host { pub labels: Vec