-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add "modinfo_filtered_modules" to collect the filtered modules …
…information (#3447) * feat: add "modinfo_all" back and enhance it to get modinfo for all filtered modules * Update spec "modinfo" to filterable * Deprecate all other modinfo specs Signed-off-by: Huanhuan Li <[email protected]> * feat: Add new specs instead of updating original spec directly * Add new spec "modinfo_modules" to collect the filtered modules * Add another new spec "modinfo_filtered_modules" to run "modinfo filtered_modules" since the result will be filtered if the spec is filterable, and then other info without the filter words will be ignored, which is not expected. Signed-off-by: Huanhuan Li <[email protected]> * fixes: Fix failed test Signed-off-by: Huanhuan Li <[email protected]> (cherry picked from commit b134ec5)
- Loading branch information
Showing
8 changed files
with
285 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,12 @@ | ||
""" | ||
ModInfo - Commands ``modinfo <module_name>`` | ||
============================================ | ||
Parsers to parse the output of ``modinfo <module_name>`` commands. | ||
ModInfoI40e - Command ``modinfo i40e`` | ||
-------------------------------------- | ||
ModInfoVmxnet3 - Command ``modinfo vmxnet3`` | ||
-------------------------------------------- | ||
ModInfoIgb - Command ``modinfo igb`` | ||
------------------------------------ | ||
ModInfoIxgbe - Command ``modinfo ixgbe`` | ||
---------------------------------------- | ||
ModInfoVeth - Command ``modinfo veth`` | ||
-------------------------------------- | ||
ModInfoEach - Command ``modinfo *`` | ||
----------------------------------- | ||
for any module listed by ``lsmod`` | ||
ModInfoAll - Command ``modinfo *(all modules)`` | ||
----------------------------------------------- | ||
for all modules listed by ``lsmod`` | ||
KernelModulesInfo - Command ``modinfo filtered_modules`` | ||
-------------------------------------------------------- | ||
""" | ||
|
||
from insights import parser, CommandParser | ||
from insights.parsers import SkipException | ||
from insights.specs import Specs | ||
from insights.util import deprecated | ||
|
||
|
||
class ModInfo(dict): | ||
|
@@ -141,11 +117,13 @@ def module_details(self): | |
return self | ||
|
||
|
||
@parser(Specs.modinfo_all) | ||
class ModInfoAll(CommandParser, dict): | ||
@parser(Specs.modinfo_filtered_modules) | ||
class KernelModulesInfo(CommandParser, dict): | ||
""" | ||
Class to parse the information about all kernel modules, the module | ||
info will be stored in dictionary format. | ||
Class to parse the information about filtered kernel modules collected by | ||
"modinfo filtered_modules". The result will be stored in a dictionary. | ||
The key is the module name, the value is a instance of ModInfo with more | ||
details. | ||
Sample output:: | ||
|
@@ -164,7 +142,6 @@ class ModInfoAll(CommandParser, dict): | |
signer: Red Hat Enterprise Linux kernel signing key | ||
sig_key: A5:70:18:DF:B6:C9:D6:1F:CF:CE:0A:3D:02:8B:B3:69:BD:76:CA:ED | ||
sig_hashalgo: sha256 | ||
filename: /lib/modules/3.10.0-993.el7.x86_64/kernel/drivers/net/ethernet/intel/i40e/i40e.ko.xz | ||
firmware: i40e/i40e-e2-7.13.1.0.fw | ||
firmware: i40e/i40e-e1h-7.13.1.0.fw | ||
|
@@ -190,21 +167,25 @@ class ModInfoAll(CommandParser, dict): | |
SkipException: When nothing need to parse. | ||
Examples: | ||
>>> type(modinfo_all) | ||
<class 'insights.parsers.modinfo.ModInfoAll'> | ||
>>> 'i40e' in modinfo_all | ||
>>> from insights.core.filters import add_filter | ||
>>> from insights.specs import Specs | ||
>>> add_filter(Specs.modinfo_modules, 'i40e') | ||
>>> add_filter(Specs.modinfo_modules, 'vmxnet3') | ||
>>> type(mods_info) | ||
<class 'insights.parsers.modinfo.KernelModulesInfo'> | ||
>>> 'i40e' in mods_info | ||
True | ||
>>> modinfo_all['i40e'].module_version | ||
>>> mods_info['i40e'].module_version | ||
'2.3.2-k' | ||
>>> modinfo_all['i40e'].module_path | ||
>>> mods_info['i40e'].module_path | ||
'/lib/modules/3.10.0-993.el7.x86_64/kernel/drivers/net/ethernet/intel/i40e/i40e.ko.xz' | ||
>>> sorted(modinfo_all['i40e'].module_firmware) | ||
>>> sorted(mods_info['i40e'].module_firmware) | ||
['i40e/i40e-e1h-7.13.1.0.fw', 'i40e/i40e-e2-7.13.1.0.fw'] | ||
>>> sorted(modinfo_all['i40e'].module_alias) | ||
>>> sorted(mods_info['i40e'].module_alias) | ||
['pci:v00008086d0000158Asv*sd*bc*sc*i*', 'pci:v00008086d0000158Bsv*sd*bc*sc*i*'] | ||
>>> sorted(modinfo_all['i40e'].module_parm) | ||
>>> sorted(mods_info['i40e'].module_parm) | ||
['debug:Debug level (0=none,...,16=all), Debug mask (0x8XXXXXXX) (uint)', 'int_mode: Force interrupt mode other than MSI-X (1 INT#x; 2 MSI) (int)'] | ||
>>> 'vmxnet3' in modinfo_all | ||
>>> 'vmxnet3' in mods_info | ||
True | ||
Attributes: | ||
|
@@ -238,9 +219,96 @@ def parse_content(self, content): | |
raise SkipException("No Parsed Contents") | ||
|
||
|
||
@parser(Specs.modinfo_all) | ||
class ModInfoAll(KernelModulesInfo): | ||
""" | ||
.. warning:: | ||
This parser is deprecated, please use | ||
:py:class:`insights.parsers.modinfo.KernelModulesInfo` instead. | ||
Class to parse the information about all kernel modules, the module | ||
info will be stored in dictionary format. | ||
Sample output:: | ||
filename: /lib/modules/3.10.0-957.10.1.el7.x86_64/kernel/drivers/net/vmxnet3/vmxnet3.ko.xz | ||
version: 1.4.14.0-k | ||
license: GPL v2 | ||
description: VMware vmxnet3 virtual NIC driver | ||
author: VMware, Inc. | ||
retpoline: Y | ||
rhelversion: 7.6 | ||
srcversion: 7E672688ACACBDD2E363B63 | ||
alias: pci:v000015ADd000007B0sv*sd*bc*sc*i* | ||
depends: | ||
intree: Y | ||
vermagic: 3.10.0-957.10.1.el7.x86_64 SMP mod_unload modversions | ||
signer: Red Hat Enterprise Linux kernel signing key | ||
sig_key: A5:70:18:DF:B6:C9:D6:1F:CF:CE:0A:3D:02:8B:B3:69:BD:76:CA:ED | ||
sig_hashalgo: sha256 | ||
filename: /lib/modules/3.10.0-993.el7.x86_64/kernel/drivers/net/ethernet/intel/i40e/i40e.ko.xz | ||
firmware: i40e/i40e-e2-7.13.1.0.fw | ||
firmware: i40e/i40e-e1h-7.13.1.0.fw | ||
version: 2.3.2-k | ||
license: GPL | ||
description: Intel(R) Ethernet Connection XL710 Network Driver | ||
author: Intel Corporation, <[email protected]> | ||
retpoline: Y | ||
rhelversion: 7.7 | ||
srcversion: DC5C250666ADD8603966656 | ||
alias: pci:v00008086d0000158Bsv*sd*bc*sc*i* | ||
alias: pci:v00008086d0000158Asv*sd*bc*sc*i* | ||
depends: ptp | ||
intree: Y | ||
vermagic: 3.10.0-993.el7.x86_64 SMP mod_unload modversions | ||
signer: Red Hat Enterprise Linux kernel signing key | ||
sig_key: 81:7C:CB:07:72:4E:7F:B8:15:24:10:F9:27:2D:AA:CF:80:3E:CE:59 | ||
sig_hashalgo: sha256 | ||
parm: debug:Debug level (0=none,...,16=all), Debug mask (0x8XXXXXXX) (uint) | ||
parm: int_mode: Force interrupt mode other than MSI-X (1 INT#x; 2 MSI) (int) | ||
Raises: | ||
SkipException: When nothing need to parse. | ||
Examples: | ||
>>> type(modinfo_all) | ||
<class 'insights.parsers.modinfo.ModInfoAll'> | ||
>>> 'i40e' in modinfo_all | ||
True | ||
>>> modinfo_all['i40e'].module_version | ||
'2.3.2-k' | ||
>>> modinfo_all['i40e'].module_path | ||
'/lib/modules/3.10.0-993.el7.x86_64/kernel/drivers/net/ethernet/intel/i40e/i40e.ko.xz' | ||
>>> sorted(modinfo_all['i40e'].module_firmware) | ||
['i40e/i40e-e1h-7.13.1.0.fw', 'i40e/i40e-e2-7.13.1.0.fw'] | ||
>>> sorted(modinfo_all['i40e'].module_alias) | ||
['pci:v00008086d0000158Asv*sd*bc*sc*i*', 'pci:v00008086d0000158Bsv*sd*bc*sc*i*'] | ||
>>> sorted(modinfo_all['i40e'].module_parm) | ||
['debug:Debug level (0=none,...,16=all), Debug mask (0x8XXXXXXX) (uint)', 'int_mode: Force interrupt mode other than MSI-X (1 INT#x; 2 MSI) (int)'] | ||
>>> 'vmxnet3' in modinfo_all | ||
True | ||
Attributes: | ||
retpoline_y (set): A set of names of the modules with the attribute "retpoline: Y". | ||
retpoline_n (set): A set of names of the modules with the attribute "retpoline: N". | ||
""" | ||
|
||
def __init__(self, *args, **kwargs): | ||
deprecated( | ||
ModInfoAll, | ||
'Please use the :class:`insights.parsers.modinfo.KernelModulesInfo` instead.' | ||
) | ||
super(ModInfoAll, self).__init__(*args, **kwargs) | ||
|
||
|
||
@parser(Specs.modinfo) | ||
class ModInfoEach(CommandParser, ModInfo): | ||
""" | ||
.. warning:: | ||
This parser is deprecated, please use | ||
:py:class:`insights.parsers.modinfo.KernelModulesInfo` instead. | ||
Parses the output of ``modinfo %s`` command, where %s is any of the loaded modules. | ||
Sample output:: | ||
|
@@ -285,6 +353,14 @@ class ModInfoEach(CommandParser, ModInfo): | |
>>> sorted(modinfo_obj.module_parm) | ||
['debug:Debug level (0=none,...,16=all), Debug mask (0x8XXXXXXX) (uint)', 'int_mode: Force interrupt mode other than MSI-X (1 INT#x; 2 MSI) (int)'] | ||
""" | ||
|
||
def __init__(self, *args, **kwargs): | ||
deprecated( | ||
ModInfoEach, | ||
'Please use the :class:`insights.parsers.modinfo.KernelModulesInfo` instead.' | ||
) | ||
super(ModInfoEach, self).__init__(*args, **kwargs) | ||
|
||
def parse_content(self, content): | ||
self.update(ModInfo.from_content(content)) | ||
|
||
|
@@ -299,6 +375,10 @@ def data(self): | |
@parser(Specs.modinfo_i40e) | ||
class ModInfoI40e(ModInfoEach): | ||
""" | ||
.. warning:: | ||
This parser is deprecated, please use | ||
:py:class:`insights.parsers.modinfo.KernelModulesInfo` instead. | ||
Parses output of ``modinfo i40e`` command. | ||
Sample ``modinfo i40e`` output:: | ||
|
@@ -341,12 +421,22 @@ class ModInfoI40e(ModInfoEach): | |
>>> sorted(modinfo_i40e.module_parm) == sorted(['debug:Debug level (0=none,...,16=all), Debug mask (0x8XXXXXXX) (uint)', 'int_mode: Force interrupt mode other than MSI-X (1 INT#x; 2 MSI) (int)']) | ||
True | ||
""" | ||
pass | ||
|
||
def __init__(self, *args, **kwargs): | ||
deprecated( | ||
ModInfoI40e, | ||
'Please use the :class:`insights.parsers.modinfo.KernelModulesInfo` instead.' | ||
) | ||
super(ModInfoI40e, self).__init__(*args, **kwargs) | ||
|
||
|
||
@parser(Specs.modinfo_vmxnet3) | ||
class ModInfoVmxnet3(ModInfoEach): | ||
""" | ||
.. warning:: | ||
This parser is deprecated, please use | ||
:py:class:`insights.parsers.modinfo.KernelModulesInfo` instead. | ||
Parses output of ``modinfo vmxnet3`` command. | ||
Sample ``modinfo vmxnet3`` output:: | ||
|
@@ -378,12 +468,22 @@ class ModInfoVmxnet3(ModInfoEach): | |
>>> modinfo_drv.module_alias | ||
'pci:v000015ADd000007B0sv*sd*bc*sc*i*' | ||
""" | ||
pass | ||
|
||
def __init__(self, *args, **kwargs): | ||
deprecated( | ||
ModInfoVmxnet3, | ||
'Please use the :class:`insights.parsers.modinfo.KernelModulesInfo` instead.' | ||
) | ||
super(ModInfoVmxnet3, self).__init__(*args, **kwargs) | ||
|
||
|
||
@parser(Specs.modinfo_igb) | ||
class ModInfoIgb(ModInfoEach): | ||
""" | ||
.. warning:: | ||
This parser is deprecated, please use | ||
:py:class:`insights.parsers.modinfo.KernelModulesInfo` instead. | ||
Parses output of ``modinfo igb`` command. | ||
Sample ``modinfo igb`` output:: | ||
|
@@ -416,12 +516,22 @@ class ModInfoIgb(ModInfoEach): | |
>>> modinfo_igb.module_alias | ||
'pci:v00008086d000010D6sv*sd*bc*sc*i*' | ||
""" | ||
pass | ||
|
||
def __init__(self, *args, **kwargs): | ||
deprecated( | ||
ModInfoIgb, | ||
'Please use the :class:`insights.parsers.modinfo.KernelModulesInfo` instead.' | ||
) | ||
super(ModInfoIgb, self).__init__(*args, **kwargs) | ||
|
||
|
||
@parser(Specs.modinfo_ixgbe) | ||
class ModInfoIxgbe(ModInfoEach): | ||
""" | ||
.. warning:: | ||
This parser is deprecated, please use | ||
:py:class:`insights.parsers.modinfo.KernelModulesInfo` instead. | ||
Parses output of ``modinfo ixgbe`` command. | ||
Sample ``modinfo ixgbe`` output:: | ||
|
@@ -454,12 +564,22 @@ class ModInfoIxgbe(ModInfoEach): | |
>>> modinfo_ixgbe.module_alias | ||
'pci:v00008086d000015CEsv*sd*bc*sc*i*' | ||
""" | ||
pass | ||
|
||
def __init__(self, *args, **kwargs): | ||
deprecated( | ||
ModInfoIxgbe, | ||
'Please use the :class:`insights.parsers.modinfo.KernelModulesInfo` instead.' | ||
) | ||
super(ModInfoIxgbe, self).__init__(*args, **kwargs) | ||
|
||
|
||
@parser(Specs.modinfo_veth) | ||
class ModInfoVeth(ModInfoEach): | ||
""" | ||
.. warning:: | ||
This parser is deprecated, please use | ||
:py:class:`insights.parsers.modinfo.KernelModulesInfo` instead. | ||
Parses output of ``modinfo veth`` command. | ||
Sample ``modinfo veth`` output:: | ||
|
@@ -484,4 +604,10 @@ class ModInfoVeth(ModInfoEach): | |
>>> modinfo_veth.module_signer | ||
'Red Hat Enterprise Linux kernel signing key' | ||
""" | ||
pass | ||
|
||
def __init__(self, *args, **kwargs): | ||
deprecated( | ||
ModInfoVeth, | ||
'Please use the :class:`insights.parsers.modinfo.KernelModulesInfo` instead.' | ||
) | ||
super(ModInfoVeth, self).__init__(*args, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.