aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2018-04-26 12:42:00 +0100
committerBryn M. Reeves <bmr@redhat.com>2018-04-26 12:42:00 +0100
commit78851871666675f226e8b8886246107df343ab15 (patch)
treed723ed8732bd022fe80a71f2e0fc27054f988e7d
parent18b153ffdbd5a6319e3aea0f7eea6c2831d6a95e (diff)
downloadsos-78851871666675f226e8b8886246107df343ab15.tar.gz
[yum] fix yum plugin data collection
Don't attempt to add a null string if there are no plugins to report on, and improve the formatting of the plugin-names and plugin-packages files. Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/plugins/yum.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/sos/plugins/yum.py b/sos/plugins/yum.py
index 1db5189a..1746389c 100644
--- a/sos/plugins/yum.py
+++ b/sos/plugins/yum.py
@@ -50,15 +50,17 @@ class Yum(Plugin, RedHatPlugin):
# Get list of available plugins and their configuration files.
if os.path.exists(YUM_PLUGIN_PATH) and os.path.isdir(YUM_PLUGIN_PATH):
plugins = ""
- names = ""
for p in os.listdir(YUM_PLUGIN_PATH):
if not p.endswith(".py"):
continue
plugins = plugins + " " if len(plugins) else ""
plugins = plugins + os.path.join(YUM_PLUGIN_PATH, p)
- names += "%s\n" % p[:-3]
- self.add_cmd_output("rpm -qf %s" % plugins)
- self.add_string_as_file(names, "plugin-names")
+ if len(plugins):
+ self.add_cmd_output("rpm -qf %s" % plugins,
+ suggest_filename="plugin-packages")
+ plugnames = [os.path.basename(p)[:-3] for p in plugins.split()]
+ plugnames = "%s\n" % "\n".join(plugnames)
+ self.add_string_as_file(plugnames, "plugin-names")
self.add_copy_spec("/etc/yum/pluginconf.d")