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,
|
schema: NETWORK_INTERFACE_LIST_SCHEMA,
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
|
bond_slaves: {
|
||||||
|
schema: NETWORK_INTERFACE_LIST_SCHEMA,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
)]
|
)]
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
@ -631,6 +635,9 @@ pub struct Interface {
|
|||||||
|
|
||||||
#[serde(skip_serializing_if="Option::is_none")]
|
#[serde(skip_serializing_if="Option::is_none")]
|
||||||
pub bridge_ports: Option<Vec<String>>,
|
pub bridge_ports: Option<Vec<String>>,
|
||||||
|
|
||||||
|
#[serde(skip_serializing_if="Option::is_none")]
|
||||||
|
pub bond_slaves: Option<Vec<String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Regression tests
|
// Regression tests
|
||||||
|
@ -34,6 +34,7 @@ impl Interface {
|
|||||||
options_v6: Vec::new(),
|
options_v6: Vec::new(),
|
||||||
mtu: None,
|
mtu: None,
|
||||||
bridge_ports: 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,
|
gateway_v6: _gateway_v6,
|
||||||
mtu: _mtu,
|
mtu: _mtu,
|
||||||
bridge_ports: _bridge_ports,
|
bridge_ports: _bridge_ports,
|
||||||
|
bond_slaves: _bond_slaves,
|
||||||
} => {
|
} => {
|
||||||
method_v4 == method_v6
|
method_v4 == method_v6
|
||||||
&& options_v4.is_empty()
|
&& options_v4.is_empty()
|
||||||
|
@ -23,6 +23,7 @@ pub enum Token {
|
|||||||
Attribute,
|
Attribute,
|
||||||
MTU,
|
MTU,
|
||||||
BridgePorts,
|
BridgePorts,
|
||||||
|
BondSlaves,
|
||||||
EOF,
|
EOF,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,6 +44,8 @@ lazy_static! {
|
|||||||
map.insert("mtu", Token::MTU);
|
map.insert("mtu", Token::MTU);
|
||||||
map.insert("bridge-ports", Token::BridgePorts);
|
map.insert("bridge-ports", Token::BridgePorts);
|
||||||
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
|
map
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -196,6 +196,12 @@ impl <R: BufRead> NetworkParser<R> {
|
|||||||
interface.bridge_ports = Some(ports);
|
interface.bridge_ports = Some(ports);
|
||||||
interface.interface_type = NetworkInterfaceType::Bridge;
|
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"),
|
Token::Netmask => bail!("netmask is deprecated and no longer supported"),
|
||||||
_ => {
|
_ => {
|
||||||
self.parse_iface_addon_attribute(interface)?;
|
self.parse_iface_addon_attribute(interface)?;
|
||||||
|
Loading…
Reference in New Issue
Block a user