tape: implement inventory command

This commit is contained in:
Dietmar Maurer
2020-12-11 07:39:28 +01:00
parent 8bc5eebeb8
commit 83abc7497d
4 changed files with 206 additions and 13 deletions

View File

@ -29,6 +29,7 @@ use crate::{
},
tape::{
TAPE_STATUS_DIR,
MediaLabelInfo,
file_formats::{
DriveLabel,
MediaSetLabel,
@ -46,6 +47,16 @@ pub struct MediaId {
pub media_set_label: Option<MediaSetLabel>,
}
impl From<MediaLabelInfo> for MediaId {
fn from(info: MediaLabelInfo) -> Self {
Self {
label: info.label.clone(),
media_set_label: info.media_set_label.map(|(l, _)| l),
}
}
}
/// Media Set
///
/// A List of backup media
@ -240,17 +251,6 @@ impl Inventory {
Ok(())
}
/*
/// Same a store, but extract MediaId form MediaLabelInfo
pub fn store_media_info(&mut self, info: &MediaLabelInfo) -> Result<(), Error> {
let media_id = MediaId {
label: info.label.clone(),
media_set_label: info.media_set_label.clone().map(|(l, _)| l),
};
self.store(media_id)
}
*/
/// Lookup media
pub fn lookup_media(&self, uuid: &Uuid) -> Option<&MediaId> {
self.map.get(uuid)