src/api2/config/network.rs: implement update/delete comments
This commit is contained in:
parent
5f60a58fd5
commit
10a9be45bd
|
@ -90,6 +90,10 @@ pub enum DeletableProperty {
|
|||
method_v4,
|
||||
/// Delete the whole IPv6 configuration entry.
|
||||
method_v6,
|
||||
/// Delete IPv4 comments
|
||||
comments_v4,
|
||||
/// Delete IPv6 comments
|
||||
comments_v6,
|
||||
/// Delete mtu.
|
||||
mtu,
|
||||
/// Delete auto flag
|
||||
|
@ -121,6 +125,16 @@ pub enum DeletableProperty {
|
|||
type: NetworkConfigMethod,
|
||||
optional: true,
|
||||
},
|
||||
comments_v4: {
|
||||
description: "Comments (inet)",
|
||||
type: String,
|
||||
optional: true,
|
||||
},
|
||||
comments_v6: {
|
||||
description: "Comments (inet6)",
|
||||
type: String,
|
||||
optional: true,
|
||||
},
|
||||
address: {
|
||||
schema: CIDR_SCHEMA,
|
||||
optional: true,
|
||||
|
@ -168,6 +182,8 @@ pub fn update_interface(
|
|||
auto: Option<bool>,
|
||||
method_v4: Option<NetworkConfigMethod>,
|
||||
method_v6: Option<NetworkConfigMethod>,
|
||||
comments_v4: Option<String>,
|
||||
comments_v6: Option<String>,
|
||||
address: Option<String>,
|
||||
gateway: Option<String>,
|
||||
mtu: Option<u64>,
|
||||
|
@ -205,6 +221,8 @@ pub fn update_interface(
|
|||
DeletableProperty::gateway_v6 => { interface.gateway_v6 = None; },
|
||||
DeletableProperty::method_v4 => { interface.method_v4 = None; },
|
||||
DeletableProperty::method_v6 => { interface.method_v6 = None; },
|
||||
DeletableProperty::comments_v4 => { interface.comments_v4 = Vec::new(); },
|
||||
DeletableProperty::comments_v6 => { interface.comments_v6 = Vec::new(); },
|
||||
DeletableProperty::mtu => { interface.mtu = None; },
|
||||
DeletableProperty::auto => { interface.auto = false; },
|
||||
DeletableProperty::bridge_ports => { interface.set_bridge_ports(Vec::new())?; }
|
||||
|
@ -248,6 +266,14 @@ pub fn update_interface(
|
|||
}
|
||||
}
|
||||
|
||||
if let Some(comments) = comments_v4 {
|
||||
interface.comments_v4 = comments.lines().map(String::from).collect();
|
||||
}
|
||||
|
||||
if let Some(comments) = comments_v6 {
|
||||
interface.comments_v6 = comments.lines().map(String::from).collect();
|
||||
}
|
||||
|
||||
network::save_config(&config)?;
|
||||
|
||||
Ok(())
|
||||
|
|
Loading…
Reference in New Issue