src/api2/config/network.rs: allow to update 'auto' flag
This commit is contained in:
parent
3fce3bc36e
commit
f1026a5aa9
@ -4,7 +4,6 @@ use ::serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use proxmox::api::{api, ApiMethod, Router, RpcEnvironment, Permission};
|
use proxmox::api::{api, ApiMethod, Router, RpcEnvironment, Permission};
|
||||||
|
|
||||||
//use crate::api2::types::*;
|
|
||||||
use crate::config::network;
|
use crate::config::network;
|
||||||
use crate::config::acl::{PRIV_SYS_AUDIT, PRIV_SYS_MODIFY};
|
use crate::config::acl::{PRIV_SYS_AUDIT, PRIV_SYS_MODIFY};
|
||||||
use crate::api2::types::*;
|
use crate::api2::types::*;
|
||||||
@ -95,6 +94,8 @@ pub enum DeletableProperty {
|
|||||||
mtu_v4,
|
mtu_v4,
|
||||||
/// Delete mtu IPv6.
|
/// Delete mtu IPv6.
|
||||||
mtu_v6,
|
mtu_v6,
|
||||||
|
/// Delete auto flag
|
||||||
|
auto,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[api(
|
#[api(
|
||||||
@ -104,6 +105,11 @@ pub enum DeletableProperty {
|
|||||||
name: {
|
name: {
|
||||||
schema: NETWORK_INTERFACE_NAME_SCHEMA,
|
schema: NETWORK_INTERFACE_NAME_SCHEMA,
|
||||||
},
|
},
|
||||||
|
auto: {
|
||||||
|
description: "Autostart interface.",
|
||||||
|
type: bool,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
method_v4: {
|
method_v4: {
|
||||||
type: NetworkConfigMethod,
|
type: NetworkConfigMethod,
|
||||||
optional: true,
|
optional: true,
|
||||||
@ -153,6 +159,7 @@ pub enum DeletableProperty {
|
|||||||
/// Update network interface config.
|
/// Update network interface config.
|
||||||
pub fn update_interface(
|
pub fn update_interface(
|
||||||
name: String,
|
name: String,
|
||||||
|
auto: Option<bool>,
|
||||||
method_v4: Option<NetworkConfigMethod>,
|
method_v4: Option<NetworkConfigMethod>,
|
||||||
method_v6: Option<NetworkConfigMethod>,
|
method_v6: Option<NetworkConfigMethod>,
|
||||||
address: Option<String>,
|
address: Option<String>,
|
||||||
@ -185,10 +192,12 @@ pub fn update_interface(
|
|||||||
DeletableProperty::method_v6 => { interface.method_v6 = None; },
|
DeletableProperty::method_v6 => { interface.method_v6 = None; },
|
||||||
DeletableProperty::mtu_v4 => { interface.mtu_v4 = None; },
|
DeletableProperty::mtu_v4 => { interface.mtu_v4 = None; },
|
||||||
DeletableProperty::mtu_v6 => { interface.mtu_v6 = 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_v4.is_some() { interface.method_v4 = method_v4; }
|
||||||
if method_v6.is_some() { interface.method_v6 = method_v6; }
|
if method_v6.is_some() { interface.method_v6 = method_v6; }
|
||||||
if mtu_v4.is_some() { interface.mtu_v4 = mtu_v4; }
|
if mtu_v4.is_some() { interface.mtu_v4 = mtu_v4; }
|
||||||
|
@ -562,7 +562,7 @@ pub const NETWORK_INTERFACE_NAME_SCHEMA: Schema = StringSchema::new("Network int
|
|||||||
/// Network Interface configuration
|
/// Network Interface configuration
|
||||||
pub struct Interface {
|
pub struct Interface {
|
||||||
/// Autostart interface
|
/// Autostart interface
|
||||||
pub autostart: bool,
|
pub auto: bool,
|
||||||
/// Interface is a physical network device
|
/// Interface is a physical network device
|
||||||
pub exists: bool,
|
pub exists: bool,
|
||||||
/// Interface is active (UP)
|
/// Interface is active (UP)
|
||||||
|
@ -21,7 +21,7 @@ impl Interface {
|
|||||||
pub fn new(name: String) -> Self {
|
pub fn new(name: String) -> Self {
|
||||||
Self {
|
Self {
|
||||||
name,
|
name,
|
||||||
autostart: false,
|
auto: false,
|
||||||
exists: false,
|
exists: false,
|
||||||
active: false,
|
active: false,
|
||||||
method_v4: None,
|
method_v4: None,
|
||||||
@ -154,7 +154,7 @@ impl Interface {
|
|||||||
|
|
||||||
if self.method_v4.is_none() && self.method_v6.is_none() { return Ok(()); }
|
if self.method_v4.is_none() && self.method_v6.is_none() { return Ok(()); }
|
||||||
|
|
||||||
if self.autostart {
|
if self.auto {
|
||||||
writeln!(w, "auto {}", self.name)?;
|
writeln!(w, "auto {}", self.name)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,7 +282,7 @@ impl <R: BufRead> NetworkParser<R> {
|
|||||||
|
|
||||||
for iface in auto_flag.iter() {
|
for iface in auto_flag.iter() {
|
||||||
if let Some(interface) = config.interfaces.get_mut(iface) {
|
if let Some(interface) = config.interfaces.get_mut(iface) {
|
||||||
interface.autostart = true;
|
interface.auto = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user