From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id A3F581FF398 for ; Mon, 13 May 2024 12:49:51 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E3C4A13AC1; Mon, 13 May 2024 12:50:01 +0200 (CEST) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Mon, 13 May 2024 12:49:26 +0200 Message-Id: <20240513104926.3113394-5-d.csapak@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240513104926.3113394-1-d.csapak@proxmox.com> References: <20240513104926.3113394-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.016 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH proxmox-backup 4/4] tape: include drive activity in status X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" Since we don't query each drives status seperately, but rely on a single call to the drives listing parameter for that, we now add the option to query the activity there too. This makes that data avaiable for us to show in a seperate (by default hidden) column. Also we show the activity in the 'State' column when the drive is idle from our perspective. This is useful when e.g. an LTO-9 tape is loaded the first time and is calibrating, since that happens automatically. Signed-off-by: Dominik Csapak --- pbs-api-types/src/tape/drive.rs | 3 +++ pbs-tape/src/sg_tape.rs | 6 ++++++ src/api2/tape/drive.rs | 14 ++++++++++++++ www/Utils.js | 5 ++++- www/tape/ChangerStatus.js | 11 +++++++++-- 5 files changed, 36 insertions(+), 3 deletions(-) diff --git a/pbs-api-types/src/tape/drive.rs b/pbs-api-types/src/tape/drive.rs index caa6b3b3e..2b788bd67 100644 --- a/pbs-api-types/src/tape/drive.rs +++ b/pbs-api-types/src/tape/drive.rs @@ -93,6 +93,9 @@ pub struct DriveListEntry { /// the state of the drive if locked #[serde(skip_serializing_if = "Option::is_none")] pub state: Option, + /// Current device activity + #[serde(skip_serializing_if = "Option::is_none")] + pub activity: Option, } #[api()] diff --git a/pbs-tape/src/sg_tape.rs b/pbs-tape/src/sg_tape.rs index 5cda91943..f30481b31 100644 --- a/pbs-tape/src/sg_tape.rs +++ b/pbs-tape/src/sg_tape.rs @@ -172,6 +172,12 @@ impl SgTape { }) } + /// Read device activity + pub fn device_activity(config: &LtoTapeDrive) -> Result { + let mut file = open_lto_tape_device(&config.path)?; + read_device_activity(&mut file) + } + /// Access to file descriptor - useful for testing pub fn file_mut(&mut self) -> &mut File { &mut self.file diff --git a/src/api2/tape/drive.rs b/src/api2/tape/drive.rs index 5a5d39d9e..7a791e09b 100644 --- a/src/api2/tape/drive.rs +++ b/src/api2/tape/drive.rs @@ -3,6 +3,7 @@ use std::panic::UnwindSafe; use std::sync::Arc; use anyhow::{bail, format_err, Error}; +use pbs_tape::sg_tape::SgTape; use serde_json::Value; use proxmox_router::{ @@ -1411,6 +1412,12 @@ pub fn catalog_media( schema: CHANGER_NAME_SCHEMA, optional: true, }, + "query-activity": { + type: bool, + description: "If true, queries and returns the drive activity for each drive.", + optional: true, + default: false, + }, }, }, returns: { @@ -1428,6 +1435,7 @@ pub fn catalog_media( /// List drives pub fn list_drives( changer: Option, + query_activity: bool, _param: Value, rpcenv: &mut dyn RpcEnvironment, ) -> Result, Error> { @@ -1454,10 +1462,16 @@ pub fn list_drives( let info = lookup_device_identification(<o_drives, &drive.path); let state = get_tape_device_state(&config, &drive.name)?; + let activity = if query_activity { + SgTape::device_activity(&drive).ok() + } else { + None + }; let entry = DriveListEntry { config: drive, info, state, + activity, }; list.push(entry); } diff --git a/www/Utils.js b/www/Utils.js index df03a4c87..4853be36c 100644 --- a/www/Utils.js +++ b/www/Utils.js @@ -721,8 +721,11 @@ Ext.define('PBS.Utils', { return PBS.Utils.tapeDriveActivities[value] ?? value; }, - renderDriveState: function(value, md) { + renderDriveState: function(value, md, rec) { if (!value) { + if (rec?.data?.activity && rec?.data?.activity !== 'no-activity') { + return PBS.Utils.renderDriveActivity(rec.data.activity); + } return gettext('Idle'); } diff --git a/www/tape/ChangerStatus.js b/www/tape/ChangerStatus.js index fdafc459e..e18af90e4 100644 --- a/www/tape/ChangerStatus.js +++ b/www/tape/ChangerStatus.js @@ -1,6 +1,6 @@ Ext.define('pbs-slot-model', { extend: 'Ext.data.Model', - fields: ['entry-id', 'label-text', 'is-labeled', ' model', 'name', 'vendor', 'serial', 'state', 'status', 'pool', + fields: ['entry-id', 'label-text', 'is-labeled', ' model', 'name', 'vendor', 'serial', 'state', 'status', 'pool', 'activity', { name: 'is-blocked', calculate: function(data) { @@ -488,7 +488,7 @@ Ext.define('PBS.TapeManagement.ChangerStatus', { }); let drives_fut = Proxmox.Async.api2({ timeout: 5*60*1000, - url: `/api2/extjs/tape/drive?changer=${encodeURIComponent(changer)}`, + url: `/api2/extjs/tape/drive?query-activity=true&changer=${encodeURIComponent(changer)}`, }); let tapes_fut = Proxmox.Async.api2({ @@ -852,6 +852,13 @@ Ext.define('PBS.TapeManagement.ChangerStatus', { flex: 1, renderer: Ext.htmlEncode, }, + { + text: gettext('Activity'), + dataIndex: 'activity', + renderer: PBS.Utils.renderDriveActivity, + hidden: true, + flex: 1, + }, { text: gettext('State'), dataIndex: 'state', -- 2.39.2 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel