forked from NationTech/harmony
chore: Move client setups to private repos that can be cloned manually by the developer
This commit is contained in:
@@ -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()))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user