wip: Working hard on topology, seems to have something that may work, next step is put the building blocks together for real
This commit is contained in:
parent
87a9ec3ec4
commit
ff3d53c704
8
harmony-rs/Cargo.lock
generated
8
harmony-rs/Cargo.lock
generated
@ -282,6 +282,12 @@ dependencies = [
|
|||||||
"cpufeatures",
|
"cpufeatures",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cidr"
|
||||||
|
version = "0.2.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6bdf600c45bd958cf2945c445264471cca8b6c8e67bc87b71affd6d7e5682621"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cipher"
|
name = "cipher"
|
||||||
version = "0.4.4"
|
version = "0.4.4"
|
||||||
@ -620,6 +626,7 @@ dependencies = [
|
|||||||
name = "fqm"
|
name = "fqm"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"cidr",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"harmony",
|
"harmony",
|
||||||
"log",
|
"log",
|
||||||
@ -794,6 +801,7 @@ name = "harmony"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
|
"cidr",
|
||||||
"derive-new",
|
"derive-new",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"libredfish",
|
"libredfish",
|
||||||
|
|||||||
@ -16,3 +16,4 @@ env_logger = "0.11.5"
|
|||||||
derive-new = "0.7.0"
|
derive-new = "0.7.0"
|
||||||
async-trait = "0.1.82"
|
async-trait = "0.1.82"
|
||||||
tokio = { version = "1.40.0", features = ["io-std"] }
|
tokio = { version = "1.40.0", features = ["io-std"] }
|
||||||
|
cidr = "0.2.3"
|
||||||
|
|||||||
@ -8,4 +8,5 @@ harmony = { path = "../harmony" }
|
|||||||
log = { workspace = true }
|
log = { workspace = true }
|
||||||
env_logger = { workspace = true }
|
env_logger = { workspace = true }
|
||||||
tokio = { workspace = true }
|
tokio = { workspace = true }
|
||||||
|
cidr = { workspace = true }
|
||||||
|
|
||||||
|
|||||||
@ -1,23 +0,0 @@
|
|||||||
use harmony::domain::{
|
|
||||||
hardware::{Host, HostCategory, Location, NetworkInterface},
|
|
||||||
inventory::Inventory,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub fn get_inventory() -> Inventory {
|
|
||||||
let network = vec![NetworkInterface::new(1_000_000_000, "TODO MAC ADDRESS".into(), true ) ];
|
|
||||||
let storage = vec![];
|
|
||||||
Inventory {
|
|
||||||
location: Location::new(
|
|
||||||
"1134 Grande Allée Ouest 1er étage, Québec, Qc".into(),
|
|
||||||
"FQM 1134 1er étage".into(),
|
|
||||||
),
|
|
||||||
host: vec![Host {
|
|
||||||
category: HostCategory::Server,
|
|
||||||
network,
|
|
||||||
storage,
|
|
||||||
labels: vec![],
|
|
||||||
}],
|
|
||||||
switch: vec![],
|
|
||||||
firewall: vec![],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
82
harmony-rs/fqm/src/inventory/mod.rs
Normal file
82
harmony-rs/fqm/src/inventory/mod.rs
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
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,9 +1,7 @@
|
|||||||
use fqm::inventory::get_inventory;
|
use fqm::{inventory::get_inventory, topology::fqm_topology};
|
||||||
use harmony::{
|
use harmony::{
|
||||||
domain::{
|
inventory::InventoryFilter,
|
||||||
inventory::{Inventory, InventoryFilter},
|
|
||||||
maestro::Maestro,
|
maestro::Maestro,
|
||||||
},
|
|
||||||
modules::opnsense_dhcp::OPNSenseDhcpScore,
|
modules::opnsense_dhcp::OPNSenseDhcpScore,
|
||||||
};
|
};
|
||||||
use log::info;
|
use log::info;
|
||||||
@ -15,6 +13,7 @@ async fn main() {
|
|||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
info!("FQM Harmony Starting");
|
info!("FQM Harmony Starting");
|
||||||
let maestro = Maestro::new(get_inventory());
|
let maestro = Maestro::new(get_inventory());
|
||||||
|
let topology = fqm_topology();
|
||||||
let score = OPNSenseDhcpScore::new(InventoryFilter::new(vec![]));
|
let score = OPNSenseDhcpScore::new(InventoryFilter::new(vec![]));
|
||||||
let result = maestro.interpret(score).await.unwrap();
|
let result = maestro.interpret(score).await.unwrap();
|
||||||
info!("{result}");
|
info!("{result}");
|
||||||
|
|||||||
@ -1,86 +1,24 @@
|
|||||||
use std::net::{IpAddr, Ipv4Addr};
|
use std::net::Ipv4Addr;
|
||||||
|
|
||||||
use harmony::{
|
use cidr::Ipv4Cidr;
|
||||||
hardware::*,
|
use harmony::infra::opnsense::OPNSenseFirewall;
|
||||||
topology::{ClusterMember, HAClusterTopology, IpAddress, OPNSenseManagement},
|
use harmony::topology::{HAClusterTopology, IpAddress, UnmanagedRouter};
|
||||||
};
|
|
||||||
|
|
||||||
pub fn fqm_topology() -> HAClusterTopology {
|
pub fn fqm_topology() -> HAClusterTopology {
|
||||||
|
let opnsense_firewall = Box::new(OPNSenseFirewall::new(IpAddress::V4(Ipv4Addr::new(10, 10, 8, 2))));
|
||||||
|
|
||||||
HAClusterTopology {
|
HAClusterTopology {
|
||||||
firewall: vec![ClusterMember {
|
firewall: opnsense_firewall.clone(),
|
||||||
management: Box::new(OPNSenseManagement::new(
|
control_plane: vec![],
|
||||||
"user".to_string(),
|
ceph_hosts: vec![],
|
||||||
"password".to_string(),
|
switch: vec![],
|
||||||
)),
|
router: Box::new(UnmanagedRouter::new(
|
||||||
host: Host {
|
IpAddress::V4(Ipv4Addr::new(10, 10, 8, 1)),
|
||||||
category: HostCategory::Firewall,
|
Ipv4Cidr::new(Ipv4Addr::new(10, 10, 8, 0), 22).expect("Subnet is valid"),
|
||||||
network: vec![
|
)),
|
||||||
NetworkInterface::new(
|
load_balancer: opnsense_firewall.clone(),
|
||||||
"igb0".to_string(),
|
dhcp_server: opnsense_firewall.clone(),
|
||||||
"00:90:7f:df:2c:1f".to_string(),
|
dns_server: opnsense_firewall.clone(),
|
||||||
1_000_000_000,
|
workers: vec![],
|
||||||
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(),
|
|
||||||
)],
|
|
||||||
},
|
|
||||||
}],
|
|
||||||
control_plane: todo!(),
|
|
||||||
workers: todo!(),
|
|
||||||
ceph_hosts: todo!(),
|
|
||||||
switch: todo!(),
|
|
||||||
gateway: IpAddress::V4(Ipv4Addr::new(10, 10, 8, 1)),
|
|
||||||
load_balancer: IpAddress::V4(Ipv4Addr::new(10, 10, 8, 1)),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,3 +16,4 @@ derive-new = { workspace = true }
|
|||||||
log = { workspace = true }
|
log = { workspace = true }
|
||||||
env_logger = { workspace = true }
|
env_logger = { workspace = true }
|
||||||
async-trait = { workspace = true }
|
async-trait = { workspace = true }
|
||||||
|
cidr = { workspace = true }
|
||||||
|
|||||||
@ -2,7 +2,7 @@ use derive_new::new;
|
|||||||
|
|
||||||
pub type HostGroup = Vec<Host>;
|
pub type HostGroup = Vec<Host>;
|
||||||
pub type SwitchGroup = Vec<Switch>;
|
pub type SwitchGroup = Vec<Switch>;
|
||||||
pub type FirewallGroup = Vec<Firewall>;
|
pub type FirewallGroup = Vec<Host>;
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Host {
|
pub struct Host {
|
||||||
pub category: HostCategory,
|
pub category: HostCategory,
|
||||||
@ -55,8 +55,6 @@ pub struct Switch {
|
|||||||
management_interface: NetworkInterface,
|
management_interface: NetworkInterface,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct Firewall {}
|
|
||||||
#[derive(Debug, new)]
|
#[derive(Debug, new)]
|
||||||
pub struct Label {
|
pub struct Label {
|
||||||
name: String,
|
name: String,
|
||||||
|
|||||||
27
harmony-rs/harmony/src/domain/topology/load_balancer.rs
Normal file
27
harmony-rs/harmony/src/domain/topology/load_balancer.rs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
use super::IpAddress;
|
||||||
|
|
||||||
|
pub trait LoadBalancer {
|
||||||
|
fn add_backend(&mut self, backend: Backend) -> Result<(), LoadBalancerError>;
|
||||||
|
fn remove_backend(&mut self, backend_id: &str) -> Result<(), LoadBalancerError>;
|
||||||
|
fn add_frontend(&mut self, frontend: Frontend) -> Result<(), LoadBalancerError>;
|
||||||
|
fn remove_frontend(&mut self, frontend_id: &str) -> Result<(), LoadBalancerError>;
|
||||||
|
fn list_backends(&self) -> Vec<Backend>;
|
||||||
|
fn list_frontends(&self) -> Vec<Frontend>;
|
||||||
|
}
|
||||||
|
pub struct LoadBalancerError;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub struct Backend {
|
||||||
|
pub id: String,
|
||||||
|
pub ip: IpAddress,
|
||||||
|
pub port: u16,
|
||||||
|
pub weight: u8,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub struct Frontend {
|
||||||
|
pub id: String,
|
||||||
|
pub ip: IpAddress,
|
||||||
|
pub port: u16,
|
||||||
|
pub backend_ids: Vec<String>,
|
||||||
|
}
|
||||||
@ -1,18 +1,20 @@
|
|||||||
|
mod router;
|
||||||
|
mod load_balancer;
|
||||||
|
pub use router::*;
|
||||||
|
pub use load_balancer::*;
|
||||||
mod network;
|
mod network;
|
||||||
pub use network::*;
|
pub use network::*;
|
||||||
|
|
||||||
use std::net::IpAddr;
|
use std::net::IpAddr;
|
||||||
|
|
||||||
use derive_new::new;
|
use super::hardware::Host;
|
||||||
|
|
||||||
use super::hardware::{Host, HostGroup};
|
|
||||||
|
|
||||||
pub struct HAClusterTopology {
|
pub struct HAClusterTopology {
|
||||||
pub gateway: IpAddress,
|
pub router: Box<dyn Router + Send>,
|
||||||
pub load_balancer: IpAddress,
|
pub load_balancer: Box<dyn LoadBalancer + Send>,
|
||||||
pub firewall: Box<dyn Firewall>,
|
pub firewall: Box<dyn Firewall + Send>,
|
||||||
pub dhcp_server: Box<dyn DhcpServer>,
|
pub dhcp_server: Box<dyn DhcpServer + Send>,
|
||||||
pub dns_server: Box<dyn DnsServer>,
|
pub dns_server: Box<dyn DnsServer + Send>,
|
||||||
pub control_plane: Vec<ClusterMember>,
|
pub control_plane: Vec<ClusterMember>,
|
||||||
pub workers: Vec<ClusterMember>,
|
pub workers: Vec<ClusterMember>,
|
||||||
pub ceph_hosts: Vec<ClusterMember>,
|
pub ceph_hosts: Vec<ClusterMember>,
|
||||||
@ -22,7 +24,7 @@ pub struct HAClusterTopology {
|
|||||||
pub type IpAddress = IpAddr;
|
pub type IpAddress = IpAddr;
|
||||||
|
|
||||||
pub struct ClusterMember {
|
pub struct ClusterMember {
|
||||||
pub management: Box<dyn ManagementInterface>,
|
pub management: Box<dyn ManagementInterface + Send>,
|
||||||
pub host: Host,
|
pub host: Host,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,18 +33,3 @@ pub trait ManagementInterface {
|
|||||||
fn get_ip(&self) -> IpAddress;
|
fn get_ip(&self) -> IpAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(new)]
|
|
||||||
pub struct OPNSenseManagement {
|
|
||||||
username: String,
|
|
||||||
password: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ManagementInterface for OPNSenseManagement {
|
|
||||||
fn boot_to_pxe(&self) {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_ip(&self) -> IpAddress {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,15 +1,20 @@
|
|||||||
use std::net::{IpAddr, Ipv4Addr};
|
use super::IpAddress;
|
||||||
|
|
||||||
pub trait Firewall {
|
pub trait Firewall {
|
||||||
fn add_rule(&mut self, rule: FirewallRule) -> Result<(), FirewallError>;
|
fn add_rule(&mut self, rule: FirewallRule) -> Result<(), FirewallError>;
|
||||||
fn remove_rule(&mut self, rule_id: &str) -> Result<(), FirewallError>;
|
fn remove_rule(&mut self, rule_id: &str) -> Result<(), FirewallError>;
|
||||||
fn list_rules(&self) -> Vec<FirewallRule>;
|
fn list_rules(&self) -> Vec<FirewallRule>;
|
||||||
|
fn get_ip(&self) -> IpAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct NetworkDomain {
|
||||||
|
pub name: String
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait DhcpServer {
|
pub trait DhcpServer {
|
||||||
fn add_static_mapping(&mut self, mac: MacAddress, ip: Ipv4Addr) -> Result<(), DhcpError>;
|
fn add_static_mapping(&mut self, mac: MacAddress, ip: IpAddress) -> Result<(), DhcpError>;
|
||||||
fn remove_static_mapping(&mut self, mac: &MacAddress) -> Result<(), DhcpError>;
|
fn remove_static_mapping(&mut self, mac: &MacAddress) -> Result<(), DhcpError>;
|
||||||
fn list_static_mappings(&self) -> Vec<(MacAddress, Ipv4Addr)>;
|
fn list_static_mappings(&self) -> Vec<(MacAddress, IpAddress)>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait DnsServer {
|
pub trait DnsServer {
|
||||||
@ -18,22 +23,11 @@ pub trait DnsServer {
|
|||||||
fn list_records(&self) -> Vec<DnsRecord>;
|
fn list_records(&self) -> Vec<DnsRecord>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait LoadBalancer {
|
|
||||||
fn add_backend(&mut self, backend: Backend) -> Result<(), LoadBalancerError>;
|
|
||||||
fn remove_backend(&mut self, backend_id: &str) -> Result<(), LoadBalancerError>;
|
|
||||||
fn add_frontend(&mut self, frontend: Frontend) -> Result<(), LoadBalancerError>;
|
|
||||||
fn remove_frontend(&mut self, frontend_id: &str) -> Result<(), LoadBalancerError>;
|
|
||||||
fn list_backends(&self) -> Vec<Backend>;
|
|
||||||
fn list_frontends(&self) -> Vec<Frontend>;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Supporting types
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct FirewallRule {
|
pub struct FirewallRule {
|
||||||
pub id: String,
|
pub id: String,
|
||||||
pub source: IpAddr,
|
pub source: IpAddress,
|
||||||
pub destination: IpAddr,
|
pub destination: IpAddress,
|
||||||
pub port: u16,
|
pub port: u16,
|
||||||
pub protocol: Protocol,
|
pub protocol: Protocol,
|
||||||
pub action: Action,
|
pub action: Action,
|
||||||
@ -71,24 +65,7 @@ pub struct DnsRecord {
|
|||||||
pub value: String,
|
pub value: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct Backend {
|
|
||||||
pub id: String,
|
|
||||||
pub ip: IpAddr,
|
|
||||||
pub port: u16,
|
|
||||||
pub weight: u8,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct Frontend {
|
|
||||||
pub id: String,
|
|
||||||
pub ip: IpAddr,
|
|
||||||
pub port: u16,
|
|
||||||
pub backend_ids: Vec<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
// Error types
|
// Error types
|
||||||
pub struct FirewallError;
|
pub struct FirewallError;
|
||||||
pub struct DhcpError;
|
pub struct DhcpError;
|
||||||
pub struct DnsError;
|
pub struct DnsError;
|
||||||
pub struct LoadBalancerError;
|
|
||||||
|
|||||||
25
harmony-rs/harmony/src/domain/topology/router.rs
Normal file
25
harmony-rs/harmony/src/domain/topology/router.rs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
use cidr::Ipv4Cidr;
|
||||||
|
use derive_new::new;
|
||||||
|
|
||||||
|
use super::IpAddress;
|
||||||
|
|
||||||
|
pub trait Router {
|
||||||
|
fn get_gateway(&self) -> IpAddress;
|
||||||
|
fn get_cidr(&self) -> Ipv4Cidr;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(new)]
|
||||||
|
pub struct UnmanagedRouter {
|
||||||
|
gateway: IpAddress,
|
||||||
|
cidr: Ipv4Cidr,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Router for UnmanagedRouter {
|
||||||
|
fn get_gateway(&self) -> IpAddress {
|
||||||
|
self.gateway.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_cidr(&self) -> Ipv4Cidr {
|
||||||
|
self.cidr.clone()
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1 +1,2 @@
|
|||||||
pub mod executors;
|
pub mod executors;
|
||||||
|
pub mod opnsense;
|
||||||
|
|||||||
78
harmony-rs/harmony/src/infra/opnsense/mod.rs
Normal file
78
harmony-rs/harmony/src/infra/opnsense/mod.rs
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
use derive_new::new;
|
||||||
|
use crate::topology::{Backend, DhcpServer, DnsServer, Firewall, FirewallError, FirewallRule, Frontend, IpAddress, LoadBalancer, LoadBalancerError};
|
||||||
|
|
||||||
|
#[derive(new, Clone)]
|
||||||
|
pub struct OPNSenseFirewall {
|
||||||
|
ip_address: IpAddress,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Firewall for OPNSenseFirewall {
|
||||||
|
fn add_rule(&mut self, _rule: FirewallRule) -> Result<(), FirewallError> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn remove_rule(&mut self, _rule_id: &str) -> Result<(), FirewallError> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn list_rules(&self) -> Vec<FirewallRule> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_ip(&self) -> IpAddress {
|
||||||
|
self.ip_address.clone()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl LoadBalancer for OPNSenseFirewall {
|
||||||
|
fn add_backend(&mut self, _backend: Backend) -> Result<(), LoadBalancerError> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn remove_backend(&mut self, _backend_id: &str) -> Result<(), LoadBalancerError> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn add_frontend(&mut self, _frontend: Frontend) -> Result<(), LoadBalancerError> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn remove_frontend(&mut self, _frontend_id: &str) -> Result<(), LoadBalancerError> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn list_backends(&self) -> Vec<Backend> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn list_frontends(&self) -> Vec<Frontend> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DhcpServer for OPNSenseFirewall {
|
||||||
|
fn add_static_mapping(&mut self, mac: crate::topology::MacAddress, ip: IpAddress) -> Result<(), crate::topology::DhcpError> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn remove_static_mapping(&mut self, mac: &crate::topology::MacAddress) -> Result<(), crate::topology::DhcpError> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn list_static_mappings(&self) -> Vec<(crate::topology::MacAddress, IpAddress)> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl DnsServer for OPNSenseFirewall {
|
||||||
|
fn add_record(&mut self, name: &str, record_type: crate::topology::DnsRecordType, value: &str) -> Result<(), crate::topology::DnsError> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn remove_record(&mut self, name: &str, record_type: crate::topology::DnsRecordType) -> Result<(), crate::topology::DnsError> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn list_records(&self) -> Vec<crate::topology::DnsRecord> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user