feat(harmony): enhance PhysicalHost with builder methods and update dependencies
- Added builder methods to `PhysicalHost` for configuring CPU, memory size, storage, MAC address, labels, and management interface. - Updated the edition of various Cargo.toml files to 2024. - Implemented workspace inheritance for version, readme, and license fields in Cargo.toml files.
This commit is contained in:
parent
0cfd5dc89e
commit
3eac78c6d3
66
harmony-rs/Cargo.lock
generated
66
harmony-rs/Cargo.lock
generated
@ -794,6 +794,38 @@ dependencies = [
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "example-kube-rs"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cidr",
|
||||
"env_logger",
|
||||
"harmony",
|
||||
"harmony_macros",
|
||||
"http 1.2.0",
|
||||
"k8s-openapi",
|
||||
"kube",
|
||||
"log",
|
||||
"serde_yaml",
|
||||
"tokio",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "example-opnsense"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cidr",
|
||||
"env_logger",
|
||||
"harmony",
|
||||
"harmony_macros",
|
||||
"harmony_tui",
|
||||
"harmony_types",
|
||||
"log",
|
||||
"tokio",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "eyre"
|
||||
version = "0.6.12"
|
||||
@ -1101,7 +1133,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "harmony_macros"
|
||||
version = "1.0.0"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"harmony_types",
|
||||
"quote",
|
||||
@ -1127,7 +1159,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "harmony_types"
|
||||
version = "1.0.0"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
@ -3282,23 +3314,6 @@ dependencies = [
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "test-kube-rs"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cidr",
|
||||
"env_logger",
|
||||
"harmony",
|
||||
"harmony_macros",
|
||||
"http 1.2.0",
|
||||
"k8s-openapi",
|
||||
"kube",
|
||||
"log",
|
||||
"serde_yaml",
|
||||
"tokio",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.63"
|
||||
@ -3687,19 +3702,6 @@ version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65"
|
||||
|
||||
[[package]]
|
||||
name = "vbox-opnpsense"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cidr",
|
||||
"env_logger",
|
||||
"harmony",
|
||||
"harmony_macros",
|
||||
"log",
|
||||
"tokio",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vcpkg"
|
||||
version = "0.2.15"
|
||||
|
@ -2,7 +2,7 @@
|
||||
resolver = "2"
|
||||
members = [
|
||||
"private_repos/*",
|
||||
"demo/*",
|
||||
"examples/*",
|
||||
"harmony",
|
||||
"harmony_types",
|
||||
"harmony_macros",
|
||||
@ -39,7 +39,3 @@ features = [
|
||||
"fast-rng", # Use a faster (but still sufficiently random) RNG
|
||||
"macro-diagnostics", # Enable better diagnostics for compile-time UUIDs
|
||||
]
|
||||
|
||||
|
||||
#[workspace.target.x86_64-unknown-linux-gnu]
|
||||
#rustflags = ["-C", "link-arg=-fuse-ld=mold"]
|
||||
|
@ -1,15 +1,16 @@
|
||||
[package]
|
||||
name = "test-kube-rs"
|
||||
name = "example-kube-rs"
|
||||
edition = "2024"
|
||||
version.workspace = true
|
||||
readme.workspace = true
|
||||
license.workspace = true
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
harmony = { version = "0.1.0", path = "../../harmony" }
|
||||
cidr = { workspace = true }
|
||||
tokio = { workspace = true }
|
||||
harmony_macros = { version = "1.0.0", path = "../../harmony_macros" }
|
||||
harmony_macros = { path = "../../harmony_macros" }
|
||||
log = { workspace = true }
|
||||
env_logger = { workspace = true }
|
||||
url = { workspace = true }
|
@ -1,15 +1,18 @@
|
||||
[package]
|
||||
name = "vbox-opnpsense"
|
||||
name = "example-opnsense"
|
||||
edition = "2024"
|
||||
version.workspace = true
|
||||
readme.workspace = true
|
||||
license.workspace = true
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
harmony = { version = "0.1.0", path = "../../harmony" }
|
||||
harmony = { path = "../../harmony" }
|
||||
harmony_tui = { path = "../../harmony_tui" }
|
||||
harmony_types = { path = "../../harmony_types" }
|
||||
cidr = { workspace = true }
|
||||
tokio = { workspace = true }
|
||||
harmony_macros = { version = "1.0.0", path = "../../harmony_macros" }
|
||||
harmony_macros = { path = "../../harmony_macros" }
|
||||
log = { workspace = true }
|
||||
env_logger = { workspace = true }
|
||||
url = { workspace = true }
|
@ -11,6 +11,5 @@ Credentials are opnsense default (root/opnsense)
|
||||
Run the project with the correct ip address on the command line :
|
||||
|
||||
```bash
|
||||
cd demo/vbox-opnsense/
|
||||
cargo run 192.168.5.229
|
||||
cargo run -p example-opnsense -- 192.168.5.229
|
||||
```
|
@ -16,11 +16,10 @@ use harmony::{
|
||||
},
|
||||
topology::{LogicalHost, UnmanagedRouter, Url},
|
||||
};
|
||||
use harmony_macros::ip;
|
||||
use harmony_macros::{ip, mac_address};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
env_logger::init();
|
||||
|
||||
let firewall = harmony::topology::LogicalHost {
|
||||
ip: ip!("192.168.5.229"),
|
||||
@ -63,34 +62,32 @@ async fn main() {
|
||||
"wk".to_string(),
|
||||
),
|
||||
switch: SwitchGroup::from([]),
|
||||
firewall: FirewallGroup::from([PhysicalHost {
|
||||
category: HostCategory::Firewall,
|
||||
network: vec![],
|
||||
management: Arc::new(OPNSenseManagementInterface::new()),
|
||||
storage: vec![],
|
||||
labels: vec![],
|
||||
}]),
|
||||
worker_host: vec![],
|
||||
firewall: FirewallGroup::from([PhysicalHost::empty(HostCategory::Firewall)
|
||||
.management(Arc::new(OPNSenseManagementInterface::new()))]),
|
||||
storage_host: vec![],
|
||||
control_plane_host: vec![],
|
||||
worker_host: vec![],
|
||||
control_plane_host: vec![PhysicalHost::empty(HostCategory::Server).mac_address(mac_address!("08:00:27:62:EC:C3"))],
|
||||
};
|
||||
|
||||
// TODO regroup smaller scores in a larger one such as this
|
||||
// let okd_boostrap_preparation();
|
||||
|
||||
// let dhcp_score = OKDDhcpScore::new(&topology, &inventory);
|
||||
// let dns_score = OKDDnsScore::new(&topology);
|
||||
// let load_balancer_score =
|
||||
// harmony::modules::okd::load_balancer::OKDLoadBalancerScore::new(&topology);
|
||||
let dhcp_score = OKDDhcpScore::new(&topology, &inventory);
|
||||
let dns_score = OKDDnsScore::new(&topology);
|
||||
let load_balancer_score =
|
||||
harmony::modules::okd::load_balancer::OKDLoadBalancerScore::new(&topology);
|
||||
|
||||
let tftp_score = TftpScore::new(Url::LocalFolder("../../../watchguard/tftpboot".to_string()));
|
||||
let http_score = HttpScore::new(Url::LocalFolder(
|
||||
"../../../watchguard/pxe-http-files".to_string(),
|
||||
));
|
||||
let maestro = Maestro::new(inventory, topology);
|
||||
// maestro.interpret(dns_score).await.unwrap();
|
||||
// maestro.interpret(dhcp_score).await.unwrap();
|
||||
// maestro.interpret(load_balancer_score).await.unwrap();
|
||||
// maestro.interpret(tftp_score).await.unwrap();
|
||||
maestro.interpret(&http_score).await.unwrap();
|
||||
let mut maestro = Maestro::new(inventory, topology);
|
||||
maestro.register_all(vec![
|
||||
Box::new(dns_score),
|
||||
Box::new(dhcp_score),
|
||||
Box::new(load_balancer_score),
|
||||
Box::new(tftp_score),
|
||||
Box::new(http_score),
|
||||
]);
|
||||
harmony_tui::init(maestro).await.unwrap();
|
||||
}
|
@ -1,7 +1,9 @@
|
||||
[package]
|
||||
name = "harmony"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
version.workspace = true
|
||||
readme.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
[dependencies]
|
||||
libredfish = "0.1.1"
|
||||
|
@ -14,16 +14,20 @@ pub struct PhysicalHost {
|
||||
pub management: Arc<dyn ManagementInterface>,
|
||||
pub storage: Vec<Storage>,
|
||||
pub labels: Vec<Label>,
|
||||
pub memory_size: Option<u64>,
|
||||
pub cpu_count: Option<u64>,
|
||||
}
|
||||
|
||||
impl PhysicalHost {
|
||||
pub fn new_empty(category: HostCategory) -> Self {
|
||||
pub fn empty(category: HostCategory) -> Self {
|
||||
Self {
|
||||
category,
|
||||
network: vec![],
|
||||
storage: vec![],
|
||||
labels: vec![],
|
||||
management: Arc::new(ManualManagementInterface {}),
|
||||
memory_size: None,
|
||||
cpu_count: None,
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,6 +38,54 @@ impl PhysicalHost {
|
||||
.mac_address
|
||||
.clone()
|
||||
}
|
||||
|
||||
pub fn cpu(mut self, cpu_count: Option<u64>) -> Self {
|
||||
self.cpu_count = cpu_count;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn memory_size(mut self, memory_size: Option<u64>) -> Self {
|
||||
self.memory_size = memory_size;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn storage(
|
||||
mut self,
|
||||
connection: StorageConnectionType,
|
||||
kind: StorageKind,
|
||||
size: u64,
|
||||
serial: String,
|
||||
) -> Self {
|
||||
self.storage.push(Storage {
|
||||
connection,
|
||||
kind,
|
||||
size,
|
||||
serial,
|
||||
});
|
||||
self
|
||||
}
|
||||
|
||||
pub fn mac_address(mut self, mac_address: MacAddress) -> Self {
|
||||
self.network.push(NetworkInterface {
|
||||
name: None,
|
||||
mac_address,
|
||||
speed: None,
|
||||
});
|
||||
self
|
||||
}
|
||||
|
||||
pub fn label(mut self, name: String, value: String) -> Self {
|
||||
self.labels.push(Label {
|
||||
_name: name,
|
||||
_value: value,
|
||||
});
|
||||
self
|
||||
}
|
||||
|
||||
pub fn management(mut self, management: Arc<dyn ManagementInterface>) -> Self {
|
||||
self.management = management;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(new)]
|
||||
@ -72,9 +124,9 @@ pub enum HostCategory {
|
||||
|
||||
#[derive(Debug, new, Clone)]
|
||||
pub struct NetworkInterface {
|
||||
pub name: String,
|
||||
pub name: Option<String>,
|
||||
pub mac_address: MacAddress,
|
||||
pub speed: u64,
|
||||
pub speed: Option<u64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, new, Clone)]
|
||||
|
@ -1,7 +1,9 @@
|
||||
[package]
|
||||
name = "harmony_macros"
|
||||
edition = "2024"
|
||||
version = "1.0.0"
|
||||
version.workspace = true
|
||||
readme.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
[lib]
|
||||
proc-macro = true
|
||||
|
@ -1,7 +1,9 @@
|
||||
[package]
|
||||
name = "harmony_tui"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
version.workspace = true
|
||||
readme.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
[dependencies]
|
||||
harmony = { path = "../harmony" }
|
||||
|
@ -1,4 +1,6 @@
|
||||
[package]
|
||||
name = "harmony_types"
|
||||
edition = "2024"
|
||||
version = "1.0.0"
|
||||
version.workspace = true
|
||||
readme.workspace = true
|
||||
license.workspace = true
|
||||
|
Loading…
Reference in New Issue
Block a user