From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <d.csapak@proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by lists.proxmox.com (Postfix) with ESMTPS id DB2D26BF17
 for <pbs-devel@lists.proxmox.com>; Thu, 28 Jan 2021 13:00:35 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id F32912D324
 for <pbs-devel@lists.proxmox.com>; Thu, 28 Jan 2021 13:00:02 +0100 (CET)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [212.186.127.180])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS id 0F3AF2D243
 for <pbs-devel@lists.proxmox.com>; Thu, 28 Jan 2021 12:59:58 +0100 (CET)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id CE6654613E
 for <pbs-devel@lists.proxmox.com>; Thu, 28 Jan 2021 12:59:57 +0100 (CET)
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Date: Thu, 28 Jan 2021 12:59:53 +0100
Message-Id: <20210128115955.23136-14-d.csapak@proxmox.com>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20210128115955.23136-1-d.csapak@proxmox.com>
References: <20210128115955.23136-1-d.csapak@proxmox.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.246 Adjusted score from AWL reputation of From: address
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 RCVD_IN_DNSWL_MED        -2.3 Sender listed at https://www.dnswl.org/,
 medium trust
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See
 http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more
 information. [mod.rs]
Subject: [pbs-devel] [PATCH proxmox-backup v2 13/15] tape/changer: add
 vendor/model to DriveStatus
X-BeenThere: pbs-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox Backup Server development discussion
 <pbs-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pbs-devel/>
List-Post: <mailto:pbs-devel@lists.proxmox.com>
List-Help: <mailto:pbs-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Thu, 28 Jan 2021 12:00:35 -0000

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/tape/changer/mod.rs                  |  4 ++++
 src/tape/changer/mtx/parse_mtx_status.rs |  6 ++++++
 src/tape/changer/sg_pt_changer.rs        | 16 ++++++++++------
 src/tape/drive/virtual_tape.rs           |  2 ++
 4 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/src/tape/changer/mod.rs b/src/tape/changer/mod.rs
index 30e30b94..0d378587 100644
--- a/src/tape/changer/mod.rs
+++ b/src/tape/changer/mod.rs
@@ -38,6 +38,10 @@ pub struct DriveStatus {
     pub status: ElementStatus,
     /// Drive Identifier (Serial number)
     pub drive_serial_number: Option<String>,
+    /// Drive Vendor
+    pub vendor: Option<String>,
+    /// Drive Model
+    pub model: Option<String>,
     /// Element Address
     pub element_address: u16,
 }
diff --git a/src/tape/changer/mtx/parse_mtx_status.rs b/src/tape/changer/mtx/parse_mtx_status.rs
index c042c318..b2f5c5d7 100644
--- a/src/tape/changer/mtx/parse_mtx_status.rs
+++ b/src/tape/changer/mtx/parse_mtx_status.rs
@@ -46,6 +46,8 @@ fn parse_drive_status(i: &str, id: u64) -> IResult<&str, DriveStatus> {
             loaded_slot,
             status: ElementStatus::Empty,
             drive_serial_number: None,
+            vendor: None,
+            model: None,
             element_address: id as u16,
         };
         return Ok((empty, status));
@@ -71,6 +73,8 @@ fn parse_drive_status(i: &str, id: u64) -> IResult<&str, DriveStatus> {
             loaded_slot,
             status: ElementStatus::VolumeTag(tag.to_string()),
             drive_serial_number: None,
+            vendor: None,
+            model: None,
             element_address: id as u16,
         };
         return Ok((i, status));
@@ -82,6 +86,8 @@ fn parse_drive_status(i: &str, id: u64) -> IResult<&str, DriveStatus> {
         loaded_slot,
         status: ElementStatus::Full,
         drive_serial_number: None,
+        vendor: None,
+        model: None,
         element_address: id as u16,
     };
     Ok((i, status))
diff --git a/src/tape/changer/sg_pt_changer.rs b/src/tape/changer/sg_pt_changer.rs
index 85961457..b6c64381 100644
--- a/src/tape/changer/sg_pt_changer.rs
+++ b/src/tape/changer/sg_pt_changer.rs
@@ -641,23 +641,25 @@ fn decode_element_status_page(
 
                         let dvcid: DvcidHead = unsafe { reader.read_be_value()? };
 
-                        let drive_serial_number = match (dvcid.code_set, dvcid.identifier_type) {
+                        let (drive_serial_number, vendor, model) = match (dvcid.code_set, dvcid.identifier_type) {
                             (2, 0) => { // Serial number only (Quantum Superloader3 uses this)
                                 let serial = reader.read_exact_allocated(dvcid.identifier_len as usize)?;
                                 let serial = scsi_ascii_to_string(&serial);
-                                Some(serial)
+                                (Some(serial), None, None)
                             }
                             (2, 1) => {
                                 if dvcid.identifier_len != 34 {
                                     bail!("got wrong DVCID length");
                                 }
-                                let _vendor = reader.read_exact_allocated(8)?;
-                                let _product = reader.read_exact_allocated(16)?;
+                                let vendor = reader.read_exact_allocated(8)?;
+                                let vendor = scsi_ascii_to_string(&vendor);
+                                let model = reader.read_exact_allocated(16)?;
+                                let model = scsi_ascii_to_string(&model);
                                 let serial = reader.read_exact_allocated(10)?;
                                 let serial = scsi_ascii_to_string(&serial);
-                                Some(serial)
+                                (Some(serial), Some(vendor), Some(model))
                             }
-                            _ => None,
+                            _ => (None, None, None),
                         };
 
                         result.last_element_address = Some(desc.element_address);
@@ -666,6 +668,8 @@ fn decode_element_status_page(
                             loaded_slot,
                             status: create_element_status(full, volume_tag),
                             drive_serial_number,
+                            vendor,
+                            model,
                             element_address: desc.element_address,
                         };
                         result.drives.push(drive);
diff --git a/src/tape/drive/virtual_tape.rs b/src/tape/drive/virtual_tape.rs
index 7dea49de..7fbc1167 100644
--- a/src/tape/drive/virtual_tape.rs
+++ b/src/tape/drive/virtual_tape.rs
@@ -399,6 +399,8 @@ impl MediaChange for VirtualTapeHandle {
                 loaded_slot: None,
                 status: ElementStatus::VolumeTag(current_tape.name.clone()),
                 drive_serial_number: None,
+                vendor: None,
+                model: None,
                 element_address: 0,
            });
         }
-- 
2.20.1