diff --git a/Cargo.lock b/Cargo.lock index a33b177..62d8aee 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1671,6 +1671,7 @@ dependencies = [ "env_logger", "harmony", "harmony_cli", + "harmony_types", "logging", "tokio", "url", @@ -1732,6 +1733,7 @@ dependencies = [ "harmony", "harmony_cli", "harmony_macros", + "harmony_types", "tokio", "url", ] @@ -1743,6 +1745,7 @@ dependencies = [ "cidr", "harmony", "harmony_cli", + "harmony_types", "tokio", "url", ] @@ -2293,7 +2296,6 @@ dependencies = [ "opnsense-config", "opnsense-config-xml", "pretty_assertions", - "rand 0.9.1", "reqwest 0.11.27", "russh", "rust-ipmi", @@ -2364,9 +2366,12 @@ version = "0.1.0" dependencies = [ "actix-web", "env_logger", + "harmony_macros", + "harmony_types", "local-ip-address", "log", "mdns-sd 0.14.1 (git+https://github.com/jggc/mdns-sd.git?branch=patch-1)", + "reqwest 0.12.20", "serde", "serde_json", "sysinfo", @@ -2437,7 +2442,9 @@ dependencies = [ name = "harmony_types" version = "0.1.0" dependencies = [ + "rand 0.9.1", "serde", + "url", ] [[package]] @@ -3849,7 +3856,7 @@ dependencies = [ "env_logger", "log", "pretty_assertions", - "rand 0.8.5", + "rand 0.9.1", "serde", "thiserror 2.0.14", "tokio", diff --git a/Cargo.toml b/Cargo.toml index aec04b8..d92c0e7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ tokio = { version = "1.40", features = [ cidr = { features = ["serde"], version = "0.2" } russh = "0.45" russh-keys = "0.45" -rand = "0.8" +rand = "0.9" url = "2.5" kube = { version = "1.1.0", features = [ "config", @@ -67,3 +67,4 @@ serde = { version = "1.0.209", features = ["derive", "rc"] } serde_json = "1.0.127" askama = "0.14" sqlx = { version = "0.8", features = ["runtime-tokio", "sqlite" ] } +reqwest = { version = "0.12", features = ["blocking", "stream", "rustls-tls", "http2", "json"], default-features = false } diff --git a/data/pxe/okd/http_files/harmony_inventory_agent b/data/pxe/okd/http_files/harmony_inventory_agent index ada5282..1d802f7 100755 --- a/data/pxe/okd/http_files/harmony_inventory_agent +++ b/data/pxe/okd/http_files/harmony_inventory_agent @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:aed14f47246bc20c5ada082f782da77da90ef9f78ef18fbf9f160f2101d9c92a -size 8129096 +oid sha256:5244fa8968fe15c2415de6cc487e6112f8aedd9989951e018f9bdb536b1016d2 +size 8139216 diff --git a/examples/application_monitoring_with_tenant/Cargo.toml b/examples/application_monitoring_with_tenant/Cargo.toml index b9b63de..3f162d3 100644 --- a/examples/application_monitoring_with_tenant/Cargo.toml +++ b/examples/application_monitoring_with_tenant/Cargo.toml @@ -7,8 +7,9 @@ license.workspace = true [dependencies] env_logger.workspace = true -harmony = { version = "0.1.0", path = "../../harmony" } -harmony_cli = { version = "0.1.0", path = "../../harmony_cli" } +harmony = { path = "../../harmony" } +harmony_cli = { path = "../../harmony_cli" } +harmony_types = { path = "../../harmony_types" } logging = "0.1.0" tokio.workspace = true url.workspace = true diff --git a/examples/application_monitoring_with_tenant/src/main.rs b/examples/application_monitoring_with_tenant/src/main.rs index 9ab0bf6..7e60703 100644 --- a/examples/application_monitoring_with_tenant/src/main.rs +++ b/examples/application_monitoring_with_tenant/src/main.rs @@ -1,15 +1,16 @@ use std::{path::PathBuf, str::FromStr, sync::Arc}; use harmony::{ - data::Id, inventory::Inventory, modules::{ application::{ApplicationScore, RustWebFramework, RustWebapp, features::Monitoring}, monitoring::alert_channel::webhook_receiver::WebhookReceiver, tenant::TenantScore, }, - topology::{K8sAnywhereTopology, Url, tenant::TenantConfig}, + topology::{K8sAnywhereTopology, tenant::TenantConfig}, }; +use harmony_types::id::Id; +use harmony_types::net::Url; #[tokio::main] async fn main() { diff --git a/examples/lamp/src/main.rs b/examples/lamp/src/main.rs index b621156..3dc5a25 100644 --- a/examples/lamp/src/main.rs +++ b/examples/lamp/src/main.rs @@ -2,8 +2,9 @@ use harmony::{ data::Version, inventory::Inventory, modules::lamp::{LAMPConfig, LAMPScore}, - topology::{K8sAnywhereTopology, Url}, + topology::K8sAnywhereTopology, }; +use harmony_types::net::Url; #[tokio::main] async fn main() { diff --git a/examples/monitoring/Cargo.toml b/examples/monitoring/Cargo.toml index 1c35330..c9f7d80 100644 --- a/examples/monitoring/Cargo.toml +++ b/examples/monitoring/Cargo.toml @@ -6,8 +6,9 @@ readme.workspace = true license.workspace = true [dependencies] -harmony = { version = "0.1.0", path = "../../harmony" } -harmony_cli = { version = "0.1.0", path = "../../harmony_cli" } -harmony_macros = { version = "0.1.0", path = "../../harmony_macros" } +harmony = { path = "../../harmony" } +harmony_cli = { path = "../../harmony_cli" } +harmony_macros = { path = "../../harmony_macros" } +harmony_types = { path = "../../harmony_types" } tokio.workspace = true url.workspace = true diff --git a/examples/monitoring/src/main.rs b/examples/monitoring/src/main.rs index b0a3939..d06a93e 100644 --- a/examples/monitoring/src/main.rs +++ b/examples/monitoring/src/main.rs @@ -22,8 +22,9 @@ use harmony::{ k8s::pvc::high_pvc_fill_rate_over_two_days, }, }, - topology::{K8sAnywhereTopology, Url}, + topology::K8sAnywhereTopology, }; +use harmony_types::net::Url; #[tokio::main] async fn main() { diff --git a/examples/monitoring_with_tenant/Cargo.toml b/examples/monitoring_with_tenant/Cargo.toml index 27fd4dd..10049c6 100644 --- a/examples/monitoring_with_tenant/Cargo.toml +++ b/examples/monitoring_with_tenant/Cargo.toml @@ -7,7 +7,8 @@ license.workspace = true [dependencies] cidr.workspace = true -harmony = { version = "0.1.0", path = "../../harmony" } -harmony_cli = { version = "0.1.0", path = "../../harmony_cli" } +harmony = { path = "../../harmony" } +harmony_cli = { path = "../../harmony_cli" } +harmony_types = { path = "../../harmony_types" } tokio.workspace = true url.workspace = true diff --git a/examples/monitoring_with_tenant/src/main.rs b/examples/monitoring_with_tenant/src/main.rs index 2960944..5b85f78 100644 --- a/examples/monitoring_with_tenant/src/main.rs +++ b/examples/monitoring_with_tenant/src/main.rs @@ -1,7 +1,6 @@ use std::{collections::HashMap, str::FromStr}; use harmony::{ - data::Id, inventory::Inventory, modules::{ monitoring::{ @@ -19,10 +18,12 @@ use harmony::{ tenant::TenantScore, }, topology::{ - K8sAnywhereTopology, Url, + K8sAnywhereTopology, tenant::{ResourceLimits, TenantConfig, TenantNetworkPolicy}, }, }; +use harmony_types::id::Id; +use harmony_types::net::Url; #[tokio::main] async fn main() { diff --git a/examples/nanodc/src/main.rs b/examples/nanodc/src/main.rs index 10ba715..a6bb8e4 100644 --- a/examples/nanodc/src/main.rs +++ b/examples/nanodc/src/main.rs @@ -18,9 +18,10 @@ use harmony::{ }, tftp::TftpScore, }, - topology::{LogicalHost, UnmanagedRouter, Url}, + topology::{LogicalHost, UnmanagedRouter}, }; use harmony_macros::{ip, mac_address}; +use harmony_types::net::Url; #[tokio::main] async fn main() { @@ -86,8 +87,7 @@ async fn main() { let inventory = Inventory { location: Location::new("I am mobile".to_string(), "earth".to_string()), switch: SwitchGroup::from([]), - firewall: FirewallGroup::from([PhysicalHost::empty(HostCategory::Firewall) - .management(Arc::new(OPNSenseManagementInterface::new()))]), + firewall_mgmt: Box::new(OPNSenseManagementInterface::new()), storage_host: vec![], worker_host: vec![ PhysicalHost::empty(HostCategory::Server) diff --git a/examples/okd_pxe/src/topology.rs b/examples/okd_pxe/src/topology.rs index eb23908..27eb8c0 100644 --- a/examples/okd_pxe/src/topology.rs +++ b/examples/okd_pxe/src/topology.rs @@ -69,8 +69,7 @@ pub fn get_inventory() -> Inventory { "testopnsense".to_string(), ), switch: SwitchGroup::from([]), - firewall: FirewallGroup::from([PhysicalHost::empty(HostCategory::Firewall) - .management(Arc::new(OPNSenseManagementInterface::new()))]), + firewall_mgmt: Box::new(OPNSenseManagementInterface::new()), storage_host: vec![], worker_host: vec![], control_plane_host: vec![], diff --git a/examples/opnsense/src/main.rs b/examples/opnsense/src/main.rs index e868829..465b0fa 100644 --- a/examples/opnsense/src/main.rs +++ b/examples/opnsense/src/main.rs @@ -15,9 +15,10 @@ use harmony::{ opnsense::OPNsenseShellCommandScore, tftp::TftpScore, }, - topology::{LogicalHost, UnmanagedRouter, Url}, + topology::{LogicalHost, UnmanagedRouter}, }; use harmony_macros::{ip, mac_address}; +use harmony_types::net::Url; #[tokio::main] async fn main() { @@ -62,8 +63,7 @@ async fn main() { "wk".to_string(), ), switch: SwitchGroup::from([]), - firewall: FirewallGroup::from([PhysicalHost::empty(HostCategory::Firewall) - .management(Arc::new(OPNSenseManagementInterface::new()))]), + firewall_mgmt: Box::new(OPNSenseManagementInterface::new()), storage_host: vec![], worker_host: vec![], control_plane_host: vec![ diff --git a/examples/rust/src/main.rs b/examples/rust/src/main.rs index feb92ef..b361edd 100644 --- a/examples/rust/src/main.rs +++ b/examples/rust/src/main.rs @@ -11,8 +11,9 @@ use harmony::{ discord_alert_channel::DiscordWebhook, webhook_receiver::WebhookReceiver, }, }, - topology::{K8sAnywhereTopology, Url}, + topology::K8sAnywhereTopology, }; +use harmony_types::net::Url; #[tokio::main] async fn main() { diff --git a/examples/tenant/src/main.rs b/examples/tenant/src/main.rs index 356ad1b..1b0a3e4 100644 --- a/examples/tenant/src/main.rs +++ b/examples/tenant/src/main.rs @@ -1,11 +1,11 @@ use std::str::FromStr; use harmony::{ - data::Id, inventory::Inventory, modules::tenant::TenantScore, topology::{K8sAnywhereTopology, tenant::TenantConfig}, }; +use harmony_types::id::Id; #[tokio::main] async fn main() { diff --git a/harmony/Cargo.toml b/harmony/Cargo.toml index 26e5f71..07a2480 100644 --- a/harmony/Cargo.toml +++ b/harmony/Cargo.toml @@ -9,7 +9,6 @@ license.workspace = true testing = [] [dependencies] -rand = "0.9" hex = "0.4" reqwest = { version = "0.11", features = ["blocking", "json", "rustls-tls"], default-features = false } russh = "0.45.0" diff --git a/harmony/src/domain/config.rs b/harmony/src/domain/config.rs index 62f612f..1a91684 100644 --- a/harmony/src/domain/config.rs +++ b/harmony/src/domain/config.rs @@ -12,4 +12,12 @@ lazy_static! { std::env::var("HARMONY_REGISTRY_PROJECT").unwrap_or_else(|_| "harmony".to_string()); pub static ref DRY_RUN: bool = std::env::var("HARMONY_DRY_RUN").is_ok_and(|value| value.parse().unwrap_or(false)); + pub static ref DEFAULT_DATABASE_URL: String = "sqlite://harmony.sqlite".to_string(); + pub static ref DATABASE_URL: String = std::env::var("HARMONY_DATABASE_URL") + .map(|value| if value.is_empty() { + (*DEFAULT_DATABASE_URL).clone() + } else { + value + }) + .unwrap_or((*DEFAULT_DATABASE_URL).clone()); } diff --git a/harmony/src/domain/data/mod.rs b/harmony/src/domain/data/mod.rs index 8d90a52..10d6dc5 100644 --- a/harmony/src/domain/data/mod.rs +++ b/harmony/src/domain/data/mod.rs @@ -1,6 +1,4 @@ mod file; -mod id; mod version; pub use file::*; -pub use id::*; pub use version::*; diff --git a/harmony/src/domain/executors/mod.rs b/harmony/src/domain/executors/mod.rs index fb95701..19d0cad 100644 --- a/harmony/src/domain/executors/mod.rs +++ b/harmony/src/domain/executors/mod.rs @@ -1,8 +1,7 @@ use std::fmt; use async_trait::async_trait; - -use super::topology::IpAddress; +use harmony_types::net::IpAddress; #[derive(Debug)] pub enum ExecutorError { diff --git a/harmony/src/domain/hardware/mod.rs b/harmony/src/domain/hardware/mod.rs index d8d63df..3a14e1a 100644 --- a/harmony/src/domain/hardware/mod.rs +++ b/harmony/src/domain/hardware/mod.rs @@ -1,24 +1,24 @@ -use std::{str::FromStr, sync::Arc}; +use std::sync::Arc; use derive_new::new; +use harmony_inventory_agent::hwinfo::{CPU, MemoryModule, NetworkInterface, StorageDrive}; use harmony_types::net::MacAddress; -use serde::{Deserialize, Serialize, Serializer, ser::SerializeStruct}; +use serde::{Deserialize, Serialize}; use serde_value::Value; pub type HostGroup = Vec; pub type SwitchGroup = Vec; pub type FirewallGroup = Vec; -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize)] pub struct PhysicalHost { pub id: Id, pub category: HostCategory, pub network: Vec, - pub management: Arc, - pub storage: Vec, + pub storage: Vec, pub labels: Vec