[pbs-devel] [PATCH proxmox-backup 1/5] api2/tape/drive: add state to DriveListEntry

Dominik Csapak d.csapak at proxmox.com
Tue Mar 2 12:19:36 CET 2021


Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 src/api2/tape/drive.rs       | 4 +++-
 src/api2/types/tape/drive.rs | 3 +++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/api2/tape/drive.rs b/src/api2/tape/drive.rs
index 6ef6a78b..f3cb1470 100644
--- a/src/api2/tape/drive.rs
+++ b/src/api2/tape/drive.rs
@@ -64,6 +64,7 @@ use crate::{
             open_drive,
             lock_tape_device,
             set_tape_device_state,
+            get_tape_device_state,
         },
         changer::update_changer_online_status,
     },
@@ -1223,7 +1224,8 @@ pub fn list_drives(
         }
 
         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);
     }
 
diff --git a/src/api2/types/tape/drive.rs b/src/api2/types/tape/drive.rs
index 067fdeba..2fd480ac 100644
--- a/src/api2/types/tape/drive.rs
+++ b/src/api2/types/tape/drive.rs
@@ -99,6 +99,9 @@ pub struct DriveListEntry {
     pub config: LinuxTapeDrive,
     #[serde(flatten)]
     pub info: OptionalDeviceIdentification,
+    /// the state of the drive if locked
+    #[serde(skip_serializing_if="Option::is_none")]
+    pub state: Option<String>,
 }
 
 #[api()]
-- 
2.20.1






More information about the pbs-devel mailing list