chore: Move client setups to private repos that can be cloned manually by the developer
This commit is contained in:
parent
532f600283
commit
042ff7e7dd
1
harmony-rs/.gitignore
vendored
1
harmony-rs/.gitignore
vendored
@ -1 +1,2 @@
|
||||
target
|
||||
private_repos
|
||||
|
11
harmony-rs/Cargo.lock
generated
11
harmony-rs/Cargo.lock
generated
@ -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"
|
||||
|
@ -1,7 +1,7 @@
|
||||
[workspace]
|
||||
resolver = "2"
|
||||
members = [
|
||||
"fqm",
|
||||
"private_repos/*",
|
||||
"harmony",
|
||||
]
|
||||
|
||||
|
@ -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 }
|
||||
|
@ -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(),
|
||||
)],
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
@ -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![],
|
||||
}
|
||||
}
|
@ -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>;
|
||||
}
|
||||
|
@ -11,6 +11,17 @@ pub struct Host {
|
||||
pub labels: Vec<Label>,
|
||||
}
|
||||
|
||||
impl Host {
|
||||
pub fn new_empty(category: HostCategory) -> Self {
|
||||
Self {
|
||||
category,
|
||||
network: vec![],
|
||||
storage: vec![],
|
||||
labels: vec![],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum HostCategory {
|
||||
Server,
|
||||
|
@ -18,7 +18,6 @@ pub struct HAClusterTopology {
|
||||
pub dns_server: Arc<dyn DnsServer>,
|
||||
pub control_plane: Vec<ClusterMember>,
|
||||
pub workers: Vec<ClusterMember>,
|
||||
pub ceph_hosts: Vec<ClusterMember>,
|
||||
pub switch: Vec<ClusterMember>,
|
||||
}
|
||||
|
||||
|
@ -3,16 +3,16 @@ use async_trait::async_trait;
|
||||
|
||||
use russh::{client, keys::key};
|
||||
|
||||
use crate::domain::executors::{ExecutorError, SshClient};
|
||||
use crate::{domain::executors::{ExecutorError, SshClient}, topology::IpAddress};
|
||||
|
||||
pub struct RusshClient;
|
||||
|
||||
#[async_trait]
|
||||
impl SshClient for RusshClient {
|
||||
async fn test_connection(&self, _username: &str, _password: &str) -> Result<(), crate::domain::executors::ExecutorError> {
|
||||
async fn test_connection(&self, address: IpAddress,_username: &str, _password: &str) -> Result<(), crate::domain::executors::ExecutorError> {
|
||||
let config = client::Config::default();
|
||||
let c = Client{};
|
||||
let mut client = client::connect(Arc::new(config), ("192.168.1.1", 22), c).await?;
|
||||
let mut client = client::connect(Arc::new(config), (address, 22), c).await?;
|
||||
match client.authenticate_password("nationtech", "opnsense").await? {
|
||||
true => Ok(()),
|
||||
false => Err(ExecutorError::AuthenticationError("ssh authentication failed".to_string())),
|
||||
|
17
harmony-rs/harmony/src/infra/intel_amt/mod.rs
Normal file
17
harmony-rs/harmony/src/infra/intel_amt/mod.rs
Normal file
@ -0,0 +1,17 @@
|
||||
use derive_new::new;
|
||||
use crate::topology::{IpAddress, ManagementInterface};
|
||||
|
||||
#[derive(new)]
|
||||
pub struct IntelAmtManagement {
|
||||
ip_address: IpAddress,
|
||||
}
|
||||
|
||||
impl ManagementInterface for IntelAmtManagement {
|
||||
fn boot_to_pxe(&self) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn get_ip(&self) -> IpAddress {
|
||||
self.ip_address
|
||||
}
|
||||
}
|
@ -1,2 +1,3 @@
|
||||
pub mod executors;
|
||||
pub mod opnsense;
|
||||
pub mod intel_amt;
|
||||
|
@ -13,9 +13,7 @@ use crate::domain::{
|
||||
use crate::domain::executors::{ExecutorError, ExecutorResult};
|
||||
|
||||
#[derive(Debug, new, Clone)]
|
||||
pub struct OPNSenseDhcpScore {
|
||||
topology: HAClusterTopology,
|
||||
}
|
||||
pub struct OPNSenseDhcpScore {}
|
||||
|
||||
impl Score for OPNSenseDhcpScore {
|
||||
type InterpretType = OPNSenseDhcpInterpret;
|
||||
@ -73,13 +71,11 @@ impl Interpret for OPNSenseDhcpInterpret {
|
||||
todo!()
|
||||
}
|
||||
|
||||
async fn execute(&self, inventory: &Inventory, _topology: &HAClusterTopology) -> Result<Outcome, InterpretError> {
|
||||
async fn execute(&self, inventory: &Inventory, topology: &HAClusterTopology) -> Result<Outcome, InterpretError> {
|
||||
info!("Executing {} on inventory {inventory:?}", self.get_name());
|
||||
let ssh_client = RusshClient{};
|
||||
|
||||
info!("RusshClient initiated");
|
||||
ssh_client.test_connection("paul", "paul").await?;
|
||||
info!("Connection test complete");
|
||||
todo!("Filter proper network interfaces and prepare the DHCP configuration");
|
||||
|
||||
Ok(Outcome::new(InterpretStatus::SUCCESS, "Connection test successful".to_string()))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user