tape: do not remove changer while still used

This commit is contained in:
Dietmar Maurer 2020-12-09 12:55:54 +01:00
parent 8a16c571d2
commit 43cfb3c35a
1 changed files with 10 additions and 0 deletions

View File

@ -11,6 +11,7 @@ use crate::{
LINUX_DRIVE_PATH_SCHEMA, LINUX_DRIVE_PATH_SCHEMA,
DriveListEntry, DriveListEntry,
ScsiTapeChanger, ScsiTapeChanger,
LinuxTapeDrive,
}, },
tape::{ tape::{
linux_tape_changer_list, linux_tape_changer_list,
@ -216,6 +217,15 @@ pub fn delete_changer(name: String, _param: Value) -> Result<(), Error> {
None => bail!("Delete changer '{}' failed - no such entry", name), None => bail!("Delete changer '{}' failed - no such entry", name),
} }
let drive_list: Vec<LinuxTapeDrive> = config.convert_to_typed_array("linux")?;
for drive in drive_list {
if let Some(changer) = drive.changer {
if changer == name {
bail!("Delete changer '{}' failed - used by drive '{}'", name, drive.name);
}
}
}
config::drive::save_config(&config)?; config::drive::save_config(&config)?;
Ok(()) Ok(())