From 27f2c23049a2b3e06f501fb456af437237bd7558 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 22 Apr 2020 11:32:36 +0200 Subject: [PATCH] src/api2/config/network.rs: allow to update configuration method --- src/api2/config/network.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/api2/config/network.rs b/src/api2/config/network.rs index 69df0670..9c348513 100644 --- a/src/api2/config/network.rs +++ b/src/api2/config/network.rs @@ -80,6 +80,14 @@ pub fn read_interface(name: String) -> Result { name: { schema: NETWORK_INTERFACE_NAME_SCHEMA, }, + method_v4: { + type: NetworkConfigMethod, + optional: true, + }, + method_v6: { + type: NetworkConfigMethod, + optional: true, + }, address: { schema: CIDR_SCHEMA, optional: true, @@ -101,6 +109,8 @@ pub fn read_interface(name: String) -> Result { /// Update network interface config. pub fn update_interface( name: String, + method_v4: Option, + method_v6: Option, address: Option, gateway: Option, digest: Option, @@ -117,6 +127,9 @@ pub fn update_interface( let interface = config.lookup_mut(&name)?; + if method_v4.is_some() { interface.method_v4 = method_v4; } + if method_v6.is_some() { interface.method_v6 = method_v6; } + if let Some(address) = address { let (_, _, is_v6) = network::parse_cidr(&address)?; if is_v6 {