Skip to content

Commit

Permalink
[plugins] Add function to iterate tape devs
Browse files Browse the repository at this point in the history
Add get_tape_devs() function and other logic
to iterate and gather information about tape
devices.

Related: #2463

Signed-off-by: Jose Castillo <[email protected]>
  • Loading branch information
jcastill committed Jan 12, 2024
1 parent e0b1ece commit 5f01d9f
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion sos/report/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 5f01d9f

Please sign in to comment.