5
0
mirror of git://git.proxmox.com/git/proxmox-backup.git synced 2025-01-08 21:18:07 +03:00

fix non-camel-case enums

This should have never been started to begin with...
This commit is contained in:
Wolfgang Bumiller 2023-01-05 10:57:11 +01:00
parent 79de842ca3
commit a2055c38fe
15 changed files with 217 additions and 230 deletions

View File

@ -1,3 +1,5 @@
use std::fmt;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use proxmox_schema::*; use proxmox_schema::*;
@ -59,42 +61,64 @@ pub enum NetworkConfigMethod {
#[api()] #[api()]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
#[allow(non_camel_case_types)]
#[repr(u8)] #[repr(u8)]
/// Linux Bond Mode /// Linux Bond Mode
pub enum LinuxBondMode { pub enum LinuxBondMode {
/// Round-robin policy /// Round-robin policy
balance_rr = 0, BalanceRr = 0,
/// Active-backup policy /// Active-backup policy
active_backup = 1, ActiveBackup = 1,
/// XOR policy /// XOR policy
balance_xor = 2, BalanceXor = 2,
/// Broadcast policy /// Broadcast policy
broadcast = 3, Broadcast = 3,
/// IEEE 802.3ad Dynamic link aggregation /// IEEE 802.3ad Dynamic link aggregation
#[serde(rename = "802.3ad")] #[serde(rename = "802.3ad")]
ieee802_3ad = 4, Ieee802_3ad = 4,
/// Adaptive transmit load balancing /// Adaptive transmit load balancing
balance_tlb = 5, BalanceTlb = 5,
/// Adaptive load balancing /// 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()] #[api()]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
#[allow(non_camel_case_types)]
#[repr(u8)] #[repr(u8)]
/// Bond Transmit Hash Policy for LACP (802.3ad) /// Bond Transmit Hash Policy for LACP (802.3ad)
pub enum BondXmitHashPolicy { pub enum BondXmitHashPolicy {
/// Layer 2 /// Layer 2
layer2 = 0, Layer2 = 0,
/// Layer 2+3 /// Layer 2+3
#[serde(rename = "layer2+3")] #[serde(rename = "layer2+3")]
layer2_3 = 1, Layer2_3 = 1,
/// Layer 3+4 /// Layer 3+4
#[serde(rename = "layer3+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()] #[api()]

View File

@ -36,31 +36,11 @@ pub fn bond_mode_from_str(s: &str) -> Result<LinuxBondMode, Error> {
.map_err(|_: value::Error| format_err!("invalid bond_mode '{}'", s)) .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, Error> { pub fn bond_xmit_hash_policy_from_str(s: &str) -> Result<BondXmitHashPolicy, Error> {
BondXmitHashPolicy::deserialize(s.into_deserializer()) BondXmitHashPolicy::deserialize(s.into_deserializer())
.map_err(|_: value::Error| format_err!("invalid bond_xmit_hash_policy '{}'", s)) .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 // Write attributes not depending on address family
fn write_iface_attributes(iface: &Interface, w: &mut dyn Write) -> Result<(), Error> { fn write_iface_attributes(iface: &Interface, w: &mut dyn Write) -> Result<(), Error> {
static EMPTY_LIST: Vec<String> = Vec::new(); static EMPTY_LIST: Vec<String> = Vec::new();
@ -78,21 +58,17 @@ fn write_iface_attributes(iface: &Interface, w: &mut dyn Write) -> Result<(), Er
} }
} }
NetworkInterfaceType::Bond => { NetworkInterfaceType::Bond => {
let mode = iface.bond_mode.unwrap_or(LinuxBondMode::balance_rr); let mode = iface.bond_mode.unwrap_or(LinuxBondMode::BalanceRr);
writeln!(w, "\tbond-mode {}", bond_mode_to_str(mode))?; writeln!(w, "\tbond-mode {mode}")?;
if let Some(primary) = &iface.bond_primary { if let Some(primary) = &iface.bond_primary {
if mode == LinuxBondMode::active_backup { if mode == LinuxBondMode::ActiveBackup {
writeln!(w, "\tbond-primary {}", primary)?; writeln!(w, "\tbond-primary {}", primary)?;
} }
} }
if let Some(xmit_policy) = &iface.bond_xmit_hash_policy { if let Some(xmit_policy) = &iface.bond_xmit_hash_policy {
if mode == LinuxBondMode::ieee802_3ad || mode == LinuxBondMode::balance_xor { if mode == LinuxBondMode::Ieee802_3ad || mode == LinuxBondMode::BalanceXor {
writeln!( writeln!(w, "\tbond_xmit_hash_policy {xmit_policy}")?;
w,
"\tbond_xmit_hash_policy {}",
bond_xmit_hash_policy_to_str(xmit_policy)
)?;
} }
} }

View File

@ -189,16 +189,15 @@ pub fn read_user(userid: Userid, rpcenv: &mut dyn RpcEnvironment) -> Result<User
#[api()] #[api()]
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
#[allow(non_camel_case_types)]
pub enum DeletableProperty { pub enum DeletableProperty {
/// Delete the comment property. /// Delete the comment property.
comment, Comment,
/// Delete the firstname property. /// Delete the firstname property.
firstname, Firstname,
/// Delete the lastname property. /// Delete the lastname property.
lastname, Lastname,
/// Delete the email property. /// Delete the email property.
email, Email,
} }
#[api( #[api(
@ -261,10 +260,10 @@ pub fn update_user(
if let Some(delete) = delete { if let Some(delete) = delete {
for delete_prop in delete { for delete_prop in delete {
match delete_prop { match delete_prop {
DeletableProperty::comment => data.comment = None, DeletableProperty::Comment => data.comment = None,
DeletableProperty::firstname => data.firstname = None, DeletableProperty::Firstname => data.firstname = None,
DeletableProperty::lastname => data.lastname = None, DeletableProperty::Lastname => data.lastname = None,
DeletableProperty::email => data.email = None, DeletableProperty::Email => data.email = None,
} }
} }
} }

View File

@ -146,21 +146,20 @@ pub fn read_openid_realm(
#[api()] #[api()]
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
#[allow(non_camel_case_types)]
/// Deletable property name /// Deletable property name
pub enum DeletableProperty { pub enum DeletableProperty {
/// Delete the client key. /// Delete the client key.
client_key, ClientKey,
/// Delete the comment property. /// Delete the comment property.
comment, Comment,
/// Delete the autocreate property /// Delete the autocreate property
autocreate, Autocreate,
/// Delete the scopes property /// Delete the scopes property
scopes, Scopes,
/// Delete the prompt property /// Delete the prompt property
prompt, Prompt,
/// Delete the acr_values property /// Delete the acr_values property
acr_values, AcrValues,
} }
#[api( #[api(
@ -215,22 +214,22 @@ pub fn update_openid_realm(
if let Some(delete) = delete { if let Some(delete) = delete {
for delete_prop in delete { for delete_prop in delete {
match delete_prop { match delete_prop {
DeletableProperty::client_key => { DeletableProperty::ClientKey => {
config.client_key = None; config.client_key = None;
} }
DeletableProperty::comment => { DeletableProperty::Comment => {
config.comment = None; config.comment = None;
} }
DeletableProperty::autocreate => { DeletableProperty::Autocreate => {
config.autocreate = None; config.autocreate = None;
} }
DeletableProperty::scopes => { DeletableProperty::Scopes => {
config.scopes = None; config.scopes = None;
} }
DeletableProperty::prompt => { DeletableProperty::Prompt => {
config.prompt = None; config.prompt = None;
} }
DeletableProperty::acr_values => { DeletableProperty::AcrValues => {
config.acr_values = None; config.acr_values = None;
} }
} }

View File

@ -633,13 +633,12 @@ pub fn delete_plugin(id: String) -> Result<(), Error> {
#[api()] #[api()]
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
#[allow(non_camel_case_types)]
/// Deletable property name /// Deletable property name
pub enum DeletableProperty { pub enum DeletableProperty {
/// Delete the disable property /// Delete the disable property
disable, Disable,
/// Delete the validation-delay property /// Delete the validation-delay property
validation_delay, ValidationDelay,
} }
#[api( #[api(
@ -711,10 +710,10 @@ pub fn update_plugin(
if let Some(delete) = delete { if let Some(delete) = delete {
for delete_prop in delete { for delete_prop in delete {
match delete_prop { match delete_prop {
DeletableProperty::validation_delay => { DeletableProperty::ValidationDelay => {
plugin.core.validation_delay = None; plugin.core.validation_delay = None;
} }
DeletableProperty::disable => { DeletableProperty::Disable => {
plugin.core.disable = None; plugin.core.disable = None;
} }
} }

View File

@ -133,12 +133,11 @@ pub fn list_changers(
} }
#[api()] #[api()]
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
#[allow(non_camel_case_types)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
/// Deletable property name /// Deletable property name
pub enum DeletableProperty { pub enum DeletableProperty {
/// Delete export-slots. /// Delete export-slots.
export_slots, ExportSlots,
} }
#[api( #[api(
@ -192,7 +191,7 @@ pub fn update_changer(
if let Some(delete) = delete { if let Some(delete) = delete {
for delete_prop in delete { for delete_prop in delete {
match delete_prop { match delete_prop {
DeletableProperty::export_slots => { DeletableProperty::ExportSlots => {
data.export_slots = None; data.export_slots = None;
} }
} }

View File

@ -165,37 +165,36 @@ pub fn read_datastore(
#[api()] #[api()]
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
#[allow(non_camel_case_types)]
/// Deletable property name /// Deletable property name
pub enum DeletableProperty { pub enum DeletableProperty {
/// Delete the comment property. /// Delete the comment property.
comment, Comment,
/// Delete the garbage collection schedule. /// Delete the garbage collection schedule.
gc_schedule, GcSchedule,
/// Delete the prune job schedule. /// Delete the prune job schedule.
prune_schedule, PruneSchedule,
/// Delete the keep-last property /// Delete the keep-last property
keep_last, KeepLast,
/// Delete the keep-hourly property /// Delete the keep-hourly property
keep_hourly, KeepHourly,
/// Delete the keep-daily property /// Delete the keep-daily property
keep_daily, KeepDaily,
/// Delete the keep-weekly property /// Delete the keep-weekly property
keep_weekly, KeepWeekly,
/// Delete the keep-monthly property /// Delete the keep-monthly property
keep_monthly, KeepMonthly,
/// Delete the keep-yearly property /// Delete the keep-yearly property
keep_yearly, KeepYearly,
/// Delete the verify-new property /// Delete the verify-new property
verify_new, VerifyNew,
/// Delete the notify-user property /// Delete the notify-user property
notify_user, NotifyUser,
/// Delete the notify property /// Delete the notify property
notify, Notify,
/// Delete the tuning property /// Delete the tuning property
tuning, Tuning,
/// Delete the maintenance-mode property /// Delete the maintenance-mode property
maintenance_mode, MaintenanceMode,
} }
#[api( #[api(
@ -249,46 +248,46 @@ pub fn update_datastore(
if let Some(delete) = delete { if let Some(delete) = delete {
for delete_prop in delete { for delete_prop in delete {
match delete_prop { match delete_prop {
DeletableProperty::comment => { DeletableProperty::Comment => {
data.comment = None; data.comment = None;
} }
DeletableProperty::gc_schedule => { DeletableProperty::GcSchedule => {
data.gc_schedule = None; data.gc_schedule = None;
} }
DeletableProperty::prune_schedule => { DeletableProperty::PruneSchedule => {
data.prune_schedule = None; data.prune_schedule = None;
} }
DeletableProperty::keep_last => { DeletableProperty::KeepLast => {
data.keep.keep_last = None; data.keep.keep_last = None;
} }
DeletableProperty::keep_hourly => { DeletableProperty::KeepHourly => {
data.keep.keep_hourly = None; data.keep.keep_hourly = None;
} }
DeletableProperty::keep_daily => { DeletableProperty::KeepDaily => {
data.keep.keep_daily = None; data.keep.keep_daily = None;
} }
DeletableProperty::keep_weekly => { DeletableProperty::KeepWeekly => {
data.keep.keep_weekly = None; data.keep.keep_weekly = None;
} }
DeletableProperty::keep_monthly => { DeletableProperty::KeepMonthly => {
data.keep.keep_monthly = None; data.keep.keep_monthly = None;
} }
DeletableProperty::keep_yearly => { DeletableProperty::KeepYearly => {
data.keep.keep_yearly = None; data.keep.keep_yearly = None;
} }
DeletableProperty::verify_new => { DeletableProperty::VerifyNew => {
data.verify_new = None; data.verify_new = None;
} }
DeletableProperty::notify => { DeletableProperty::Notify => {
data.notify = None; data.notify = None;
} }
DeletableProperty::notify_user => { DeletableProperty::NotifyUser => {
data.notify_user = None; data.notify_user = None;
} }
DeletableProperty::tuning => { DeletableProperty::Tuning => {
data.tuning = None; data.tuning = None;
} }
DeletableProperty::maintenance_mode => { DeletableProperty::MaintenanceMode => {
data.maintenance_mode = None; data.maintenance_mode = None;
} }
} }

View File

@ -134,14 +134,13 @@ pub fn list_drives(
#[api()] #[api()]
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
#[allow(non_camel_case_types)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
/// Deletable property name /// Deletable property name
pub enum DeletableProperty { pub enum DeletableProperty {
/// Delete the changer property. /// Delete the changer property.
changer, Changer,
/// Delete the changer-drivenum property. /// Delete the changer-drivenum property.
changer_drivenum, ChangerDrivenum,
} }
#[api( #[api(
@ -195,11 +194,11 @@ pub fn update_drive(
if let Some(delete) = delete { if let Some(delete) = delete {
for delete_prop in delete { for delete_prop in delete {
match delete_prop { match delete_prop {
DeletableProperty::changer => { DeletableProperty::Changer => {
data.changer = None; data.changer = None;
data.changer_drivenum = None; data.changer_drivenum = None;
} }
DeletableProperty::changer_drivenum => { DeletableProperty::ChangerDrivenum => {
data.changer_drivenum = None; data.changer_drivenum = None;
} }
} }

View File

@ -103,19 +103,18 @@ pub fn get_config(name: String) -> Result<MediaPoolConfig, Error> {
#[api()] #[api()]
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
#[allow(non_camel_case_types)]
/// Deletable property name /// Deletable property name
pub enum DeletableProperty { pub enum DeletableProperty {
/// Delete media set allocation policy. /// Delete media set allocation policy.
allocation, Allocation,
/// Delete pool retention policy /// Delete pool retention policy
retention, Retention,
/// Delete media set naming template /// Delete media set naming template
template, Template,
/// Delete encryption fingerprint /// Delete encryption fingerprint
encrypt, Encrypt,
/// Delete comment /// Delete comment
comment, Comment,
} }
#[api( #[api(
@ -158,19 +157,19 @@ pub fn update_pool(
if let Some(delete) = delete { if let Some(delete) = delete {
for delete_prop in delete { for delete_prop in delete {
match delete_prop { match delete_prop {
DeletableProperty::allocation => { DeletableProperty::Allocation => {
data.allocation = None; data.allocation = None;
} }
DeletableProperty::retention => { DeletableProperty::Retention => {
data.retention = None; data.retention = None;
} }
DeletableProperty::template => { DeletableProperty::Template => {
data.template = None; data.template = None;
} }
DeletableProperty::encrypt => { DeletableProperty::Encrypt => {
data.encrypt = None; data.encrypt = None;
} }
DeletableProperty::comment => { DeletableProperty::Comment => {
data.comment = None; data.comment = None;
} }
} }

View File

@ -133,15 +133,14 @@ pub fn read_remote(
#[api()] #[api()]
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
#[allow(non_camel_case_types)]
/// Deletable property name /// Deletable property name
pub enum DeletableProperty { pub enum DeletableProperty {
/// Delete the comment property. /// Delete the comment property.
comment, Comment,
/// Delete the fingerprint property. /// Delete the fingerprint property.
fingerprint, Fingerprint,
/// Delete the port property. /// Delete the port property.
port, Port,
} }
#[api( #[api(
@ -200,13 +199,13 @@ pub fn update_remote(
if let Some(delete) = delete { if let Some(delete) = delete {
for delete_prop in delete { for delete_prop in delete {
match delete_prop { match delete_prop {
DeletableProperty::comment => { DeletableProperty::Comment => {
data.config.comment = None; data.config.comment = None;
} }
DeletableProperty::fingerprint => { DeletableProperty::Fingerprint => {
data.config.fingerprint = None; data.config.fingerprint = None;
} }
DeletableProperty::port => { DeletableProperty::Port => {
data.config.port = None; data.config.port = None;
} }
} }

View File

@ -189,33 +189,32 @@ pub fn read_sync_job(id: String, rpcenv: &mut dyn RpcEnvironment) -> Result<Sync
#[api()] #[api()]
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
#[allow(non_camel_case_types)]
/// Deletable property name /// Deletable property name
pub enum DeletableProperty { pub enum DeletableProperty {
/// Delete the owner property. /// Delete the owner property.
owner, Owner,
/// Delete the comment property. /// Delete the comment property.
comment, Comment,
/// Delete the job schedule. /// Delete the job schedule.
schedule, Schedule,
/// Delete the remove-vanished flag. /// Delete the remove-vanished flag.
remove_vanished, RemoveVanished,
/// Delete the group_filter property. /// Delete the group_filter property.
group_filter, GroupFilter,
/// Delete the rate_in property. /// Delete the rate_in property.
rate_in, RateIn,
/// Delete the burst_in property. /// Delete the burst_in property.
burst_in, BurstIn,
/// Delete the rate_out property. /// Delete the rate_out property.
rate_out, RateOut,
/// Delete the burst_out property. /// Delete the burst_out property.
burst_out, BurstOut,
/// Delete the ns property, /// Delete the ns property,
ns, Ns,
/// Delete the remote_ns property, /// Delete the remote_ns property,
remote_ns, RemoteNs,
/// Delete the max_depth property, /// Delete the max_depth property,
max_depth, MaxDepth,
} }
#[api( #[api(
@ -274,40 +273,40 @@ pub fn update_sync_job(
if let Some(delete) = delete { if let Some(delete) = delete {
for delete_prop in delete { for delete_prop in delete {
match delete_prop { match delete_prop {
DeletableProperty::owner => { DeletableProperty::Owner => {
data.owner = None; data.owner = None;
} }
DeletableProperty::comment => { DeletableProperty::Comment => {
data.comment = None; data.comment = None;
} }
DeletableProperty::schedule => { DeletableProperty::Schedule => {
data.schedule = None; data.schedule = None;
} }
DeletableProperty::remove_vanished => { DeletableProperty::RemoveVanished => {
data.remove_vanished = None; data.remove_vanished = None;
} }
DeletableProperty::group_filter => { DeletableProperty::GroupFilter => {
data.group_filter = None; data.group_filter = None;
} }
DeletableProperty::rate_in => { DeletableProperty::RateIn => {
data.limit.rate_in = None; data.limit.rate_in = None;
} }
DeletableProperty::rate_out => { DeletableProperty::RateOut => {
data.limit.rate_out = None; data.limit.rate_out = None;
} }
DeletableProperty::burst_in => { DeletableProperty::BurstIn => {
data.limit.burst_in = None; data.limit.burst_in = None;
} }
DeletableProperty::burst_out => { DeletableProperty::BurstOut => {
data.limit.burst_out = None; data.limit.burst_out = None;
} }
DeletableProperty::ns => { DeletableProperty::Ns => {
data.ns = None; data.ns = None;
} }
DeletableProperty::remote_ns => { DeletableProperty::RemoteNs => {
data.remote_ns = None; data.remote_ns = None;
} }
DeletableProperty::max_depth => { DeletableProperty::MaxDepth => {
data.max_depth = None; data.max_depth = None;
} }
} }

View File

@ -101,22 +101,21 @@ pub fn read_traffic_control(
#[api()] #[api()]
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
#[allow(non_camel_case_types)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
/// Deletable property name /// Deletable property name
pub enum DeletableProperty { pub enum DeletableProperty {
/// Delete the rate_in property. /// Delete the rate_in property.
rate_in, RateIn,
/// Delete the burst_in property. /// Delete the burst_in property.
burst_in, BurstIn,
/// Delete the rate_out property. /// Delete the rate_out property.
rate_out, RateOut,
/// Delete the burst_out property. /// Delete the burst_out property.
burst_out, BurstOut,
/// Delete the comment property. /// Delete the comment property.
comment, Comment,
/// Delete the timeframe property /// Delete the timeframe property
timeframe, Timeframe,
} }
// fixme: use TrafficControlUpdater // fixme: use TrafficControlUpdater
@ -170,22 +169,22 @@ pub fn update_traffic_control(
if let Some(delete) = delete { if let Some(delete) = delete {
for delete_prop in delete { for delete_prop in delete {
match delete_prop { match delete_prop {
DeletableProperty::rate_in => { DeletableProperty::RateIn => {
data.limit.rate_in = None; data.limit.rate_in = None;
} }
DeletableProperty::rate_out => { DeletableProperty::RateOut => {
data.limit.rate_out = None; data.limit.rate_out = None;
} }
DeletableProperty::burst_in => { DeletableProperty::BurstIn => {
data.limit.burst_in = None; data.limit.burst_in = None;
} }
DeletableProperty::burst_out => { DeletableProperty::BurstOut => {
data.limit.burst_out = None; data.limit.burst_out = None;
} }
DeletableProperty::comment => { DeletableProperty::Comment => {
data.comment = None; data.comment = None;
} }
DeletableProperty::timeframe => { DeletableProperty::Timeframe => {
data.timeframe = None; data.timeframe = None;
} }
} }

View File

@ -37,37 +37,36 @@ pub fn get_node_config(rpcenv: &mut dyn RpcEnvironment) -> Result<NodeConfig, Er
#[api()] #[api()]
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
#[allow(non_camel_case_types)]
/// Deletable property name /// Deletable property name
pub enum DeletableProperty { pub enum DeletableProperty {
/// Delete the acme property. /// Delete the acme property.
acme, Acme,
/// Delete the acmedomain0 property. /// Delete the acmedomain0 property.
acmedomain0, Acmedomain0,
/// Delete the acmedomain1 property. /// Delete the acmedomain1 property.
acmedomain1, Acmedomain1,
/// Delete the acmedomain2 property. /// Delete the acmedomain2 property.
acmedomain2, Acmedomain2,
/// Delete the acmedomain3 property. /// Delete the acmedomain3 property.
acmedomain3, Acmedomain3,
/// Delete the acmedomain4 property. /// Delete the acmedomain4 property.
acmedomain4, Acmedomain4,
/// Delete the http-proxy property. /// Delete the http-proxy property.
http_proxy, HttpProxy,
/// Delete the email-from property. /// Delete the email-from property.
email_from, EmailFrom,
/// Delete the ciphers-tls-1.3 property. /// Delete the ciphers-tls-1.3 property.
#[serde(rename = "ciphers-tls-1.3")] #[serde(rename = "ciphers-tls-1.3")]
ciphers_tls_1_3, CiphersTls1_3,
/// Delete the ciphers-tls-1.2 property. /// Delete the ciphers-tls-1.2 property.
#[serde(rename = "ciphers-tls-1.2")] #[serde(rename = "ciphers-tls-1.2")]
ciphers_tls_1_2, CiphersTls1_2,
/// Delete the default-lang property. /// Delete the default-lang property.
default_lang, DefaultLang,
/// Delete any description /// Delete any description
description, Description,
/// Delete the task-log-max-days property /// Delete the task-log-max-days property
task_log_max_days, TaskLogMaxDays,
} }
#[api( #[api(
@ -117,43 +116,43 @@ pub fn update_node_config(
if let Some(delete) = delete { if let Some(delete) = delete {
for delete_prop in delete { for delete_prop in delete {
match delete_prop { match delete_prop {
DeletableProperty::acme => { DeletableProperty::Acme => {
config.acme = None; config.acme = None;
} }
DeletableProperty::acmedomain0 => { DeletableProperty::Acmedomain0 => {
config.acmedomain0 = None; config.acmedomain0 = None;
} }
DeletableProperty::acmedomain1 => { DeletableProperty::Acmedomain1 => {
config.acmedomain1 = None; config.acmedomain1 = None;
} }
DeletableProperty::acmedomain2 => { DeletableProperty::Acmedomain2 => {
config.acmedomain2 = None; config.acmedomain2 = None;
} }
DeletableProperty::acmedomain3 => { DeletableProperty::Acmedomain3 => {
config.acmedomain3 = None; config.acmedomain3 = None;
} }
DeletableProperty::acmedomain4 => { DeletableProperty::Acmedomain4 => {
config.acmedomain4 = None; config.acmedomain4 = None;
} }
DeletableProperty::http_proxy => { DeletableProperty::HttpProxy => {
config.http_proxy = None; config.http_proxy = None;
} }
DeletableProperty::email_from => { DeletableProperty::EmailFrom => {
config.email_from = None; config.email_from = None;
} }
DeletableProperty::ciphers_tls_1_3 => { DeletableProperty::CiphersTls1_3 => {
config.ciphers_tls_1_3 = None; config.ciphers_tls_1_3 = None;
} }
DeletableProperty::ciphers_tls_1_2 => { DeletableProperty::CiphersTls1_2 => {
config.ciphers_tls_1_2 = None; config.ciphers_tls_1_2 = None;
} }
DeletableProperty::default_lang => { DeletableProperty::DefaultLang => {
config.default_lang = None; config.default_lang = None;
} }
DeletableProperty::description => { DeletableProperty::Description => {
config.description = None; config.description = None;
} }
DeletableProperty::task_log_max_days => { DeletableProperty::TaskLogMaxDays => {
config.task_log_max_days = None; config.task_log_max_days = None;
} }
} }

View File

@ -22,15 +22,14 @@ static RESOLV_CONF_FN: &str = "/etc/resolv.conf";
#[api()] #[api()]
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
#[allow(non_camel_case_types)]
/// Deletable property name /// Deletable property name
pub enum DeletableProperty { pub enum DeletableProperty {
/// Delete first nameserver entry /// Delete first nameserver entry
dns1, Dns1,
/// Delete second nameserver entry /// Delete second nameserver entry
dns2, Dns2,
/// Delete third nameserver entry /// Delete third nameserver entry
dns3, Dns3,
} }
pub fn read_etc_resolv_conf() -> Result<Value, Error> { pub fn read_etc_resolv_conf() -> Result<Value, Error> {
@ -146,13 +145,13 @@ pub fn update_dns(
for delete_prop in delete { for delete_prop in delete {
let config = config.as_object_mut().unwrap(); let config = config.as_object_mut().unwrap();
match delete_prop { match delete_prop {
DeletableProperty::dns1 => { DeletableProperty::Dns1 => {
config.remove("dns1"); config.remove("dns1");
} }
DeletableProperty::dns2 => { DeletableProperty::Dns2 => {
config.remove("dns2"); config.remove("dns2");
} }
DeletableProperty::dns3 => { DeletableProperty::Dns3 => {
config.remove("dns3"); config.remove("dns3");
} }
} }

View File

@ -356,13 +356,13 @@ pub fn create_interface(
if let Some(mode) = bond_mode { if let Some(mode) = bond_mode {
interface.bond_mode = bond_mode; interface.bond_mode = bond_mode;
if bond_primary.is_some() { if bond_primary.is_some() {
if mode != LinuxBondMode::active_backup { if mode != LinuxBondMode::ActiveBackup {
bail!("bond-primary is only valid with Active/Backup mode"); bail!("bond-primary is only valid with Active/Backup mode");
} }
interface.bond_primary = bond_primary; interface.bond_primary = bond_primary;
} }
if bond_xmit_hash_policy.is_some() { 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"); 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; interface.bond_xmit_hash_policy = bond_xmit_hash_policy;
@ -400,40 +400,39 @@ pub fn create_interface(
#[api()] #[api()]
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
#[allow(non_camel_case_types)]
/// Deletable property name /// Deletable property name
pub enum DeletableProperty { pub enum DeletableProperty {
/// Delete the IPv4 address property. /// Delete the IPv4 address property.
cidr, Cidr,
/// Delete the IPv6 address property. /// Delete the IPv6 address property.
cidr6, Cidr6,
/// Delete the IPv4 gateway property. /// Delete the IPv4 gateway property.
gateway, Gateway,
/// Delete the IPv6 gateway property. /// Delete the IPv6 gateway property.
gateway6, Gateway6,
/// Delete the whole IPv4 configuration entry. /// Delete the whole IPv4 configuration entry.
method, Method,
/// Delete the whole IPv6 configuration entry. /// Delete the whole IPv6 configuration entry.
method6, Method6,
/// Delete IPv4 comments /// Delete IPv4 comments
comments, Comments,
/// Delete IPv6 comments /// Delete IPv6 comments
comments6, Comments6,
/// Delete mtu. /// Delete mtu.
mtu, Mtu,
/// Delete autostart flag /// Delete autostart flag
autostart, Autostart,
/// Delete bridge ports (set to 'none') /// Delete bridge ports (set to 'none')
bridge_ports, BridgePorts,
/// Delete bridge-vlan-aware flag /// Delete bridge-vlan-aware flag
bridge_vlan_aware, BridgeVlanAware,
/// Delete bond-slaves (set to 'none') /// Delete bond-slaves (set to 'none')
slaves, Slaves,
/// Delete bond-primary /// Delete bond-primary
#[serde(rename = "bond-primary")] #[serde(rename = "bond-primary")]
bond_primary, BondPrimary,
/// Delete bond transmit hash policy /// Delete bond transmit hash policy
bond_xmit_hash_policy, BondXmitHashPolicy,
} }
#[api( #[api(
@ -595,49 +594,49 @@ pub fn update_interface(
if let Some(delete) = delete { if let Some(delete) = delete {
for delete_prop in delete { for delete_prop in delete {
match delete_prop { match delete_prop {
DeletableProperty::cidr => { DeletableProperty::Cidr => {
interface.cidr = None; interface.cidr = None;
} }
DeletableProperty::cidr6 => { DeletableProperty::Cidr6 => {
interface.cidr6 = None; interface.cidr6 = None;
} }
DeletableProperty::gateway => { DeletableProperty::Gateway => {
interface.gateway = None; interface.gateway = None;
} }
DeletableProperty::gateway6 => { DeletableProperty::Gateway6 => {
interface.gateway6 = None; interface.gateway6 = None;
} }
DeletableProperty::method => { DeletableProperty::Method => {
interface.method = None; interface.method = None;
} }
DeletableProperty::method6 => { DeletableProperty::Method6 => {
interface.method6 = None; interface.method6 = None;
} }
DeletableProperty::comments => { DeletableProperty::Comments => {
interface.comments = None; interface.comments = None;
} }
DeletableProperty::comments6 => { DeletableProperty::Comments6 => {
interface.comments6 = None; interface.comments6 = None;
} }
DeletableProperty::mtu => { DeletableProperty::Mtu => {
interface.mtu = None; interface.mtu = None;
} }
DeletableProperty::autostart => { DeletableProperty::Autostart => {
interface.autostart = false; interface.autostart = false;
} }
DeletableProperty::bridge_ports => { DeletableProperty::BridgePorts => {
set_bridge_ports(interface, Vec::new())?; set_bridge_ports(interface, Vec::new())?;
} }
DeletableProperty::bridge_vlan_aware => { DeletableProperty::BridgeVlanAware => {
interface.bridge_vlan_aware = None; interface.bridge_vlan_aware = None;
} }
DeletableProperty::slaves => { DeletableProperty::Slaves => {
set_bond_slaves(interface, Vec::new())?; set_bond_slaves(interface, Vec::new())?;
} }
DeletableProperty::bond_primary => { DeletableProperty::BondPrimary => {
interface.bond_primary = None; 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 { if let Some(mode) = bond_mode {
interface.bond_mode = bond_mode; interface.bond_mode = bond_mode;
if bond_primary.is_some() { if bond_primary.is_some() {
if mode != LinuxBondMode::active_backup { if mode != LinuxBondMode::ActiveBackup {
bail!("bond-primary is only valid with Active/Backup mode"); bail!("bond-primary is only valid with Active/Backup mode");
} }
interface.bond_primary = bond_primary; interface.bond_primary = bond_primary;
} }
if bond_xmit_hash_policy.is_some() { 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"); 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; interface.bond_xmit_hash_policy = bond_xmit_hash_policy;