api2/tape/drive: add state to DriveListEntry

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2021-03-02 12:19:36 +01:00 committed by Dietmar Maurer
parent 2970cd3d6d
commit 8bf5769382
2 changed files with 6 additions and 1 deletions

View File

@ -64,6 +64,7 @@ use crate::{
open_drive, open_drive,
lock_tape_device, lock_tape_device,
set_tape_device_state, set_tape_device_state,
get_tape_device_state,
}, },
changer::update_changer_online_status, changer::update_changer_online_status,
}, },
@ -1223,7 +1224,8 @@ pub fn list_drives(
} }
let info = lookup_device_identification(&linux_drives, &drive.path); let info = lookup_device_identification(&linux_drives, &drive.path);
let entry = DriveListEntry { config: drive, info }; let state = get_tape_device_state(&config, &drive.name)?;
let entry = DriveListEntry { config: drive, info, state };
list.push(entry); list.push(entry);
} }

View File

@ -99,6 +99,9 @@ pub struct DriveListEntry {
pub config: LinuxTapeDrive, pub config: LinuxTapeDrive,
#[serde(flatten)] #[serde(flatten)]
pub info: OptionalDeviceIdentification, pub info: OptionalDeviceIdentification,
/// the state of the drive if locked
#[serde(skip_serializing_if="Option::is_none")]
pub state: Option<String>,
} }
#[api()] #[api()]