diff --git a/src/api2/config/network.rs b/src/api2/config/network.rs index cfb82980..ecd6f9c6 100644 --- a/src/api2/config/network.rs +++ b/src/api2/config/network.rs @@ -4,7 +4,6 @@ use ::serde::{Deserialize, Serialize}; use proxmox::api::{api, ApiMethod, Router, RpcEnvironment, Permission}; -//use crate::api2::types::*; use crate::config::network; use crate::config::acl::{PRIV_SYS_AUDIT, PRIV_SYS_MODIFY}; use crate::api2::types::*; @@ -95,6 +94,8 @@ pub enum DeletableProperty { mtu_v4, /// Delete mtu IPv6. mtu_v6, + /// Delete auto flag + auto, } #[api( @@ -104,6 +105,11 @@ pub enum DeletableProperty { name: { schema: NETWORK_INTERFACE_NAME_SCHEMA, }, + auto: { + description: "Autostart interface.", + type: bool, + optional: true, + }, method_v4: { type: NetworkConfigMethod, optional: true, @@ -153,6 +159,7 @@ pub enum DeletableProperty { /// Update network interface config. pub fn update_interface( name: String, + auto: Option, method_v4: Option, method_v6: Option, address: Option, @@ -185,10 +192,12 @@ pub fn update_interface( DeletableProperty::method_v6 => { interface.method_v6 = None; }, DeletableProperty::mtu_v4 => { interface.mtu_v4 = None; }, DeletableProperty::mtu_v6 => { interface.mtu_v6 = None; }, + DeletableProperty::auto => { interface.auto = false; }, } } } + if let Some(auto) = auto { interface.auto = auto; } if method_v4.is_some() { interface.method_v4 = method_v4; } if method_v6.is_some() { interface.method_v6 = method_v6; } if mtu_v4.is_some() { interface.mtu_v4 = mtu_v4; } diff --git a/src/api2/types.rs b/src/api2/types.rs index 9385008d..6e94f59f 100644 --- a/src/api2/types.rs +++ b/src/api2/types.rs @@ -562,7 +562,7 @@ pub const NETWORK_INTERFACE_NAME_SCHEMA: Schema = StringSchema::new("Network int /// Network Interface configuration pub struct Interface { /// Autostart interface - pub autostart: bool, + pub auto: bool, /// Interface is a physical network device pub exists: bool, /// Interface is active (UP) diff --git a/src/config/network.rs b/src/config/network.rs index fb0c6d83..05dfe43c 100644 --- a/src/config/network.rs +++ b/src/config/network.rs @@ -21,7 +21,7 @@ impl Interface { pub fn new(name: String) -> Self { Self { name, - autostart: false, + auto: false, exists: false, active: false, method_v4: None, @@ -154,7 +154,7 @@ impl Interface { if self.method_v4.is_none() && self.method_v6.is_none() { return Ok(()); } - if self.autostart { + if self.auto { writeln!(w, "auto {}", self.name)?; } diff --git a/src/config/network/parser.rs b/src/config/network/parser.rs index 3ecae114..e0dc248f 100644 --- a/src/config/network/parser.rs +++ b/src/config/network/parser.rs @@ -282,7 +282,7 @@ impl NetworkParser { for iface in auto_flag.iter() { if let Some(interface) = config.interfaces.get_mut(iface) { - interface.autostart = true; + interface.auto = true; } }