]> git.proxmox.com Git - proxmox-backup.git/commitdiff
tape: add drive activity to drive status api
authorDominik Csapak <d.csapak@proxmox.com>
Mon, 13 May 2024 10:49:24 +0000 (12:49 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 14 May 2024 08:25:42 +0000 (10:25 +0200)
and show it in the gui for single drives. Adds the known values for the
activity to the UI.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
pbs-api-types/src/tape/drive.rs
pbs-tape/src/sg_tape.rs
www/Utils.js
www/tape/DriveStatus.js

index de569980a881cf533652274d9b86c3d825b89dce..caa6b3b3e05dc4b96af98f0dbbe614084feac7f2 100644 (file)
@@ -216,6 +216,9 @@ pub struct LtoDriveAndMediaStatus {
     /// Estimated tape wearout factor (assuming max. 16000 end-to-end passes)
     #[serde(skip_serializing_if = "Option::is_none")]
     pub medium_wearout: Option<f64>,
+    /// Current device activity
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub drive_activity: Option<DeviceActivity>,
 }
 
 #[api()]
index 85be6b0719421efc9526409332b70cb8430a204c..d185dd1ac967fade5920a5b8027ef9e8214c470f 100644 (file)
@@ -31,7 +31,8 @@ use proxmox_io::{ReadExt, WriteExt};
 use proxmox_sys::error::SysResult;
 
 use pbs_api_types::{
-    Lp17VolumeStatistics, LtoDriveAndMediaStatus, LtoTapeDrive, MamAttribute, TapeDensity,
+    DeviceActivity, Lp17VolumeStatistics, LtoDriveAndMediaStatus, LtoTapeDrive, MamAttribute,
+    TapeDensity,
 };
 
 use crate::linux_list_drives::open_lto_tape_device;
@@ -960,6 +961,7 @@ impl SgTape {
     pub fn get_drive_and_media_status(&mut self) -> Result<LtoDriveAndMediaStatus, Error> {
         let drive_status = self.read_drive_status()?;
 
+        let drive_activity = read_device_activity(&mut self.file).ok();
         let alert_flags = self
             .tape_alert_flags()
             .map(|flags| format!("{:?}", flags))
@@ -983,6 +985,7 @@ impl SgTape {
             medium_passes: None,
             medium_wearout: None,
             volume_mounts: None,
+            drive_activity,
         };
 
         if self.test_unit_ready().is_ok() {
index 1d7351a324927f2046548ccc2b79c7b0c882a448..df03a4c87963aaf5afaf2ad918af055ffcdb9bed 100644 (file)
@@ -659,6 +659,9 @@ Ext.define('PBS.Utils', {
            if (key === 'bytes-read' || key === 'bytes-written') {
                val = Proxmox.Utils.format_size(val);
            }
+           if (key === 'drive-activity') {
+               val = PBS.Utils.renderDriveActivity(val);
+           }
            list.push({ key: key, value: val });
        }
 
@@ -692,6 +695,32 @@ Ext.define('PBS.Utils', {
        }).show();
     },
 
+    tapeDriveActivities: {
+       'no-activity': gettext('No Activity'),
+       'cleaning': gettext('Cleaning'),
+       'loading': gettext('Loading'),
+       'unloading': gettext('Unloading'),
+       'other': gettext('Other Activity'),
+       'reading': gettext('Reading data'),
+       'writing': gettext('Writing data'),
+       'locating': gettext('Locating'),
+       'rewinding': gettext('Rewinding'),
+       'erasing': gettext('Erasing'),
+       'formatting': gettext('Formatting'),
+       'calibrating': gettext('Calibrating'),
+       'other-dt': gettext('Other DT Activity'),
+       'microcode-update': gettext('Updating Microcode'),
+       'reading-encrypted': gettext('Reading encrypted data'),
+       'writing-encrypted': gettext('Writing encrypted data'),
+    },
+
+    renderDriveActivity: function(value) {
+       if (!value) {
+           return Proxmox.Utils.unknownText;
+       }
+       return PBS.Utils.tapeDriveActivities[value] ?? value;
+    },
+
     renderDriveState: function(value, md) {
        if (!value) {
            return gettext('Idle');
index 2c55fc97f6c7f521cb2404d96501c62ac97cb5be..a392202ca2787a6421a97618d3de0c72c94d8e5f 100644 (file)
@@ -348,6 +348,10 @@ Ext.define('PBS.TapeManagement.DriveStatusGrid', {
            header: gettext('Compression'),
            renderer: Proxmox.Utils.format_boolean,
        },
+       'drive-activity': {
+           header: gettext('Drive Activity'),
+           renderer: PBS.Utils.renderDriveActivity,
+       },
        'file-number': {
            header: gettext('Tape Position'),
            renderer: function(value, mD, r, rI, cI, store) {