tape: implement delete property for drive update command

This commit is contained in:
Dietmar Maurer 2020-12-10 08:25:46 +01:00
parent 93829fc680
commit 4917f1e2d4
1 changed files with 27 additions and 0 deletions

View File

@ -1,4 +1,5 @@
use anyhow::{bail, Error}; use anyhow::{bail, Error};
use ::serde::{Deserialize, Serialize};
use serde_json::Value; use serde_json::Value;
use proxmox::api::{api, Router, RpcEnvironment}; use proxmox::api::{api, Router, RpcEnvironment};
@ -138,6 +139,15 @@ pub fn list_drives(
Ok(list) Ok(list)
} }
#[api()]
#[derive(Serialize, Deserialize)]
#[allow(non_camel_case_types)]
/// Deletable property name
pub enum DeletableProperty {
/// Delete the changer property.
changer,
}
#[api( #[api(
protected: true, protected: true,
input: { input: {
@ -153,6 +163,14 @@ pub fn list_drives(
schema: CHANGER_ID_SCHEMA, schema: CHANGER_ID_SCHEMA,
optional: true, optional: true,
}, },
delete: {
description: "List of properties to delete.",
type: Array,
optional: true,
items: {
type: DeletableProperty,
}
},
digest: { digest: {
schema: PROXMOX_CONFIG_DIGEST_SCHEMA, schema: PROXMOX_CONFIG_DIGEST_SCHEMA,
optional: true, optional: true,
@ -165,6 +183,7 @@ pub fn update_drive(
name: String, name: String,
path: Option<String>, path: Option<String>,
changer: Option<String>, changer: Option<String>,
delete: Option<Vec<DeletableProperty>>,
digest: Option<String>, digest: Option<String>,
_param: Value, _param: Value,
) -> Result<(), Error> { ) -> Result<(), Error> {
@ -180,6 +199,14 @@ pub fn update_drive(
let mut data: LinuxTapeDrive = config.lookup("linux", &name)?; let mut data: LinuxTapeDrive = config.lookup("linux", &name)?;
if let Some(delete) = delete {
for delete_prop in delete {
match delete_prop {
DeletableProperty::changer => { data.changer = None; },
}
}
}
if let Some(path) = path { if let Some(path) = path {
let linux_drives = linux_tape_device_list(); let linux_drives = linux_tape_device_list();
check_drive_path(&linux_drives, &path)?; check_drive_path(&linux_drives, &path)?;