From a2055c38fe033cd02bcc6ed093ad1c7d2fcf360c Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Thu, 5 Jan 2023 10:57:11 +0100 Subject: [PATCH] fix non-camel-case enums This should have never been started to begin with... --- pbs-api-types/src/network.rs | 48 +++++++++++++++------ pbs-config/src/network/mod.rs | 34 +++------------ src/api2/access/user.rs | 17 ++++---- src/api2/config/access/openid.rs | 25 ++++++----- src/api2/config/acme.rs | 9 ++-- src/api2/config/changer.rs | 5 +-- src/api2/config/datastore.rs | 57 ++++++++++++------------ src/api2/config/drive.rs | 9 ++-- src/api2/config/media_pool.rs | 21 +++++---- src/api2/config/remote.rs | 13 +++--- src/api2/config/sync.rs | 49 +++++++++++---------- src/api2/config/traffic_control.rs | 25 ++++++----- src/api2/node/config.rs | 53 +++++++++++------------ src/api2/node/dns.rs | 13 +++--- src/api2/node/network.rs | 69 +++++++++++++++--------------- 15 files changed, 217 insertions(+), 230 deletions(-) diff --git a/pbs-api-types/src/network.rs b/pbs-api-types/src/network.rs index 4b0671c5..361c20e4 100644 --- a/pbs-api-types/src/network.rs +++ b/pbs-api-types/src/network.rs @@ -1,3 +1,5 @@ +use std::fmt; + use serde::{Deserialize, Serialize}; use proxmox_schema::*; @@ -59,42 +61,64 @@ pub enum NetworkConfigMethod { #[api()] #[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "kebab-case")] -#[allow(non_camel_case_types)] #[repr(u8)] /// Linux Bond Mode pub enum LinuxBondMode { /// Round-robin policy - balance_rr = 0, + BalanceRr = 0, /// Active-backup policy - active_backup = 1, + ActiveBackup = 1, /// XOR policy - balance_xor = 2, + BalanceXor = 2, /// Broadcast policy - broadcast = 3, + Broadcast = 3, /// IEEE 802.3ad Dynamic link aggregation #[serde(rename = "802.3ad")] - ieee802_3ad = 4, + Ieee802_3ad = 4, /// Adaptive transmit load balancing - balance_tlb = 5, + BalanceTlb = 5, /// Adaptive load balancing - balance_alb = 6, + BalanceAlb = 6, +} + +impl fmt::Display for LinuxBondMode { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_str(match self { + LinuxBondMode::BalanceRr => "balance-rr", + LinuxBondMode::ActiveBackup => "active-backup", + LinuxBondMode::BalanceXor => "balance-xor", + LinuxBondMode::Broadcast => "broadcast", + LinuxBondMode::Ieee802_3ad => "802.3ad", + LinuxBondMode::BalanceTlb => "balance-tlb", + LinuxBondMode::BalanceAlb => "balance-alb", + }) + } } #[api()] #[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "kebab-case")] -#[allow(non_camel_case_types)] #[repr(u8)] /// Bond Transmit Hash Policy for LACP (802.3ad) pub enum BondXmitHashPolicy { /// Layer 2 - layer2 = 0, + Layer2 = 0, /// Layer 2+3 #[serde(rename = "layer2+3")] - layer2_3 = 1, + Layer2_3 = 1, /// Layer 3+4 #[serde(rename = "layer3+4")] - layer3_4 = 2, + Layer3_4 = 2, +} + +impl fmt::Display for BondXmitHashPolicy { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_str(match self { + BondXmitHashPolicy::Layer2 => "layer2", + BondXmitHashPolicy::Layer2_3 => "layer2+3", + BondXmitHashPolicy::Layer3_4 => "layer3+4", + }) + } } #[api()] diff --git a/pbs-config/src/network/mod.rs b/pbs-config/src/network/mod.rs index a05a554d..e2008b7c 100644 --- a/pbs-config/src/network/mod.rs +++ b/pbs-config/src/network/mod.rs @@ -36,31 +36,11 @@ pub fn bond_mode_from_str(s: &str) -> Result { .map_err(|_: value::Error| format_err!("invalid bond_mode '{}'", s)) } -pub fn bond_mode_to_str(mode: LinuxBondMode) -> &'static str { - match mode { - LinuxBondMode::balance_rr => "balance-rr", - LinuxBondMode::active_backup => "active-backup", - LinuxBondMode::balance_xor => "balance-xor", - LinuxBondMode::broadcast => "broadcast", - LinuxBondMode::ieee802_3ad => "802.3ad", - LinuxBondMode::balance_tlb => "balance-tlb", - LinuxBondMode::balance_alb => "balance-alb", - } -} - pub fn bond_xmit_hash_policy_from_str(s: &str) -> Result { BondXmitHashPolicy::deserialize(s.into_deserializer()) .map_err(|_: value::Error| format_err!("invalid bond_xmit_hash_policy '{}'", s)) } -pub fn bond_xmit_hash_policy_to_str(policy: &BondXmitHashPolicy) -> &'static str { - match policy { - BondXmitHashPolicy::layer2 => "layer2", - BondXmitHashPolicy::layer2_3 => "layer2+3", - BondXmitHashPolicy::layer3_4 => "layer3+4", - } -} - // Write attributes not depending on address family fn write_iface_attributes(iface: &Interface, w: &mut dyn Write) -> Result<(), Error> { static EMPTY_LIST: Vec = Vec::new(); @@ -78,21 +58,17 @@ fn write_iface_attributes(iface: &Interface, w: &mut dyn Write) -> Result<(), Er } } NetworkInterfaceType::Bond => { - let mode = iface.bond_mode.unwrap_or(LinuxBondMode::balance_rr); - writeln!(w, "\tbond-mode {}", bond_mode_to_str(mode))?; + let mode = iface.bond_mode.unwrap_or(LinuxBondMode::BalanceRr); + writeln!(w, "\tbond-mode {mode}")?; if let Some(primary) = &iface.bond_primary { - if mode == LinuxBondMode::active_backup { + if mode == LinuxBondMode::ActiveBackup { writeln!(w, "\tbond-primary {}", primary)?; } } if let Some(xmit_policy) = &iface.bond_xmit_hash_policy { - if mode == LinuxBondMode::ieee802_3ad || mode == LinuxBondMode::balance_xor { - writeln!( - w, - "\tbond_xmit_hash_policy {}", - bond_xmit_hash_policy_to_str(xmit_policy) - )?; + if mode == LinuxBondMode::Ieee802_3ad || mode == LinuxBondMode::BalanceXor { + writeln!(w, "\tbond_xmit_hash_policy {xmit_policy}")?; } } diff --git a/src/api2/access/user.rs b/src/api2/access/user.rs index 2264f8e8..62d9d697 100644 --- a/src/api2/access/user.rs +++ b/src/api2/access/user.rs @@ -189,16 +189,15 @@ pub fn read_user(userid: Userid, rpcenv: &mut dyn RpcEnvironment) -> Result data.comment = None, - DeletableProperty::firstname => data.firstname = None, - DeletableProperty::lastname => data.lastname = None, - DeletableProperty::email => data.email = None, + DeletableProperty::Comment => data.comment = None, + DeletableProperty::Firstname => data.firstname = None, + DeletableProperty::Lastname => data.lastname = None, + DeletableProperty::Email => data.email = None, } } } diff --git a/src/api2/config/access/openid.rs b/src/api2/config/access/openid.rs index 92cc6685..bb39b574 100644 --- a/src/api2/config/access/openid.rs +++ b/src/api2/config/access/openid.rs @@ -146,21 +146,20 @@ pub fn read_openid_realm( #[api()] #[derive(Serialize, Deserialize)] #[serde(rename_all = "kebab-case")] -#[allow(non_camel_case_types)] /// Deletable property name pub enum DeletableProperty { /// Delete the client key. - client_key, + ClientKey, /// Delete the comment property. - comment, + Comment, /// Delete the autocreate property - autocreate, + Autocreate, /// Delete the scopes property - scopes, + Scopes, /// Delete the prompt property - prompt, + Prompt, /// Delete the acr_values property - acr_values, + AcrValues, } #[api( @@ -215,22 +214,22 @@ pub fn update_openid_realm( if let Some(delete) = delete { for delete_prop in delete { match delete_prop { - DeletableProperty::client_key => { + DeletableProperty::ClientKey => { config.client_key = None; } - DeletableProperty::comment => { + DeletableProperty::Comment => { config.comment = None; } - DeletableProperty::autocreate => { + DeletableProperty::Autocreate => { config.autocreate = None; } - DeletableProperty::scopes => { + DeletableProperty::Scopes => { config.scopes = None; } - DeletableProperty::prompt => { + DeletableProperty::Prompt => { config.prompt = None; } - DeletableProperty::acr_values => { + DeletableProperty::AcrValues => { config.acr_values = None; } } diff --git a/src/api2/config/acme.rs b/src/api2/config/acme.rs index b1fa7a0a..3ea18493 100644 --- a/src/api2/config/acme.rs +++ b/src/api2/config/acme.rs @@ -633,13 +633,12 @@ pub fn delete_plugin(id: String) -> Result<(), Error> { #[api()] #[derive(Serialize, Deserialize)] #[serde(rename_all = "kebab-case")] -#[allow(non_camel_case_types)] /// Deletable property name pub enum DeletableProperty { /// Delete the disable property - disable, + Disable, /// Delete the validation-delay property - validation_delay, + ValidationDelay, } #[api( @@ -711,10 +710,10 @@ pub fn update_plugin( if let Some(delete) = delete { for delete_prop in delete { match delete_prop { - DeletableProperty::validation_delay => { + DeletableProperty::ValidationDelay => { plugin.core.validation_delay = None; } - DeletableProperty::disable => { + DeletableProperty::Disable => { plugin.core.disable = None; } } diff --git a/src/api2/config/changer.rs b/src/api2/config/changer.rs index 8bd99848..01908e3b 100644 --- a/src/api2/config/changer.rs +++ b/src/api2/config/changer.rs @@ -133,12 +133,11 @@ pub fn list_changers( } #[api()] #[derive(Serialize, Deserialize)] -#[allow(non_camel_case_types)] #[serde(rename_all = "kebab-case")] /// Deletable property name pub enum DeletableProperty { /// Delete export-slots. - export_slots, + ExportSlots, } #[api( @@ -192,7 +191,7 @@ pub fn update_changer( if let Some(delete) = delete { for delete_prop in delete { match delete_prop { - DeletableProperty::export_slots => { + DeletableProperty::ExportSlots => { data.export_slots = None; } } diff --git a/src/api2/config/datastore.rs b/src/api2/config/datastore.rs index 677650b9..5e013c39 100644 --- a/src/api2/config/datastore.rs +++ b/src/api2/config/datastore.rs @@ -165,37 +165,36 @@ pub fn read_datastore( #[api()] #[derive(Serialize, Deserialize)] #[serde(rename_all = "kebab-case")] -#[allow(non_camel_case_types)] /// Deletable property name pub enum DeletableProperty { /// Delete the comment property. - comment, + Comment, /// Delete the garbage collection schedule. - gc_schedule, + GcSchedule, /// Delete the prune job schedule. - prune_schedule, + PruneSchedule, /// Delete the keep-last property - keep_last, + KeepLast, /// Delete the keep-hourly property - keep_hourly, + KeepHourly, /// Delete the keep-daily property - keep_daily, + KeepDaily, /// Delete the keep-weekly property - keep_weekly, + KeepWeekly, /// Delete the keep-monthly property - keep_monthly, + KeepMonthly, /// Delete the keep-yearly property - keep_yearly, + KeepYearly, /// Delete the verify-new property - verify_new, + VerifyNew, /// Delete the notify-user property - notify_user, + NotifyUser, /// Delete the notify property - notify, + Notify, /// Delete the tuning property - tuning, + Tuning, /// Delete the maintenance-mode property - maintenance_mode, + MaintenanceMode, } #[api( @@ -249,46 +248,46 @@ pub fn update_datastore( if let Some(delete) = delete { for delete_prop in delete { match delete_prop { - DeletableProperty::comment => { + DeletableProperty::Comment => { data.comment = None; } - DeletableProperty::gc_schedule => { + DeletableProperty::GcSchedule => { data.gc_schedule = None; } - DeletableProperty::prune_schedule => { + DeletableProperty::PruneSchedule => { data.prune_schedule = None; } - DeletableProperty::keep_last => { + DeletableProperty::KeepLast => { data.keep.keep_last = None; } - DeletableProperty::keep_hourly => { + DeletableProperty::KeepHourly => { data.keep.keep_hourly = None; } - DeletableProperty::keep_daily => { + DeletableProperty::KeepDaily => { data.keep.keep_daily = None; } - DeletableProperty::keep_weekly => { + DeletableProperty::KeepWeekly => { data.keep.keep_weekly = None; } - DeletableProperty::keep_monthly => { + DeletableProperty::KeepMonthly => { data.keep.keep_monthly = None; } - DeletableProperty::keep_yearly => { + DeletableProperty::KeepYearly => { data.keep.keep_yearly = None; } - DeletableProperty::verify_new => { + DeletableProperty::VerifyNew => { data.verify_new = None; } - DeletableProperty::notify => { + DeletableProperty::Notify => { data.notify = None; } - DeletableProperty::notify_user => { + DeletableProperty::NotifyUser => { data.notify_user = None; } - DeletableProperty::tuning => { + DeletableProperty::Tuning => { data.tuning = None; } - DeletableProperty::maintenance_mode => { + DeletableProperty::MaintenanceMode => { data.maintenance_mode = None; } } diff --git a/src/api2/config/drive.rs b/src/api2/config/drive.rs index 5de84d0f..02589aaf 100644 --- a/src/api2/config/drive.rs +++ b/src/api2/config/drive.rs @@ -134,14 +134,13 @@ pub fn list_drives( #[api()] #[derive(Serialize, Deserialize)] -#[allow(non_camel_case_types)] #[serde(rename_all = "kebab-case")] /// Deletable property name pub enum DeletableProperty { /// Delete the changer property. - changer, + Changer, /// Delete the changer-drivenum property. - changer_drivenum, + ChangerDrivenum, } #[api( @@ -195,11 +194,11 @@ pub fn update_drive( if let Some(delete) = delete { for delete_prop in delete { match delete_prop { - DeletableProperty::changer => { + DeletableProperty::Changer => { data.changer = None; data.changer_drivenum = None; } - DeletableProperty::changer_drivenum => { + DeletableProperty::ChangerDrivenum => { data.changer_drivenum = None; } } diff --git a/src/api2/config/media_pool.rs b/src/api2/config/media_pool.rs index 9833db52..79e2e9c5 100644 --- a/src/api2/config/media_pool.rs +++ b/src/api2/config/media_pool.rs @@ -103,19 +103,18 @@ pub fn get_config(name: String) -> Result { #[api()] #[derive(Serialize, Deserialize)] -#[allow(non_camel_case_types)] /// Deletable property name pub enum DeletableProperty { /// Delete media set allocation policy. - allocation, + Allocation, /// Delete pool retention policy - retention, + Retention, /// Delete media set naming template - template, + Template, /// Delete encryption fingerprint - encrypt, + Encrypt, /// Delete comment - comment, + Comment, } #[api( @@ -158,19 +157,19 @@ pub fn update_pool( if let Some(delete) = delete { for delete_prop in delete { match delete_prop { - DeletableProperty::allocation => { + DeletableProperty::Allocation => { data.allocation = None; } - DeletableProperty::retention => { + DeletableProperty::Retention => { data.retention = None; } - DeletableProperty::template => { + DeletableProperty::Template => { data.template = None; } - DeletableProperty::encrypt => { + DeletableProperty::Encrypt => { data.encrypt = None; } - DeletableProperty::comment => { + DeletableProperty::Comment => { data.comment = None; } } diff --git a/src/api2/config/remote.rs b/src/api2/config/remote.rs index 1646699d..fb97b3e1 100644 --- a/src/api2/config/remote.rs +++ b/src/api2/config/remote.rs @@ -133,15 +133,14 @@ pub fn read_remote( #[api()] #[derive(Serialize, Deserialize)] -#[allow(non_camel_case_types)] /// Deletable property name pub enum DeletableProperty { /// Delete the comment property. - comment, + Comment, /// Delete the fingerprint property. - fingerprint, + Fingerprint, /// Delete the port property. - port, + Port, } #[api( @@ -200,13 +199,13 @@ pub fn update_remote( if let Some(delete) = delete { for delete_prop in delete { match delete_prop { - DeletableProperty::comment => { + DeletableProperty::Comment => { data.config.comment = None; } - DeletableProperty::fingerprint => { + DeletableProperty::Fingerprint => { data.config.fingerprint = None; } - DeletableProperty::port => { + DeletableProperty::Port => { data.config.port = None; } } diff --git a/src/api2/config/sync.rs b/src/api2/config/sync.rs index dc080816..bd7373df 100644 --- a/src/api2/config/sync.rs +++ b/src/api2/config/sync.rs @@ -189,33 +189,32 @@ pub fn read_sync_job(id: String, rpcenv: &mut dyn RpcEnvironment) -> Result { + DeletableProperty::Owner => { data.owner = None; } - DeletableProperty::comment => { + DeletableProperty::Comment => { data.comment = None; } - DeletableProperty::schedule => { + DeletableProperty::Schedule => { data.schedule = None; } - DeletableProperty::remove_vanished => { + DeletableProperty::RemoveVanished => { data.remove_vanished = None; } - DeletableProperty::group_filter => { + DeletableProperty::GroupFilter => { data.group_filter = None; } - DeletableProperty::rate_in => { + DeletableProperty::RateIn => { data.limit.rate_in = None; } - DeletableProperty::rate_out => { + DeletableProperty::RateOut => { data.limit.rate_out = None; } - DeletableProperty::burst_in => { + DeletableProperty::BurstIn => { data.limit.burst_in = None; } - DeletableProperty::burst_out => { + DeletableProperty::BurstOut => { data.limit.burst_out = None; } - DeletableProperty::ns => { + DeletableProperty::Ns => { data.ns = None; } - DeletableProperty::remote_ns => { + DeletableProperty::RemoteNs => { data.remote_ns = None; } - DeletableProperty::max_depth => { + DeletableProperty::MaxDepth => { data.max_depth = None; } } diff --git a/src/api2/config/traffic_control.rs b/src/api2/config/traffic_control.rs index 56903643..30ea40ec 100644 --- a/src/api2/config/traffic_control.rs +++ b/src/api2/config/traffic_control.rs @@ -101,22 +101,21 @@ pub fn read_traffic_control( #[api()] #[derive(Serialize, Deserialize)] -#[allow(non_camel_case_types)] #[serde(rename_all = "kebab-case")] /// Deletable property name pub enum DeletableProperty { /// Delete the rate_in property. - rate_in, + RateIn, /// Delete the burst_in property. - burst_in, + BurstIn, /// Delete the rate_out property. - rate_out, + RateOut, /// Delete the burst_out property. - burst_out, + BurstOut, /// Delete the comment property. - comment, + Comment, /// Delete the timeframe property - timeframe, + Timeframe, } // fixme: use TrafficControlUpdater @@ -170,22 +169,22 @@ pub fn update_traffic_control( if let Some(delete) = delete { for delete_prop in delete { match delete_prop { - DeletableProperty::rate_in => { + DeletableProperty::RateIn => { data.limit.rate_in = None; } - DeletableProperty::rate_out => { + DeletableProperty::RateOut => { data.limit.rate_out = None; } - DeletableProperty::burst_in => { + DeletableProperty::BurstIn => { data.limit.burst_in = None; } - DeletableProperty::burst_out => { + DeletableProperty::BurstOut => { data.limit.burst_out = None; } - DeletableProperty::comment => { + DeletableProperty::Comment => { data.comment = None; } - DeletableProperty::timeframe => { + DeletableProperty::Timeframe => { data.timeframe = None; } } diff --git a/src/api2/node/config.rs b/src/api2/node/config.rs index 1ebf4efb..86a73cf8 100644 --- a/src/api2/node/config.rs +++ b/src/api2/node/config.rs @@ -37,37 +37,36 @@ pub fn get_node_config(rpcenv: &mut dyn RpcEnvironment) -> Result { + DeletableProperty::Acme => { config.acme = None; } - DeletableProperty::acmedomain0 => { + DeletableProperty::Acmedomain0 => { config.acmedomain0 = None; } - DeletableProperty::acmedomain1 => { + DeletableProperty::Acmedomain1 => { config.acmedomain1 = None; } - DeletableProperty::acmedomain2 => { + DeletableProperty::Acmedomain2 => { config.acmedomain2 = None; } - DeletableProperty::acmedomain3 => { + DeletableProperty::Acmedomain3 => { config.acmedomain3 = None; } - DeletableProperty::acmedomain4 => { + DeletableProperty::Acmedomain4 => { config.acmedomain4 = None; } - DeletableProperty::http_proxy => { + DeletableProperty::HttpProxy => { config.http_proxy = None; } - DeletableProperty::email_from => { + DeletableProperty::EmailFrom => { config.email_from = None; } - DeletableProperty::ciphers_tls_1_3 => { + DeletableProperty::CiphersTls1_3 => { config.ciphers_tls_1_3 = None; } - DeletableProperty::ciphers_tls_1_2 => { + DeletableProperty::CiphersTls1_2 => { config.ciphers_tls_1_2 = None; } - DeletableProperty::default_lang => { + DeletableProperty::DefaultLang => { config.default_lang = None; } - DeletableProperty::description => { + DeletableProperty::Description => { config.description = None; } - DeletableProperty::task_log_max_days => { + DeletableProperty::TaskLogMaxDays => { config.task_log_max_days = None; } } diff --git a/src/api2/node/dns.rs b/src/api2/node/dns.rs index bc97b8be..6804a102 100644 --- a/src/api2/node/dns.rs +++ b/src/api2/node/dns.rs @@ -22,15 +22,14 @@ static RESOLV_CONF_FN: &str = "/etc/resolv.conf"; #[api()] #[derive(Serialize, Deserialize)] -#[allow(non_camel_case_types)] /// Deletable property name pub enum DeletableProperty { /// Delete first nameserver entry - dns1, + Dns1, /// Delete second nameserver entry - dns2, + Dns2, /// Delete third nameserver entry - dns3, + Dns3, } pub fn read_etc_resolv_conf() -> Result { @@ -146,13 +145,13 @@ pub fn update_dns( for delete_prop in delete { let config = config.as_object_mut().unwrap(); match delete_prop { - DeletableProperty::dns1 => { + DeletableProperty::Dns1 => { config.remove("dns1"); } - DeletableProperty::dns2 => { + DeletableProperty::Dns2 => { config.remove("dns2"); } - DeletableProperty::dns3 => { + DeletableProperty::Dns3 => { config.remove("dns3"); } } diff --git a/src/api2/node/network.rs b/src/api2/node/network.rs index d4be3b46..fef0a6cb 100644 --- a/src/api2/node/network.rs +++ b/src/api2/node/network.rs @@ -356,13 +356,13 @@ pub fn create_interface( if let Some(mode) = bond_mode { interface.bond_mode = bond_mode; if bond_primary.is_some() { - if mode != LinuxBondMode::active_backup { + if mode != LinuxBondMode::ActiveBackup { bail!("bond-primary is only valid with Active/Backup mode"); } interface.bond_primary = bond_primary; } if bond_xmit_hash_policy.is_some() { - if mode != LinuxBondMode::ieee802_3ad && mode != LinuxBondMode::balance_xor { + if mode != LinuxBondMode::Ieee802_3ad && mode != LinuxBondMode::BalanceXor { bail!("bond_xmit_hash_policy is only valid with LACP(802.3ad) or balance-xor mode"); } interface.bond_xmit_hash_policy = bond_xmit_hash_policy; @@ -400,40 +400,39 @@ pub fn create_interface( #[api()] #[derive(Serialize, Deserialize)] -#[allow(non_camel_case_types)] /// Deletable property name pub enum DeletableProperty { /// Delete the IPv4 address property. - cidr, + Cidr, /// Delete the IPv6 address property. - cidr6, + Cidr6, /// Delete the IPv4 gateway property. - gateway, + Gateway, /// Delete the IPv6 gateway property. - gateway6, + Gateway6, /// Delete the whole IPv4 configuration entry. - method, + Method, /// Delete the whole IPv6 configuration entry. - method6, + Method6, /// Delete IPv4 comments - comments, + Comments, /// Delete IPv6 comments - comments6, + Comments6, /// Delete mtu. - mtu, + Mtu, /// Delete autostart flag - autostart, + Autostart, /// Delete bridge ports (set to 'none') - bridge_ports, + BridgePorts, /// Delete bridge-vlan-aware flag - bridge_vlan_aware, + BridgeVlanAware, /// Delete bond-slaves (set to 'none') - slaves, + Slaves, /// Delete bond-primary #[serde(rename = "bond-primary")] - bond_primary, + BondPrimary, /// Delete bond transmit hash policy - bond_xmit_hash_policy, + BondXmitHashPolicy, } #[api( @@ -595,49 +594,49 @@ pub fn update_interface( if let Some(delete) = delete { for delete_prop in delete { match delete_prop { - DeletableProperty::cidr => { + DeletableProperty::Cidr => { interface.cidr = None; } - DeletableProperty::cidr6 => { + DeletableProperty::Cidr6 => { interface.cidr6 = None; } - DeletableProperty::gateway => { + DeletableProperty::Gateway => { interface.gateway = None; } - DeletableProperty::gateway6 => { + DeletableProperty::Gateway6 => { interface.gateway6 = None; } - DeletableProperty::method => { + DeletableProperty::Method => { interface.method = None; } - DeletableProperty::method6 => { + DeletableProperty::Method6 => { interface.method6 = None; } - DeletableProperty::comments => { + DeletableProperty::Comments => { interface.comments = None; } - DeletableProperty::comments6 => { + DeletableProperty::Comments6 => { interface.comments6 = None; } - DeletableProperty::mtu => { + DeletableProperty::Mtu => { interface.mtu = None; } - DeletableProperty::autostart => { + DeletableProperty::Autostart => { interface.autostart = false; } - DeletableProperty::bridge_ports => { + DeletableProperty::BridgePorts => { set_bridge_ports(interface, Vec::new())?; } - DeletableProperty::bridge_vlan_aware => { + DeletableProperty::BridgeVlanAware => { interface.bridge_vlan_aware = None; } - DeletableProperty::slaves => { + DeletableProperty::Slaves => { set_bond_slaves(interface, Vec::new())?; } - DeletableProperty::bond_primary => { + DeletableProperty::BondPrimary => { interface.bond_primary = None; } - DeletableProperty::bond_xmit_hash_policy => interface.bond_xmit_hash_policy = None, + DeletableProperty::BondXmitHashPolicy => interface.bond_xmit_hash_policy = None, } } } @@ -668,13 +667,13 @@ pub fn update_interface( if let Some(mode) = bond_mode { interface.bond_mode = bond_mode; if bond_primary.is_some() { - if mode != LinuxBondMode::active_backup { + if mode != LinuxBondMode::ActiveBackup { bail!("bond-primary is only valid with Active/Backup mode"); } interface.bond_primary = bond_primary; } if bond_xmit_hash_policy.is_some() { - if mode != LinuxBondMode::ieee802_3ad && mode != LinuxBondMode::balance_xor { + if mode != LinuxBondMode::Ieee802_3ad && mode != LinuxBondMode::BalanceXor { bail!("bond_xmit_hash_policy is only valid with LACP(802.3ad) or balance-xor mode"); } interface.bond_xmit_hash_policy = bond_xmit_hash_policy;