tape: implement drive clean

This commit is contained in:
Dietmar Maurer
2021-01-08 11:32:56 +01:00
parent 25d3965769
commit df69a4fc59
5 changed files with 148 additions and 0 deletions

View File

@ -677,6 +677,38 @@ fn status(
Ok(())
}
#[api(
input: {
properties: {
drive: {
schema: DRIVE_NAME_SCHEMA,
optional: true,
},
},
},
)]
/// Clean drive
async fn clean_drive(
mut param: Value,
rpcenv: &mut dyn RpcEnvironment,
) -> Result<(), Error> {
let (config, _digest) = config::drive::config()?;
param["drive"] = lookup_drive_name(&param, &config)?.into();
let info = &api2::tape::drive::API_METHOD_CLEAN_DRIVE;
let result = match info.handler {
ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?,
_ => unreachable!(),
};
wait_for_local_worker(result.as_str().unwrap()).await?;
Ok(())
}
#[api(
input: {
properties: {
@ -856,6 +888,11 @@ fn main() {
CliCommand::new(&API_METHOD_CARTRIDGE_MEMORY)
.completion_cb("drive", complete_drive_name)
)
.insert(
"clean",
CliCommand::new(&API_METHOD_CLEAN_DRIVE)
.completion_cb("drive", complete_drive_name)
)
.insert(
"label",
CliCommand::new(&API_METHOD_LABEL_MEDIA)