forked from NationTech/harmony
		
	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", |  "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]] | [[package]] | ||||||
| name = "eyre" | name = "eyre" | ||||||
| version = "0.6.12" | version = "0.6.12" | ||||||
| @ -1101,7 +1133,7 @@ dependencies = [ | |||||||
| 
 | 
 | ||||||
| [[package]] | [[package]] | ||||||
| name = "harmony_macros" | name = "harmony_macros" | ||||||
| version = "1.0.0" | version = "0.1.0" | ||||||
| dependencies = [ | dependencies = [ | ||||||
|  "harmony_types", |  "harmony_types", | ||||||
|  "quote", |  "quote", | ||||||
| @ -1127,7 +1159,7 @@ dependencies = [ | |||||||
| 
 | 
 | ||||||
| [[package]] | [[package]] | ||||||
| name = "harmony_types" | name = "harmony_types" | ||||||
| version = "1.0.0" | version = "0.1.0" | ||||||
| 
 | 
 | ||||||
| [[package]] | [[package]] | ||||||
| name = "hashbrown" | name = "hashbrown" | ||||||
| @ -3282,23 +3314,6 @@ dependencies = [ | |||||||
|  "windows-sys 0.59.0", |  "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]] | [[package]] | ||||||
| name = "thiserror" | name = "thiserror" | ||||||
| version = "1.0.63" | version = "1.0.63" | ||||||
| @ -3687,19 +3702,6 @@ version = "0.1.1" | |||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
| checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" | checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" | ||||||
| 
 | 
 | ||||||
| [[package]] |  | ||||||
| name = "vbox-opnpsense" |  | ||||||
| version = "0.1.0" |  | ||||||
| dependencies = [ |  | ||||||
|  "cidr", |  | ||||||
|  "env_logger", |  | ||||||
|  "harmony", |  | ||||||
|  "harmony_macros", |  | ||||||
|  "log", |  | ||||||
|  "tokio", |  | ||||||
|  "url", |  | ||||||
| ] |  | ||||||
| 
 |  | ||||||
| [[package]] | [[package]] | ||||||
| name = "vcpkg" | name = "vcpkg" | ||||||
| version = "0.2.15" | version = "0.2.15" | ||||||
|  | |||||||
| @ -2,7 +2,7 @@ | |||||||
| resolver = "2" | resolver = "2" | ||||||
| members = [ | members = [ | ||||||
|   "private_repos/*", |   "private_repos/*", | ||||||
|   "demo/*", |   "examples/*", | ||||||
|   "harmony", |   "harmony", | ||||||
|   "harmony_types", |   "harmony_types", | ||||||
|   "harmony_macros", |   "harmony_macros", | ||||||
| @ -39,7 +39,3 @@ features = [ | |||||||
|     "fast-rng",          # Use a faster (but still sufficiently random) RNG |     "fast-rng",          # Use a faster (but still sufficiently random) RNG | ||||||
|     "macro-diagnostics", # Enable better diagnostics for compile-time UUIDs |     "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] | [package] | ||||||
| name = "test-kube-rs" | name = "example-kube-rs" | ||||||
| edition = "2024" | edition = "2024" | ||||||
| version.workspace = true | version.workspace = true | ||||||
| readme.workspace = true | readme.workspace = true | ||||||
| license.workspace = true | license.workspace = true | ||||||
|  | publish = false | ||||||
| 
 | 
 | ||||||
| [dependencies] | [dependencies] | ||||||
| harmony = { version = "0.1.0", path = "../../harmony" } | harmony = { version = "0.1.0", path = "../../harmony" } | ||||||
| cidr = { workspace = true } | cidr = { workspace = true } | ||||||
| tokio = { workspace = true } | tokio = { workspace = true } | ||||||
| harmony_macros = { version = "1.0.0", path = "../../harmony_macros" } | harmony_macros = { path = "../../harmony_macros" } | ||||||
| log = { workspace = true } | log = { workspace = true } | ||||||
| env_logger = { workspace = true } | env_logger = { workspace = true } | ||||||
| url = { workspace = true } | url = { workspace = true } | ||||||
| @ -1,15 +1,18 @@ | |||||||
| [package] | [package] | ||||||
| name = "vbox-opnpsense" | name = "example-opnsense" | ||||||
| edition = "2024" | edition = "2024" | ||||||
| version.workspace = true | version.workspace = true | ||||||
| readme.workspace = true | readme.workspace = true | ||||||
| license.workspace = true | license.workspace = true | ||||||
|  | publish = false | ||||||
| 
 | 
 | ||||||
| [dependencies] | [dependencies] | ||||||
| harmony = { version = "0.1.0", path = "../../harmony" } | harmony = { path = "../../harmony" } | ||||||
|  | harmony_tui = { path = "../../harmony_tui" } | ||||||
|  | harmony_types = { path = "../../harmony_types" } | ||||||
| cidr = { workspace = true } | cidr = { workspace = true } | ||||||
| tokio = { workspace = true } | tokio = { workspace = true } | ||||||
| harmony_macros = { version = "1.0.0", path = "../../harmony_macros" } | harmony_macros = { path = "../../harmony_macros" } | ||||||
| log = { workspace = true } | log = { workspace = true } | ||||||
| env_logger = { workspace = true } | env_logger = { workspace = true } | ||||||
| url = { 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 : | Run the project with the correct ip address on the command line : | ||||||
| 
 | 
 | ||||||
| ```bash | ```bash | ||||||
| cd demo/vbox-opnsense/ | cargo run -p example-opnsense -- 192.168.5.229 | ||||||
| cargo run 192.168.5.229 |  | ||||||
| ``` | ``` | ||||||
| @ -16,11 +16,10 @@ use harmony::{ | |||||||
|     }, |     }, | ||||||
|     topology::{LogicalHost, UnmanagedRouter, Url}, |     topology::{LogicalHost, UnmanagedRouter, Url}, | ||||||
| }; | }; | ||||||
| use harmony_macros::ip; | use harmony_macros::{ip, mac_address}; | ||||||
| 
 | 
 | ||||||
| #[tokio::main] | #[tokio::main] | ||||||
| async fn main() { | async fn main() { | ||||||
|     env_logger::init(); |  | ||||||
| 
 | 
 | ||||||
|     let firewall = harmony::topology::LogicalHost { |     let firewall = harmony::topology::LogicalHost { | ||||||
|         ip: ip!("192.168.5.229"), |         ip: ip!("192.168.5.229"), | ||||||
| @ -63,34 +62,32 @@ async fn main() { | |||||||
|             "wk".to_string(), |             "wk".to_string(), | ||||||
|         ), |         ), | ||||||
|         switch: SwitchGroup::from([]), |         switch: SwitchGroup::from([]), | ||||||
|         firewall: FirewallGroup::from([PhysicalHost { |         firewall: FirewallGroup::from([PhysicalHost::empty(HostCategory::Firewall) | ||||||
|             category: HostCategory::Firewall, |             .management(Arc::new(OPNSenseManagementInterface::new()))]), | ||||||
|             network: vec![], |  | ||||||
|             management: Arc::new(OPNSenseManagementInterface::new()), |  | ||||||
|             storage: vec![], |  | ||||||
|             labels: vec![], |  | ||||||
|         }]), |  | ||||||
|         worker_host: vec![], |  | ||||||
|         storage_host: vec![], |         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
 |     // TODO regroup smaller scores in a larger one such as this
 | ||||||
|     // let okd_boostrap_preparation();
 |     // let okd_boostrap_preparation();
 | ||||||
| 
 | 
 | ||||||
|     // let dhcp_score = OKDDhcpScore::new(&topology, &inventory);
 |     let dhcp_score = OKDDhcpScore::new(&topology, &inventory); | ||||||
|     // let dns_score = OKDDnsScore::new(&topology);
 |     let dns_score = OKDDnsScore::new(&topology); | ||||||
|     // let load_balancer_score =
 |     let load_balancer_score = | ||||||
|     //     harmony::modules::okd::load_balancer::OKDLoadBalancerScore::new(&topology);
 |         harmony::modules::okd::load_balancer::OKDLoadBalancerScore::new(&topology); | ||||||
| 
 | 
 | ||||||
|     let tftp_score = TftpScore::new(Url::LocalFolder("../../../watchguard/tftpboot".to_string())); |     let tftp_score = TftpScore::new(Url::LocalFolder("../../../watchguard/tftpboot".to_string())); | ||||||
|     let http_score = HttpScore::new(Url::LocalFolder( |     let http_score = HttpScore::new(Url::LocalFolder( | ||||||
|         "../../../watchguard/pxe-http-files".to_string(), |         "../../../watchguard/pxe-http-files".to_string(), | ||||||
|     )); |     )); | ||||||
|     let maestro = Maestro::new(inventory, topology); |     let mut maestro = Maestro::new(inventory, topology); | ||||||
|     // maestro.interpret(dns_score).await.unwrap();
 |     maestro.register_all(vec![ | ||||||
|     // maestro.interpret(dhcp_score).await.unwrap();
 |         Box::new(dns_score), | ||||||
|     // maestro.interpret(load_balancer_score).await.unwrap();
 |         Box::new(dhcp_score), | ||||||
|     // maestro.interpret(tftp_score).await.unwrap();
 |         Box::new(load_balancer_score), | ||||||
|     maestro.interpret(&http_score).await.unwrap(); |         Box::new(tftp_score), | ||||||
|  |         Box::new(http_score), | ||||||
|  |     ]); | ||||||
|  |     harmony_tui::init(maestro).await.unwrap(); | ||||||
| } | } | ||||||
| @ -1,7 +1,9 @@ | |||||||
| [package] | [package] | ||||||
| name = "harmony" | name = "harmony" | ||||||
| version = "0.1.0" | edition = "2024" | ||||||
| edition = "2021" | version.workspace = true | ||||||
|  | readme.workspace = true | ||||||
|  | license.workspace = true | ||||||
| 
 | 
 | ||||||
| [dependencies] | [dependencies] | ||||||
| libredfish = "0.1.1" | libredfish = "0.1.1" | ||||||
|  | |||||||
| @ -14,16 +14,20 @@ pub struct PhysicalHost { | |||||||
|     pub management: Arc<dyn ManagementInterface>, |     pub management: Arc<dyn ManagementInterface>, | ||||||
|     pub storage: Vec<Storage>, |     pub storage: Vec<Storage>, | ||||||
|     pub labels: Vec<Label>, |     pub labels: Vec<Label>, | ||||||
|  |     pub memory_size: Option<u64>, | ||||||
|  |     pub cpu_count: Option<u64>, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| impl PhysicalHost { | impl PhysicalHost { | ||||||
|     pub fn new_empty(category: HostCategory) -> Self { |     pub fn empty(category: HostCategory) -> Self { | ||||||
|         Self { |         Self { | ||||||
|             category, |             category, | ||||||
|             network: vec![], |             network: vec![], | ||||||
|             storage: vec![], |             storage: vec![], | ||||||
|             labels: vec![], |             labels: vec![], | ||||||
|             management: Arc::new(ManualManagementInterface {}), |             management: Arc::new(ManualManagementInterface {}), | ||||||
|  |             memory_size: None, | ||||||
|  |             cpu_count: None, | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -34,6 +38,54 @@ impl PhysicalHost { | |||||||
|             .mac_address |             .mac_address | ||||||
|             .clone() |             .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)] | #[derive(new)] | ||||||
| @ -72,9 +124,9 @@ pub enum HostCategory { | |||||||
| 
 | 
 | ||||||
| #[derive(Debug, new, Clone)] | #[derive(Debug, new, Clone)] | ||||||
| pub struct NetworkInterface { | pub struct NetworkInterface { | ||||||
|     pub name: String, |     pub name: Option<String>, | ||||||
|     pub mac_address: MacAddress, |     pub mac_address: MacAddress, | ||||||
|     pub speed: u64, |     pub speed: Option<u64>, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #[derive(Debug, new, Clone)] | #[derive(Debug, new, Clone)] | ||||||
|  | |||||||
| @ -1,7 +1,9 @@ | |||||||
| [package] | [package] | ||||||
| name = "harmony_macros" | name = "harmony_macros" | ||||||
| edition = "2024" | edition = "2024" | ||||||
| version = "1.0.0" | version.workspace = true | ||||||
|  | readme.workspace = true | ||||||
|  | license.workspace = true | ||||||
| 
 | 
 | ||||||
| [lib] | [lib] | ||||||
| proc-macro = true | proc-macro = true | ||||||
|  | |||||||
| @ -1,7 +1,9 @@ | |||||||
| [package] | [package] | ||||||
| name = "harmony_tui" | name = "harmony_tui" | ||||||
| version = "0.1.0" | edition = "2024" | ||||||
| edition = "2021" | version.workspace = true | ||||||
|  | readme.workspace = true | ||||||
|  | license.workspace = true | ||||||
| 
 | 
 | ||||||
| [dependencies] | [dependencies] | ||||||
| harmony = { path = "../harmony" } | harmony = { path = "../harmony" } | ||||||
|  | |||||||
| @ -1,4 +1,6 @@ | |||||||
| [package] | [package] | ||||||
| name = "harmony_types" | name = "harmony_types" | ||||||
| edition = "2024" | edition = "2024" | ||||||
| version = "1.0.0" | version.workspace = true | ||||||
|  | readme.workspace = true | ||||||
|  | license.workspace = true | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user