tape: use worker tasks for media load/unload

This commit is contained in:
Dietmar Maurer
2021-02-18 09:04:51 +01:00
parent bbe06f97be
commit d0647e5a02
2 changed files with 79 additions and 18 deletions

View File

@ -206,12 +206,18 @@ async fn eject_media(mut param: Value) -> Result<(), Error> {
"label-text": {
schema: MEDIA_LABEL_SCHEMA,
},
"output-format": {
schema: OUTPUT_FORMAT,
optional: true,
},
},
},
)]
/// Load media with specified label
async fn load_media(mut param: Value) -> Result<(), Error> {
let output_format = get_output_format(&param);
let (config, _digest) = config::drive::config()?;
let drive = extract_drive_name(&mut param, &config)?;
@ -219,7 +225,9 @@ async fn load_media(mut param: Value) -> Result<(), Error> {
let mut client = connect_to_localhost()?;
let path = format!("api2/json/tape/drive/{}/load-media", drive);
client.put(&path, Some(param)).await?;
let result = client.post(&path, Some(param)).await?;
view_task_result(&mut client, result, &output_format).await?;
Ok(())
}
@ -295,12 +303,18 @@ async fn load_media_from_slot(mut param: Value) -> Result<(), Error> {
minimum: 1,
optional: true,
},
"output-format": {
schema: OUTPUT_FORMAT,
optional: true,
},
},
},
)]
/// Unload media via changer
async fn unload_media(mut param: Value) -> Result<(), Error> {
let output_format = get_output_format(&param);
let (config, _digest) = config::drive::config()?;
let drive = extract_drive_name(&mut param, &config)?;
@ -308,7 +322,9 @@ async fn unload_media(mut param: Value) -> Result<(), Error> {
let mut client = connect_to_localhost()?;
let path = format!("api2/json/tape/drive/{}/unload", drive);
client.put(&path, Some(param)).await?;
let result = client.post(&path, Some(param)).await?;
view_task_result(&mut client, result, &output_format).await?;
Ok(())
}