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,
|
method_v4,
|
||||||
/// Delete the whole IPv6 configuration entry.
|
/// Delete the whole IPv6 configuration entry.
|
||||||
method_v6,
|
method_v6,
|
||||||
|
/// Delete IPv4 comments
|
||||||
|
comments_v4,
|
||||||
|
/// Delete IPv6 comments
|
||||||
|
comments_v6,
|
||||||
/// Delete mtu.
|
/// Delete mtu.
|
||||||
mtu,
|
mtu,
|
||||||
/// Delete auto flag
|
/// Delete auto flag
|
||||||
@ -121,6 +125,16 @@ pub enum DeletableProperty {
|
|||||||
type: NetworkConfigMethod,
|
type: NetworkConfigMethod,
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
|
comments_v4: {
|
||||||
|
description: "Comments (inet)",
|
||||||
|
type: String,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
comments_v6: {
|
||||||
|
description: "Comments (inet6)",
|
||||||
|
type: String,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
address: {
|
address: {
|
||||||
schema: CIDR_SCHEMA,
|
schema: CIDR_SCHEMA,
|
||||||
optional: true,
|
optional: true,
|
||||||
@ -168,6 +182,8 @@ pub fn update_interface(
|
|||||||
auto: Option<bool>,
|
auto: Option<bool>,
|
||||||
method_v4: Option<NetworkConfigMethod>,
|
method_v4: Option<NetworkConfigMethod>,
|
||||||
method_v6: Option<NetworkConfigMethod>,
|
method_v6: Option<NetworkConfigMethod>,
|
||||||
|
comments_v4: Option<String>,
|
||||||
|
comments_v6: Option<String>,
|
||||||
address: Option<String>,
|
address: Option<String>,
|
||||||
gateway: Option<String>,
|
gateway: Option<String>,
|
||||||
mtu: Option<u64>,
|
mtu: Option<u64>,
|
||||||
@ -205,6 +221,8 @@ pub fn update_interface(
|
|||||||
DeletableProperty::gateway_v6 => { interface.gateway_v6 = None; },
|
DeletableProperty::gateway_v6 => { interface.gateway_v6 = None; },
|
||||||
DeletableProperty::method_v4 => { interface.method_v4 = None; },
|
DeletableProperty::method_v4 => { interface.method_v4 = None; },
|
||||||
DeletableProperty::method_v6 => { interface.method_v6 = 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::mtu => { interface.mtu = None; },
|
||||||
DeletableProperty::auto => { interface.auto = false; },
|
DeletableProperty::auto => { interface.auto = false; },
|
||||||
DeletableProperty::bridge_ports => { interface.set_bridge_ports(Vec::new())?; }
|
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)?;
|
network::save_config(&config)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
Loading…
Reference in New Issue
Block a user