]>
Commit | Line | Data |
---|---|---|
b107fdb9 DM |
1 | mod email; |
2 | pub use email::*; | |
3 | ||
4 | mod parse_mtx_status; | |
5 | pub use parse_mtx_status::*; | |
6 | ||
7 | mod mtx_wrapper; | |
8 | pub use mtx_wrapper::*; | |
9 | ||
10 | mod linux_tape; | |
11 | pub use linux_tape::*; | |
12 | ||
13 | use anyhow::Error; | |
14 | ||
15 | /// Interface to media change devices | |
16 | pub 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 | } |