tape: add --inventorize flag to read-label API/CLI
This commit is contained in:
parent
646221cc29
commit
781da7f6f0
@ -462,6 +462,10 @@ fn write_media_label(
|
|||||||
drive: {
|
drive: {
|
||||||
schema: DRIVE_NAME_SCHEMA,
|
schema: DRIVE_NAME_SCHEMA,
|
||||||
},
|
},
|
||||||
|
inventorize: {
|
||||||
|
description: "Inventorize media",
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
returns: {
|
returns: {
|
||||||
@ -469,7 +473,10 @@ fn write_media_label(
|
|||||||
},
|
},
|
||||||
)]
|
)]
|
||||||
/// Read media label
|
/// Read media label
|
||||||
pub async fn read_label(drive: String) -> Result<MediaIdFlat, Error> {
|
pub async fn read_label(
|
||||||
|
drive: String,
|
||||||
|
inventorize: Option<bool>,
|
||||||
|
) -> Result<MediaIdFlat, Error> {
|
||||||
|
|
||||||
let (config, _digest) = config::drive::config()?;
|
let (config, _digest) = config::drive::config()?;
|
||||||
|
|
||||||
@ -489,12 +496,19 @@ pub async fn read_label(drive: String) -> Result<MediaIdFlat, Error> {
|
|||||||
pool: None,
|
pool: None,
|
||||||
seq_nr: None,
|
seq_nr: None,
|
||||||
};
|
};
|
||||||
if let Some(set) = media_id.media_set_label {
|
if let Some(ref set) = media_id.media_set_label {
|
||||||
flat.pool = Some(set.pool.clone());
|
flat.pool = Some(set.pool.clone());
|
||||||
flat.seq_nr = Some(set.seq_nr);
|
flat.seq_nr = Some(set.seq_nr);
|
||||||
flat.media_set_uuid = Some(set.uuid.to_string());
|
flat.media_set_uuid = Some(set.uuid.to_string());
|
||||||
flat.media_set_ctime = Some(set.ctime);
|
flat.media_set_ctime = Some(set.ctime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(true) = inventorize {
|
||||||
|
let state_path = Path::new(TAPE_STATUS_DIR);
|
||||||
|
let mut inventory = Inventory::load(state_path)?;
|
||||||
|
inventory.store(media_id, false)?;
|
||||||
|
}
|
||||||
|
|
||||||
flat
|
flat
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
|
@ -386,6 +386,11 @@ async fn label_media(
|
|||||||
schema: DRIVE_NAME_SCHEMA,
|
schema: DRIVE_NAME_SCHEMA,
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
|
inventorize: {
|
||||||
|
description: "Inventorize media",
|
||||||
|
type: bool,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
"output-format": {
|
"output-format": {
|
||||||
schema: OUTPUT_FORMAT,
|
schema: OUTPUT_FORMAT,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
Loading…
Reference in New Issue
Block a user