src/config/network.rs: parse bond-slaves
This commit is contained in:
parent
1d9a68c2fc
commit
42fbe91a34
@ -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<Vec<String>>,
|
||||
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
pub bond_slaves: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
// Regression tests
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
};
|
||||
}
|
||||
|
@ -196,6 +196,12 @@ impl <R: BufRead> NetworkParser<R> {
|
||||
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)?;
|
||||
|
Loading…
Reference in New Issue
Block a user