aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2018-06-20 16:21:20 +0100
committerBryn M. Reeves <bmr@redhat.com>2018-06-20 16:21:20 +0100
commitf57e6df8b59fe81024cac58bf81bcc536e6dafc5 (patch)
treefc3e9be59040ff4e176c4c75c312cb1403a9723d
parent98320d3730aa267c82bd6ae8d7184895726d18f8 (diff)
downloadsos-f57e6df8b59fe81024cac58bf81bcc536e6dafc5.tar.gz
[fibrechannel] do not attempt to list non-existent directories
Use a list comprehension to both generate the list of paths to collect, and to filter out any directories in the standard list of fibrechannel paths that do not exist on the running system. Resolves: #1353 Related: #1341 Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/plugins/fibrechannel.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/sos/plugins/fibrechannel.py b/sos/plugins/fibrechannel.py
index 570c385e..fdca6d47 100644
--- a/sos/plugins/fibrechannel.py
+++ b/sos/plugins/fibrechannel.py
@@ -8,9 +8,11 @@
#
# See the LICENSE file in the source distribution for further information.
-import os
from sos.plugins import Plugin, RedHatPlugin
+from os import listdir
+from os.path import isdir, join
+
class Fibrechannel(Plugin, RedHatPlugin):
'''Collects information on fibrechannel devices, if present'''
@@ -21,17 +23,13 @@ class Fibrechannel(Plugin, RedHatPlugin):
def setup(self):
- devs = []
dirs = [
'/sys/class/fc_host/',
'/sys/class/fc_remote_ports/',
'/sys/class/fc_transport/'
]
- for loc in dirs:
- devs.extend([loc + device for device in os.listdir(loc)
- if os.path.isdir(loc)])
-
+ devs = [join(d, dev) for d in dirs for dev in listdir(d) if isdir(d)]
if devs:
self.add_udev_info(devs, attrs=True)