tape: add drive status api
This commit is contained in:
@ -554,6 +554,50 @@ fn cartridge_memory(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[api(
|
||||
input: {
|
||||
properties: {
|
||||
drive: {
|
||||
schema: DRIVE_NAME_SCHEMA,
|
||||
optional: true,
|
||||
},
|
||||
"output-format": {
|
||||
schema: OUTPUT_FORMAT,
|
||||
optional: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
)]
|
||||
/// Get drive status
|
||||
fn status(
|
||||
mut param: Value,
|
||||
rpcenv: &mut dyn RpcEnvironment,
|
||||
) -> Result<(), Error> {
|
||||
|
||||
let (config, _digest) = config::drive::config()?;
|
||||
|
||||
param["drive"] = lookup_drive_name(¶m, &config)?.into();
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
let info = &api2::tape::drive::API_METHOD_STATUS;
|
||||
|
||||
let mut data = match info.handler {
|
||||
ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
let options = default_table_format_options()
|
||||
.column(ColumnConfig::new("blocksize"))
|
||||
.column(ColumnConfig::new("density"))
|
||||
.column(ColumnConfig::new("status"))
|
||||
.column(ColumnConfig::new("file-number"))
|
||||
.column(ColumnConfig::new("block-number"))
|
||||
;
|
||||
|
||||
format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[api(
|
||||
input: {
|
||||
properties: {
|
||||
@ -610,6 +654,11 @@ fn main() {
|
||||
CliCommand::new(&API_METHOD_DEBUG_SCAN)
|
||||
.completion_cb("drive", complete_drive_name)
|
||||
)
|
||||
.insert(
|
||||
"status",
|
||||
CliCommand::new(&API_METHOD_STATUS)
|
||||
.completion_cb("drive", complete_drive_name)
|
||||
)
|
||||
.insert(
|
||||
"eod",
|
||||
CliCommand::new(&API_METHOD_MOVE_TO_EOM)
|
||||
|
Reference in New Issue
Block a user