2020-12-05 13:46:57 +00:00
|
|
|
mod email;
|
|
|
|
pub use email::*;
|
|
|
|
|
|
|
|
mod parse_mtx_status;
|
|
|
|
pub use parse_mtx_status::*;
|
|
|
|
|
|
|
|
mod mtx_wrapper;
|
|
|
|
pub use mtx_wrapper::*;
|
|
|
|
|
|
|
|
mod linux_tape;
|
|
|
|
pub use linux_tape::*;
|
|
|
|
|
|
|
|
use anyhow::Error;
|
|
|
|
|
|
|
|
/// Interface to media change devices
|
|
|
|
pub trait MediaChange {
|
|
|
|
|
2021-01-07 13:26:43 +00:00
|
|
|
/// Returns the changer status
|
|
|
|
fn status(&mut self) -> Result<MtxStatus, Error>;
|
|
|
|
|
|
|
|
/// Load media from storage slot into drive
|
|
|
|
fn load_media_from_slot(&mut self, slot: u64) -> Result<(), Error>;
|
|
|
|
|
|
|
|
/// Load media by changer-id into drive
|
2020-12-05 13:46:57 +00:00
|
|
|
///
|
|
|
|
/// This unloads first if the drive is already loaded with another media.
|
2021-01-07 13:26:43 +00:00
|
|
|
///
|
|
|
|
/// Note: This refuses to load media inside import/export slots.
|
2020-12-05 13:46:57 +00:00
|
|
|
fn load_media(&mut self, changer_id: &str) -> Result<(), Error>;
|
|
|
|
|
|
|
|
/// Unload media from drive
|
|
|
|
///
|
|
|
|
/// This is a nop on drives without autoloader.
|
2021-01-07 13:26:43 +00:00
|
|
|
fn unload_media(&mut self, target_slot: Option<u64>) -> Result<(), Error>;
|
2020-12-05 13:46:57 +00:00
|
|
|
|
|
|
|
/// Returns true if unload_media automatically ejects drive media
|
|
|
|
fn eject_on_unload(&self) -> bool {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
|
2021-01-07 13:26:43 +00:00
|
|
|
/// List online media changer IDs (barcodes)
|
|
|
|
///
|
|
|
|
/// List acessible (online) changer IDs. This does not include
|
|
|
|
/// media inside import-export slots or cleaning media.
|
|
|
|
fn online_media_changer_ids(&mut self) -> Result<Vec<String>, Error> {
|
|
|
|
let status = self.status()?;
|
|
|
|
|
|
|
|
let mut list = Vec::new();
|
|
|
|
|
|
|
|
for drive_status in status.drives.iter() {
|
|
|
|
if let ElementStatus::VolumeTag(ref tag) = drive_status.status {
|
|
|
|
list.push(tag.clone());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (import_export, element_status) in status.slots.iter() {
|
|
|
|
if *import_export { continue; }
|
|
|
|
if let ElementStatus::VolumeTag(ref tag) = element_status {
|
2021-01-08 08:16:42 +00:00
|
|
|
if tag.starts_with("CLN") { continue; }
|
2021-01-07 13:26:43 +00:00
|
|
|
list.push(tag.clone());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok(list)
|
|
|
|
}
|
2020-12-05 13:46:57 +00:00
|
|
|
}
|