tape: implement read_volume_statistics

This commit is contained in:
Dietmar Maurer
2021-01-05 12:58:18 +01:00
parent 470f1c798a
commit f8ccbfdedd
4 changed files with 319 additions and 0 deletions

View File

@ -122,6 +122,31 @@ fn tape_alert_flags(
Ok(())
}
#[api(
input: {
properties: {
device: {
schema: LINUX_DRIVE_PATH_SCHEMA,
optional: true,
},
},
},
)]
/// Read volume statistics
fn volume_statistics(
device: Option<String>,
) -> Result<(), Error> {
let result = proxmox::try_block!({
let mut handle = get_tape_handle(device)?;
handle.volume_statistics()
}).map_err(|err: Error| err.to_string());
println!("{}", serde_json::to_string_pretty(&result)?);
Ok(())
}
fn main() -> Result<(), Error> {
// check if we are user root or backup
@ -157,6 +182,10 @@ fn main() -> Result<(), Error> {
"tape-alert-flags",
CliCommand::new(&API_METHOD_TAPE_ALERT_FLAGS)
)
.insert(
"volume-statistics",
CliCommand::new(&API_METHOD_VOLUME_STATISTICS)
)
;
let mut rpcenv = CliEnvironment::new();