Skip to content

Commit 2605e82

Browse files
author
“Samir
committed
Add dynamic detection of SOS “numa” plugin name
Previously, the code used a hard-coded SOS NUMA plugin name (numa1). However, some distributions do not provide the numa1 plugin and instead use numa. This commit adds logic to dynamically detect the supported NUMA plugin for the running distribution. With this change, the correct plugin name (numa1 or numa) is selected automatically at runtime, improving portability across distros. Signed-off-by: “Samir <“[email protected]”> Removed unwanted print statements. Removed unwanted print debug statements. Signed-off-by: “Samir <“[email protected]”>
1 parent 4251053 commit 2605e82

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

ras/sosreport.py

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,24 @@ def run_cmd_search(self, cmd, search_str):
4949
if search_str in line:
5050
return line.strip()
5151

52+
def get_sos_plugin(self):
53+
"""
54+
Here we are trying to fetch the supported numa plugin
55+
as per the linux distro.
56+
"""
57+
matched_plugin = ""
58+
cmd = "sos report --list-plugins"
59+
sos_plugin = self.run_cmd_out(cmd)
60+
plain_payload = sos_plugin.split('\n')
61+
for plugins in plain_payload:
62+
if "numa" in plugins or "numa1" in plugins:
63+
match = re.match(r"^(\w+)\s+(.*)$", plugins.strip())
64+
if match:
65+
matched_plugin = match.group(1)
66+
break
67+
68+
return matched_plugin
69+
5270
def setUp(self):
5371
dist = distro.detect()
5472
sm = SoftwareManager()
@@ -184,6 +202,7 @@ def test_others(self):
184202
"""
185203
self.log.info(
186204
"===============Executing sosreport tool test (others)===============")
205+
sos_supported_plugin = self.get_sos_plugin()
187206
directory_name = tempfile.mkdtemp()
188207
self.is_fail = 0
189208
self.run_cmd("%s --list-profiles" % self.sos_cmd, None)
@@ -199,13 +218,15 @@ def test_others(self):
199218

200219
dir_name = self.run_cmd_search(
201220
"%s --batch --tmp-dir=%s --build" % (self.sos_cmd, directory_name), directory_name)
221+
202222
if not os.path.isdir(dir_name):
203223
self.is_fail += 1
204224
self.log.info("--build option failed")
205225

206-
if "version" not in self.run_cmd_out("%s --batch --tmp-dir=%s --quiet "
207-
"--no-report -e ntp,numa1"
208-
% (self.sos_cmd, directory_name)):
226+
if not self.run_cmd_out("%s --batch --tmp-dir=%s --quiet "
227+
"--no-report -e ntp,%s"
228+
% (self.sos_cmd, directory_name,
229+
sos_supported_plugin)):
209230
self.is_fail += 1
210231
self.log.info("--quiet --no-report option failed")
211232
self.run_cmd("%s --batch --tmp-dir=%s --debug" %
@@ -223,13 +244,13 @@ def test_others(self):
223244
self.is_fail += 1
224245
self.log.info("--no-report option failed")
225246
if 'powerpc' in cpu.get_arch():
226-
file_list = self.params.get('file_list', default=['proc/device-tree/'])
247+
file_list = self.params.get(
248+
'file_list', default=['proc/device-tree/'])
227249
for files in file_list:
228250
file_path = os.path.join(dir_name, files)
229251
if not os.path.exists(file_path):
230252
self.is_fail += 1
231253
self.log.info("%s file/directory not created" % file_path)
232-
233254
self.run_cmd("%s --batch --tmp-dir=%s -s /" %
234255
(self.sos_cmd, directory_name))
235256

@@ -270,7 +291,8 @@ def test_archive(self):
270291

271292
if os.path.exists(file_name):
272293
md5_sum1 = self.run_cmd_out("cat %s.md5" % file_name).strip()
273-
md5_sum2 = self.run_cmd_out("md5sum %s" % file_name).strip().split()[0]
294+
md5_sum2 = self.run_cmd_out(
295+
"md5sum %s" % file_name).strip().split()[0]
274296
if md5_sum1 != md5_sum2:
275297
self.is_fail += 1
276298
self.log.info("md5sum check failed")
@@ -390,7 +412,8 @@ def test_fs(self):
390412
if not mnt:
391413
mnt = self.workdir
392414
if 'blockfile' not in self.run_cmd_out("ls /tmp"):
393-
blk_dev = process.run("dd if=/dev/zero of=/tmp/blockfile bs=1M count=5120")
415+
blk_dev = process.run(
416+
"dd if=/dev/zero of=/tmp/blockfile bs=1M count=5120")
394417
process.run("losetup %s /tmp/blockfile" % loop_dev)
395418
if fstype == "ext4":
396419
cmd = "mkfs.%s %s" % (fstype, loop_dev)

0 commit comments

Comments
 (0)