tape: implement eject

This commit is contained in:
Dietmar Maurer
2020-12-09 17:50:48 +01:00
parent 5fb694e8c0
commit 0098b712a5
2 changed files with 68 additions and 0 deletions

View File

@ -108,6 +108,7 @@ fn rewind(
mut param: Value,
rpcenv: &mut dyn RpcEnvironment,
) -> Result<(), Error> {
let (config, _digest) = config::drive::config()?;
param["drive"] = lookup_drive_name(&param, &config)?.into();
@ -122,6 +123,36 @@ fn rewind(
Ok(())
}
#[api(
input: {
properties: {
drive: {
schema: DRIVE_ID_SCHEMA,
optional: true,
},
},
},
)]
/// Eject/Unload drive media
fn eject_media(
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_EJECT_MEDIA;
match info.handler {
ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?,
_ => unreachable!(),
};
Ok(())
}
fn main() {
let cmd_def = CliCommandMap::new()
@ -135,6 +166,11 @@ fn main() {
CliCommand::new(&API_METHOD_ERASE_MEDIA)
.completion_cb("drive", complete_drive_name)
)
.insert(
"eject",
CliCommand::new(&API_METHOD_EJECT_MEDIA)
.completion_cb("drive", complete_drive_name)
)
.insert("changer", changer_commands())
.insert("drive", drive_commands())
;