From 5f01d9f0ac948647e0a816fbb627ab22fcea8b5a Mon Sep 17 00:00:00 2001 From: Jose Castillo Date: Fri, 12 Jan 2024 14:12:18 +0000 Subject: [PATCH 1/2] [plugins] Add function to iterate tape devs Add get_tape_devs() function and other logic to iterate and gather information about tape devices. Related: #2463 Signed-off-by: Jose Castillo --- sos/report/__init__.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/sos/report/__init__.py b/sos/report/__init__.py index 591782eedd..21c9a1bde0 100644 --- a/sos/report/__init__.py +++ b/sos/report/__init__.py @@ -424,7 +424,8 @@ def _get_hardware_devices(self): self.devices = { 'storage': { 'block': self._get_block_devs(), - 'fibre': self._get_fibre_devs() + 'fibre': self._get_fibre_devs(), + 'tape': self._get_tape_devs(), }, 'network': self._get_network_devs(), 'namespaced_network': self._get_network_namespace_devices() @@ -506,6 +507,26 @@ def _get_block_devs(self): self.soslog.error("Could not get block device list: %s" % err) return [] + def _get_tape_devs(self): + """Enumerate a list of tape devices on this system so that plugins + can iterate over them + + These devices are used by add_device_cmd() in the Plugin class. + """ + try: + devs = [] + devdirs = [ + 'scsi_tape', + 'lin_tape' + ] + for devdir in devdirs: + if os.path.isdir(f"/sys/class/{devdir}"): + devs.extend(glob.glob(f"/sys/class/{devdir}/*")) + return devs + except Exception as err: + self.soslog.error(f"Could not get tape device list: {err}") + return [] + def _get_namespaces(self): self.namespaces = { 'network': self._get_network_namespaces() From 063d1124b6397879aeb1bc0a24dc8736349857f3 Mon Sep 17 00:00:00 2001 From: Jose Castillo Date: Fri, 12 Jan 2024 16:39:50 +0000 Subject: [PATCH 2/2] [scsi] Capture udevadm information for tape devices Capture udevadm info for tape devices. Related: #2463 Signed-off-by: Jose Castillo --- sos/report/__init__.py | 3 +-- sos/report/plugins/scsi.py | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sos/report/__init__.py b/sos/report/__init__.py index 21c9a1bde0..41d79d2776 100644 --- a/sos/report/__init__.py +++ b/sos/report/__init__.py @@ -520,8 +520,7 @@ def _get_tape_devs(self): 'lin_tape' ] for devdir in devdirs: - if os.path.isdir(f"/sys/class/{devdir}"): - devs.extend(glob.glob(f"/sys/class/{devdir}/*")) + devs.extend(glob.glob(f"/sys/class/{devdir}/*")) return devs except Exception as err: self.soslog.error(f"Could not get tape device list: {err}") diff --git a/sos/report/plugins/scsi.py b/sos/report/plugins/scsi.py index 1589c20ac7..bf55a394ad 100644 --- a/sos/report/plugins/scsi.py +++ b/sos/report/plugins/scsi.py @@ -63,6 +63,7 @@ def setup(self): scsi_hosts = glob("/sys/class/scsi_host/*") self.add_device_cmd("udevadm info -a %(dev)s", devices=scsi_hosts) + self.add_device_cmd("udevadm info -a %(dev)s", devices="tape") self.add_device_cmd([ "sg_persist --in -k -d %(dev)s",