Compare commits

...

2 Commits

Author SHA1 Message Date
734c9704ab feat: provide an unmanaged switch 2025-11-11 13:30:03 -05:00
83c1cc82b6 fix(host_network): remove extra fields from bond config to prevent clashes (#186)
Also alias `port` to support both `port` and `ports` as per the nmstate spec.

Reviewed-on: NationTech/harmony#186
2025-11-11 14:12:56 +00:00
4 changed files with 42 additions and 4 deletions

View File

@@ -113,6 +113,37 @@ impl SwitchClient for BrocadeSwitchClient {
}
}
#[derive(Debug)]
pub struct UnmanagedSwitch;
impl UnmanagedSwitch {
pub async fn init( ) -> Result<Self, ()> {
Ok(Self)
}
}
#[async_trait]
impl SwitchClient for UnmanagedSwitch {
async fn setup(&self) -> Result<(), SwitchError> {
todo!("unmanaged switch. Nothing to do.")
}
async fn find_port(
&self,
mac_address: &MacAddress,
) -> Result<Option<PortLocation>, SwitchError> {
todo!("unmanaged switch. Nothing to do.")
}
async fn configure_port_channel(
&self,
channel_name: &str,
switch_ports: Vec<PortLocation>,
) -> Result<u8, SwitchError> {
todo!("unmanaged switch. Nothing to do.")
}
}
#[cfg(test)]
mod tests {
use std::sync::{Arc, Mutex};

View File

@@ -135,8 +135,6 @@ impl OpenShiftNmStateNetworkManager {
description: Some(format!("Member of bond {bond_name}")),
r#type: nmstate::InterfaceType::Ethernet,
state: "up".to_string(),
mtu: Some(switch_port.interface.mtu),
mac_address: Some(switch_port.interface.mac_address.to_string()),
ipv4: Some(nmstate::IpStackSpec {
enabled: Some(false),
..Default::default()
@@ -162,7 +160,7 @@ impl OpenShiftNmStateNetworkManager {
interfaces.push(nmstate::Interface {
name: bond_name.to_string(),
description: Some(format!("Network bond for host {host}")),
description: Some(format!("HARMONY - Network bond for host {host}")),
r#type: nmstate::InterfaceType::Bond,
state: "up".to_string(),
copy_mac_from,

View File

@@ -417,6 +417,7 @@ pub struct EthernetSpec {
#[serde(rename_all = "kebab-case")]
pub struct BondSpec {
pub mode: String,
#[serde(alias = "port")]
pub ports: Vec<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub options: Option<BTreeMap<String, Value>>,

View File

@@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize, PartialOrd, Ord)]
#[derive(Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, PartialOrd, Ord)]
pub struct MacAddress(pub [u8; 6]);
impl MacAddress {
@@ -19,6 +19,14 @@ impl From<&MacAddress> for String {
}
}
impl std::fmt::Debug for MacAddress {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_tuple("MacAddress")
.field(&String::from(self))
.finish()
}
}
impl std::fmt::Display for MacAddress {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(&String::from(self))