]> git.proxmox.com Git - proxmox-backup.git/blame - src/tape/changer/mod.rs
tape: correctly skip cleaning tapes (not regular tapes)
[proxmox-backup.git] / src / tape / changer / mod.rs
CommitLineData
b107fdb9
DM
1mod email;
2pub use email::*;
3
4mod parse_mtx_status;
5pub use parse_mtx_status::*;
6
7mod mtx_wrapper;
8pub use mtx_wrapper::*;
9
10mod linux_tape;
11pub use linux_tape::*;
12
13use anyhow::Error;
14
15/// Interface to media change devices
16pub trait MediaChange {
17
46a1863f
DM
18 /// Returns the changer status
19 fn status(&mut self) -> Result<MtxStatus, Error>;
20
21 /// Load media from storage slot into drive
22 fn load_media_from_slot(&mut self, slot: u64) -> Result<(), Error>;
23
24 /// Load media by changer-id into drive
b107fdb9
DM
25 ///
26 /// This unloads first if the drive is already loaded with another media.
46a1863f
DM
27 ///
28 /// Note: This refuses to load media inside import/export slots.
b107fdb9
DM
29 fn load_media(&mut self, changer_id: &str) -> Result<(), Error>;
30
31 /// Unload media from drive
32 ///
33 /// This is a nop on drives without autoloader.
46a1863f 34 fn unload_media(&mut self, target_slot: Option<u64>) -> Result<(), Error>;
b107fdb9
DM
35
36 /// Returns true if unload_media automatically ejects drive media
37 fn eject_on_unload(&self) -> bool {
38 false
39 }
40
46a1863f
DM
41 /// List online media changer IDs (barcodes)
42 ///
43 /// List acessible (online) changer IDs. This does not include
44 /// media inside import-export slots or cleaning media.
45 fn online_media_changer_ids(&mut self) -> Result<Vec<String>, Error> {
46 let status = self.status()?;
47
48 let mut list = Vec::new();
49
50 for drive_status in status.drives.iter() {
51 if let ElementStatus::VolumeTag(ref tag) = drive_status.status {
52 list.push(tag.clone());
53 }
54 }
55
56 for (import_export, element_status) in status.slots.iter() {
57 if *import_export { continue; }
58 if let ElementStatus::VolumeTag(ref tag) = element_status {
25d39657 59 if tag.starts_with("CLN") { continue; }
46a1863f
DM
60 list.push(tag.clone());
61 }
62 }
63
64 Ok(list)
65 }
b107fdb9 66}