diff --git a/insights/combiners/grubby.py b/insights/combiners/grubby.py index 1e003e426..98f023ecd 100644 --- a/insights/combiners/grubby.py +++ b/insights/combiners/grubby.py @@ -1,7 +1,6 @@ """ Grubby ====== - Combiner for command ``/usr/sbin/grubby`` parsers. This combiner uses the parsers: @@ -28,16 +27,20 @@ class Grubby(object): Raises: ParseException: when parsing into error. """ + def __init__(self, grubby_info_all, grubby_default_index): self.boot_entries = grubby_info_all.boot_entries self.default_index = grubby_default_index.default_index if self.default_index not in self.boot_entries: - raise ParseException("DEFAULT index %s not exist in parsed boot_entries: %s" % - (self.default_index, list(self.boot_entries.keys()))) + raise ParseException( + "DEFAULT index %s not exist in parsed boot_entries: %s" + % (self.default_index, list(self.boot_entries.keys())) + ) self.default_boot_entry = self.boot_entries[self.default_index] self.default_kernel = self.default_boot_entry.get("kernel") if not self.default_kernel: - raise ParseException("DEFAULT kernel-path not exist in default-index: %s" % - self.default_index) + raise ParseException( + "DEFAULT kernel-path not exist in default-index: %s" % self.default_index + ) diff --git a/insights/parsers/grubby.py b/insights/parsers/grubby.py index 4e0d3eb69..f5872b975 100644 --- a/insights/parsers/grubby.py +++ b/insights/parsers/grubby.py @@ -1,5 +1,5 @@ """ -grubby - command ``/usr/sbin/grubby`` +Grubby - command ``/usr/sbin/grubby`` ===================================== This is a collection of parsers that all deal with the command ``grubby``. @@ -14,6 +14,7 @@ GrubbyInfoAll - command ``grubby --info=ALL`` --------------------------------------------- """ + from insights.core import CommandParser from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser @@ -41,6 +42,7 @@ class GrubbyDefaultIndex(CommandParser): Attributes: default_index (int): the numeric index of the current default boot entry, count from 0 """ + def parse_content(self, content): if not content: raise SkipComponent('Empty output') @@ -74,9 +76,13 @@ class GrubbyDefaultKernel(CommandParser): Attributes: default_kernel(str): The default kernel name for next boot """ + def __init__(self, context): - deprecated(GrubbyDefaultKernel, - "Please use the :class:`insights.combiners.grubby.Grubby` instead.", "3.7.0") + deprecated( + GrubbyDefaultKernel, + "Please use the :class:`insights.combiners.grubby.Grubby` instead.", + "3.7.0", + ) super(GrubbyDefaultKernel, self).__init__(context) def parse_content(self, content): @@ -145,6 +151,7 @@ class GrubbyInfoAll(CommandParser): SkipComponent: When output is empty ParseException: When output is invalid """ + def parse_content(self, content): def _parse_args(args): diff --git a/insights/tests/combiners/test_grubby.py b/insights/tests/combiners/test_grubby.py index 0f4616639..95d87b3c1 100644 --- a/insights/tests/combiners/test_grubby.py +++ b/insights/tests/combiners/test_grubby.py @@ -52,7 +52,9 @@ def test_grubby(): 'crashkernel': ['1G-4G:192M,4G-64G:256M,64G-:512M'], 'resume': ['/dev/mapper/rhel-swap'], 'rd.lvm.lv': ['rhel/root', 'rhel/swap'], - 'rhgb': [True], 'quiet': [True], 'retbleed': ['stuff'], + 'rhgb': [True], + 'quiet': [True], + 'retbleed': ['stuff'], }, root="/dev/mapper/rhel-root", initrd="/boot/initramfs-5.14.0-162.6.1.el9_1.x86_64.img", diff --git a/insights/tests/parsers/test_grubby.py b/insights/tests/parsers/test_grubby.py index 014fd13ec..9cc76e30a 100644 --- a/insights/tests/parsers/test_grubby.py +++ b/insights/tests/parsers/test_grubby.py @@ -3,11 +3,7 @@ from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import grubby -from insights.parsers.grubby import ( - GrubbyDefaultIndex, - GrubbyDefaultKernel, - GrubbyInfoAll -) +from insights.parsers.grubby import GrubbyDefaultIndex, GrubbyDefaultKernel, GrubbyInfoAll from insights.tests import context_wrap DEFAULT_INDEX_1 = '0' @@ -179,7 +175,9 @@ def test_grubby_info_all(): 'crashkernel': ['1G-4G:192M,4G-64G:256M,64G-:512M'], 'resume': ['/dev/mapper/rhel-swap'], 'rd.lvm.lv': ['rhel/root', 'rhel/swap'], - 'rhgb': [True], 'quiet': [True], 'retbleed': ['stuff'], + 'rhgb': [True], + 'quiet': [True], + 'retbleed': ['stuff'], }, root="/dev/mapper/rhel-root", initrd="/boot/initramfs-5.14.0-162.6.1.el9_1.x86_64.img", @@ -216,9 +214,9 @@ def test_grubby_info_all_ab(): def test_doc_examples(): env = { - 'grubby_default_index': GrubbyDefaultIndex(context_wrap(DEFAULT_INDEX_1)), - 'grubby_default_kernel': GrubbyDefaultKernel(context_wrap(DEFAULT_KERNEL)), - 'grubby_info_all': GrubbyInfoAll(context_wrap(GRUBBY_INFO_ALL_1)), - } + 'grubby_default_index': GrubbyDefaultIndex(context_wrap(DEFAULT_INDEX_1)), + 'grubby_default_kernel': GrubbyDefaultKernel(context_wrap(DEFAULT_KERNEL)), + 'grubby_info_all': GrubbyInfoAll(context_wrap(GRUBBY_INFO_ALL_1)), + } failed, total = doctest.testmod(grubby, globs=env) assert failed == 0