diff --git a/src/api2/types.rs b/src/api2/types.rs index b5e8ad41..52752e4e 100644 --- a/src/api2/types.rs +++ b/src/api2/types.rs @@ -590,6 +590,10 @@ pub const NETWORK_INTERFACE_LIST_SCHEMA: Schema = ArraySchema::new( schema: NETWORK_INTERFACE_LIST_SCHEMA, optional: true, }, + bond_slaves: { + schema: NETWORK_INTERFACE_LIST_SCHEMA, + optional: true, + }, } )] #[derive(Debug, Serialize, Deserialize)] @@ -631,6 +635,9 @@ pub struct Interface { #[serde(skip_serializing_if="Option::is_none")] pub bridge_ports: Option>, + + #[serde(skip_serializing_if="Option::is_none")] + pub bond_slaves: Option>, } // Regression tests diff --git a/src/config/network.rs b/src/config/network.rs index 0d3490d9..2545810d 100644 --- a/src/config/network.rs +++ b/src/config/network.rs @@ -34,6 +34,7 @@ impl Interface { options_v6: Vec::new(), mtu: None, bridge_ports: None, + bond_slaves: None, } } @@ -112,6 +113,15 @@ impl Interface { } } } + NetworkInterfaceType::Bond => { + if let Some(ref slaves) = self.bond_slaves { + if slaves.is_empty() { + writeln!(w, " bond-slaves none")?; + } else { + writeln!(w, " bond-slaves {}", slaves.join(" "))?; + } + } + } _ => {} } @@ -178,6 +188,7 @@ impl Interface { gateway_v6: _gateway_v6, mtu: _mtu, bridge_ports: _bridge_ports, + bond_slaves: _bond_slaves, } => { method_v4 == method_v6 && options_v4.is_empty() diff --git a/src/config/network/lexer.rs b/src/config/network/lexer.rs index 0ec8fb5a..47ddb021 100644 --- a/src/config/network/lexer.rs +++ b/src/config/network/lexer.rs @@ -23,6 +23,7 @@ pub enum Token { Attribute, MTU, BridgePorts, + BondSlaves, EOF, } @@ -43,6 +44,8 @@ lazy_static! { map.insert("mtu", Token::MTU); map.insert("bridge-ports", Token::BridgePorts); map.insert("bridge_ports", Token::BridgePorts); + map.insert("bond-slaves", Token::BondSlaves); + map.insert("bond_slaves", Token::BondSlaves); map }; } diff --git a/src/config/network/parser.rs b/src/config/network/parser.rs index 0cb47670..d2595feb 100644 --- a/src/config/network/parser.rs +++ b/src/config/network/parser.rs @@ -196,6 +196,12 @@ impl NetworkParser { interface.bridge_ports = Some(ports); interface.interface_type = NetworkInterfaceType::Bridge; } + Token::BondSlaves => { + self.eat(Token::BondSlaves)?; + let slaves = self.parse_iface_list()?; + interface.bond_slaves = Some(slaves); + interface.interface_type = NetworkInterfaceType::Bond; + } Token::Netmask => bail!("netmask is deprecated and no longer supported"), _ => { self.parse_iface_addon_attribute(interface)?;