tape: add drive status api
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
//! Types for tape drive API
|
||||
use std::convert::TryFrom;
|
||||
|
||||
use anyhow::{bail, Error};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use proxmox::api::{
|
||||
@ -111,3 +113,69 @@ pub struct MamAttribute {
|
||||
/// Attribute value
|
||||
pub value: String,
|
||||
}
|
||||
|
||||
#[api()]
|
||||
#[derive(Serialize,Deserialize,Debug)]
|
||||
pub enum TapeDensity {
|
||||
/// No tape loaded
|
||||
None,
|
||||
/// LTO2
|
||||
LTO2,
|
||||
/// LTO3
|
||||
LTO3,
|
||||
/// LTO4
|
||||
LTO4,
|
||||
/// LTO5
|
||||
LTO5,
|
||||
/// LTO6
|
||||
LTO6,
|
||||
/// LTO7
|
||||
LTO7,
|
||||
/// LTO7M8
|
||||
LTO7M8,
|
||||
/// LTO8
|
||||
LTO8,
|
||||
}
|
||||
|
||||
impl TryFrom<u8> for TapeDensity {
|
||||
type Error = Error;
|
||||
|
||||
fn try_from(value: u8) -> Result<Self, Self::Error> {
|
||||
let density = match value {
|
||||
0x00 => TapeDensity::None,
|
||||
0x42 => TapeDensity::LTO2,
|
||||
0x44 => TapeDensity::LTO3,
|
||||
0x46 => TapeDensity::LTO4,
|
||||
0x58 => TapeDensity::LTO5,
|
||||
0x5a => TapeDensity::LTO6,
|
||||
0x5c => TapeDensity::LTO7,
|
||||
0x5d => TapeDensity::LTO7M8,
|
||||
0x5e => TapeDensity::LTO8,
|
||||
_ => bail!("unknown tape density code 0x{:02x}", value),
|
||||
};
|
||||
Ok(density)
|
||||
}
|
||||
}
|
||||
|
||||
#[api(
|
||||
properties: {
|
||||
density: {
|
||||
type: TapeDensity,
|
||||
},
|
||||
},
|
||||
)]
|
||||
#[derive(Serialize,Deserialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
/// Drive status for Linux SCSI drives.
|
||||
pub struct LinuxDriveStatusFlat {
|
||||
/// Block size (0 is variable size)
|
||||
pub blocksize: u32,
|
||||
/// Tape density
|
||||
pub density: TapeDensity,
|
||||
/// Status flags
|
||||
pub status: String,
|
||||
/// Current file number
|
||||
pub file_number: i32,
|
||||
/// Current block number
|
||||
pub block_number: i32,
|
||||
}
|
||||
|
Reference in New Issue
Block a user