Silence modprobe loading errors for IPMI drivers

Debug messages from modprobe failing to load ipmi drivers can
be confusing and they do not add anything since they're
not really errors.
This patch silence the message in the logs.

Change-Id: I7452bc9e56148e3d423be92f384ff9aeffbe88d7
This commit is contained in:
Riccardo Pittau
2024-12-04 17:09:38 +01:00
committed by Jay Faulkner
parent 56037e78cc
commit 51c73d22fa
2 changed files with 27 additions and 6 deletions

View File

@@ -129,9 +129,14 @@ def _load_ipmi_modules():
This is required to be called at least once before attempting to use
ipmitool or related tools.
"""
utils.try_execute('modprobe', 'ipmi_msghandler')
utils.try_execute('modprobe', 'ipmi_devintf')
utils.try_execute('modprobe', 'ipmi_si')
ipmi_drivers = ['ipmi_msghandler', 'ipmi_devintf', 'ipmi_si']
for ipmi_driver in ipmi_drivers:
try:
processutils.execute('modprobe', ipmi_driver)
except (processutils.ProcessExecutionError, OSError):
LOG.debug("IPMI driver %s not supported or not present",
ipmi_driver)
def _load_multipath_modules():

View File

@@ -5928,14 +5928,30 @@ class TestModuleFunctions(base.IronicAgentTest):
mocked_execute.assert_has_calls([
mock.call('iscsistart', '-f')])
@mock.patch.object(utils, 'try_execute', autospec=True)
def test__load_ipmi_modules(self, mocked_try_execute, me):
@mock.patch.object(processutils, 'execute', autospec=True)
def test__load_ipmi_modules(self, mocked_proc_execute, mocked_execute):
hardware._load_ipmi_modules()
mocked_try_execute.assert_has_calls([
mocked_proc_execute.assert_has_calls([
mock.call('modprobe', 'ipmi_msghandler'),
mock.call('modprobe', 'ipmi_devintf'),
mock.call('modprobe', 'ipmi_si')])
@mock.patch.object(hardware, 'LOG', autospec=True)
@mock.patch.object(processutils, 'execute', autospec=True)
def test__load_ipmi_modules_fail(self, mocked_proc_execute, mocked_log,
mocked_execute):
mocked_proc_execute.side_effect = [
processutils.ProcessExecutionError,
('', ''),
('', ''),
]
hardware._load_ipmi_modules()
mocked_proc_execute.assert_has_calls([
mock.call('modprobe', 'ipmi_msghandler'),
mock.call('modprobe', 'ipmi_devintf'),
mock.call('modprobe', 'ipmi_si')])
mocked_log.debug.assert_called_once()
@mock.patch.object(utils, 'execute', autospec=True)
class TestMultipathEnabled(base.IronicAgentTest):