diff --git a/harmony/src/domain/topology/ha_cluster.rs b/harmony/src/domain/topology/ha_cluster.rs index 6a08ef3..0e9230b 100644 --- a/harmony/src/domain/topology/ha_cluster.rs +++ b/harmony/src/domain/topology/ha_cluster.rs @@ -79,32 +79,139 @@ impl HAClusterTopology { } #[async_trait] -impl DnsServer for HAClusterTopology{ - async fn register_dhcp_leases(&self, _register: bool) -> Result<(), ExecutorError> { - self.dns_server.register_dhcp_leases(_register) +impl DnsServer for HAClusterTopology { + async fn register_dhcp_leases(&self, register: bool) -> Result<(), ExecutorError> { + self.dns_server.register_dhcp_leases(register).await } - async fn register_hosts(&self, _hosts: Vec) -> Result<(), ExecutorError> { - unimplemented!("{}", UNIMPLEMENTED_DUMMY_INFRA) + async fn register_hosts(&self, hosts: Vec) -> Result<(), ExecutorError> { + self.dns_server.register_hosts(hosts).await } - fn remove_record( - &mut self, - _name: &str, - _record_type: DnsRecordType, - ) -> Result<(), ExecutorError> { - unimplemented!("{}", UNIMPLEMENTED_DUMMY_INFRA) + fn remove_record(&self, name: &str, record_type: DnsRecordType) -> Result<(), ExecutorError> { + self.dns_server.remove_record(name, record_type) } async fn list_records(&self) -> Vec { - unimplemented!("{}", UNIMPLEMENTED_DUMMY_INFRA) + self.dns_server.list_records().await } + fn get_ip(&self) -> IpAddress { + self.dns_server.get_ip() + } + fn get_host(&self) -> LogicalHost { + self.dns_server.get_host() + } + async fn commit_config(&self) -> Result<(), ExecutorError> { + self.dns_server.commit_config().await + } +} + +#[async_trait] +impl LoadBalancer for HAClusterTopology { + fn get_ip(&self) -> IpAddress { + self.load_balancer.get_ip() + } + fn get_host(&self) -> LogicalHost { + self.load_balancer.get_host() + } + async fn add_service(&self, service: &LoadBalancerService) -> Result<(), ExecutorError> { + self.load_balancer.add_service(service).await + } + async fn remove_service(&self, service: &LoadBalancerService) -> Result<(), ExecutorError> { + self.load_balancer.remove_service(service).await + } + async fn list_services(&self) -> Vec { + self.load_balancer.list_services().await + } + async fn ensure_initialized(&self) -> Result<(), ExecutorError> { + self.load_balancer.ensure_initialized().await + } + async fn commit_config(&self) -> Result<(), ExecutorError> { + self.load_balancer.commit_config().await + } + async fn reload_restart(&self) -> Result<(), ExecutorError> { + self.load_balancer.reload_restart().await + } +} + +#[async_trait] +impl DhcpServer for HAClusterTopology { + async fn add_static_mapping(&self, entry: &DHCPStaticEntry) -> Result<(), ExecutorError> { + self.dhcp_server.add_static_mapping(entry).await + } + async fn remove_static_mapping(&self, mac: &MacAddress) -> Result<(), ExecutorError> { + self.dhcp_server.remove_static_mapping(mac).await + } + async fn list_static_mappings(&self) -> Vec<(MacAddress, IpAddress)> { + self.dhcp_server.list_static_mappings().await + } + async fn set_next_server(&self, ip: IpAddress) -> Result<(), ExecutorError> { + self.dhcp_server.set_next_server(ip).await + } + async fn set_boot_filename(&self, boot_filename: &str) -> Result<(), ExecutorError> { + self.dhcp_server.set_boot_filename(boot_filename).await + } + fn get_ip(&self) -> IpAddress { + self.dhcp_server.get_ip() + } + fn get_host(&self) -> LogicalHost { + self.dhcp_server.get_host() + } + async fn commit_config(&self) -> Result<(), ExecutorError> { + self.dhcp_server.commit_config().await + } +} + +#[async_trait] +impl TftpServer for HAClusterTopology { + async fn serve_files(&self, url: &Url) -> Result<(), ExecutorError> { + self.tftp_server.serve_files(url).await + } + fn get_ip(&self) -> IpAddress { + self.tftp_server.get_ip() + } + + async fn set_ip(&self, ip: IpAddress) -> Result<(), ExecutorError> { + self.tftp_server.set_ip(ip).await + } + async fn ensure_initialized(&self) -> Result<(), ExecutorError> { + self.tftp_server.ensure_initialized().await + } + async fn commit_config(&self) -> Result<(), ExecutorError> { + self.tftp_server.commit_config().await + } + async fn reload_restart(&self) -> Result<(), ExecutorError> { + self.tftp_server.reload_restart().await + } +} + +impl Router for HAClusterTopology { + fn get_gateway(&self) -> super::IpAddress { + self.router.get_gateway() + } + fn get_cidr(&self) -> cidr::Ipv4Cidr { + self.router.get_cidr() + } + fn get_host(&self) -> LogicalHost { + self.router.get_host() + } +} + +#[async_trait] +impl HttpServer for HAClusterTopology { + async fn serve_files(&self, url: &Url) -> Result<(), ExecutorError> { + self.http_server.serve_files(url).await + } + fn get_ip(&self) -> IpAddress { unimplemented!("{}", UNIMPLEMENTED_DUMMY_INFRA) } - fn get_host(&self) -> LogicalHost { + async fn ensure_initialized(&self) -> Result<(), ExecutorError> { unimplemented!("{}", UNIMPLEMENTED_DUMMY_INFRA) } async fn commit_config(&self) -> Result<(), ExecutorError> { unimplemented!("{}", UNIMPLEMENTED_DUMMY_INFRA) } + async fn reload_restart(&self) -> Result<(), ExecutorError> { + unimplemented!("{}", UNIMPLEMENTED_DUMMY_INFRA) + } } #[derive(Debug)] @@ -251,11 +358,7 @@ impl DnsServer for DummyInfra { async fn register_hosts(&self, _hosts: Vec) -> Result<(), ExecutorError> { unimplemented!("{}", UNIMPLEMENTED_DUMMY_INFRA) } - fn remove_record( - &mut self, - _name: &str, - _record_type: DnsRecordType, - ) -> Result<(), ExecutorError> { + fn remove_record(&self, _name: &str, _record_type: DnsRecordType) -> Result<(), ExecutorError> { unimplemented!("{}", UNIMPLEMENTED_DUMMY_INFRA) } async fn list_records(&self) -> Vec { diff --git a/harmony/src/domain/topology/network.rs b/harmony/src/domain/topology/network.rs index 523db2f..6aba5f3 100644 --- a/harmony/src/domain/topology/network.rs +++ b/harmony/src/domain/topology/network.rs @@ -63,7 +63,7 @@ pub trait DnsServer: Send + Sync { async fn register_dhcp_leases(&self, register: bool) -> Result<(), ExecutorError>; async fn register_hosts(&self, hosts: Vec) -> Result<(), ExecutorError>; fn remove_record( - &mut self, + &self, name: &str, record_type: DnsRecordType, ) -> Result<(), ExecutorError>; @@ -254,7 +254,7 @@ mod test { } fn remove_record( - &mut self, + &self, _name: &str, _record_type: DnsRecordType, ) -> Result<(), ExecutorError> { diff --git a/harmony/src/infra/opnsense/dns.rs b/harmony/src/infra/opnsense/dns.rs index 765cdb0..56f8136 100644 --- a/harmony/src/infra/opnsense/dns.rs +++ b/harmony/src/infra/opnsense/dns.rs @@ -30,7 +30,7 @@ impl DnsServer for OPNSenseFirewall { } fn remove_record( - &mut self, + &self, _name: &str, _record_type: crate::topology::DnsRecordType, ) -> Result<(), ExecutorError> {