aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Moravec <pmoravec@redhat.com>2019-09-16 17:15:40 +0200
committerJake Hunsaker <jhunsake@redhat.com>2019-10-25 11:57:31 -0400
commit285de0bea2e7d7ada7b938a44639b3ad0ee6d393 (patch)
treec9219b278380b9810871bccae53cc41ede2b0675
parent59132c9250a925b1287eb25227748025bb9e5a55 (diff)
downloadsos-285de0bea2e7d7ada7b938a44639b3ad0ee6d393.tar.gz
[grub2] call grub2-config with --no-grubenv-update when appropriate
On some newer grub2 versions, grub2-config removes extra args in $kernel_opts until --no-grubenv-update option is used. Test if the option is present in "grub2-config --help" and if so, use it. Resolves: #1682 Signed-off-by: Pavel Moravec <pmoravec@redhat.com> Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
-rw-r--r--sos/plugins/__init__.py2
-rw-r--r--sos/plugins/grub2.py12
2 files changed, 11 insertions, 3 deletions
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
index 8084dbfb..e75ec82e 100644
--- a/sos/plugins/__init__.py
+++ b/sos/plugins/__init__.py
@@ -208,7 +208,7 @@ class SoSPredicate(object):
'''Does 'cmd' output contain string 'output'?'''
if 'cmd' not in cmd_output or 'output' not in cmd_output:
return False
- result = self._owner.get_command_output(cmd_output['cmd'])
+ result = sos_get_command_output(cmd_output['cmd'])
if result['status'] != 0:
return False
for line in result['output'].splitlines():
diff --git a/sos/plugins/grub2.py b/sos/plugins/grub2.py
index 9786de44..0ca6fe09 100644
--- a/sos/plugins/grub2.py
+++ b/sos/plugins/grub2.py
@@ -6,7 +6,8 @@
#
# See the LICENSE file in the source distribution for further information.
-from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin
+from sos.plugins import (Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin,
+ SoSPredicate)
class Grub2(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
@@ -32,9 +33,16 @@ class Grub2(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
self.add_cmd_output("ls -lanR /boot")
# call grub2-mkconfig with GRUB_DISABLE_OS_PROBER=true to prevent
# possible unwanted loading of some kernel modules
+ # further, check if the command supports --no-grubenv-update option
+ # to prevent removing of extra args in $kernel_opts, and (only) if so,
+ # call the command with this argument
env = {}
env['GRUB_DISABLE_OS_PROBER'] = 'true'
- self.add_cmd_output("grub2-mkconfig", env=env)
+ grub_cmd = 'grub2-mkconfig'
+ co = {'cmd': 'grub2-mkconfig --help', 'output': '--no-grubenv-update'}
+ if self.test_predicate(self, pred=SoSPredicate(self, cmd_outputs=co)):
+ grub_cmd += ' --no-grubenv-update'
+ self.add_cmd_output(grub_cmd, env=env)
def postproc(self):
# the trailing space is required; python treats '_' as whitespace