tape: add volume-statistics api/command

This commit is contained in:
Dietmar Maurer
2021-01-22 08:45:35 +01:00
parent 337ff5a3cc
commit 5f34d69bcc
3 changed files with 104 additions and 3 deletions

View File

@ -664,6 +664,44 @@ fn cartridge_memory(
Ok(())
}
#[api(
input: {
properties: {
drive: {
schema: DRIVE_NAME_SCHEMA,
optional: true,
},
"output-format": {
schema: OUTPUT_FORMAT,
optional: true,
},
},
},
)]
/// Read Volume Statistics (SCSI log page 17h)
fn volume_statistics(
mut param: Value,
rpcenv: &mut dyn RpcEnvironment,
) -> Result<(), Error> {
let (config, _digest) = config::drive::config()?;
param["drive"] = lookup_drive_name(&param, &config)?.into();
let output_format = get_output_format(&param);
let info = &api2::tape::drive::API_METHOD_VOLUME_STATISTICS;
let mut data = match info.handler {
ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?,
_ => unreachable!(),
};
let options = default_table_format_options();
format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
Ok(())
}
#[api(
input: {
properties: {
@ -943,6 +981,11 @@ fn main() {
CliCommand::new(&API_METHOD_CARTRIDGE_MEMORY)
.completion_cb("drive", complete_drive_name)
)
.insert(
"volume-statistics",
CliCommand::new(&API_METHOD_VOLUME_STATISTICS)
.completion_cb("drive", complete_drive_name)
)
.insert(
"clean",
CliCommand::new(&API_METHOD_CLEAN_DRIVE)