diff --git a/Cargo.lock b/Cargo.lock index a787f9e..62d8aee 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2366,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", diff --git a/Cargo.toml b/Cargo.toml index 6be0aa9..d92c0e7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -67,4 +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 = ["stream", "rustls-tls", "http2"], default-features = false } +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/nanodc/src/main.rs b/examples/nanodc/src/main.rs index a8a17e3..a6bb8e4 100644 --- a/examples/nanodc/src/main.rs +++ b/examples/nanodc/src/main.rs @@ -87,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 3af30cf..465b0fa 100644 --- a/examples/opnsense/src/main.rs +++ b/examples/opnsense/src/main.rs @@ -63,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/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/hardware/mod.rs b/harmony/src/domain/hardware/mod.rs index 20c3596..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