Merge "Silence modprobe loading errors for IPMI drivers"

This commit is contained in:
Zuul
2025-01-21 01:48:46 +00:00
committed by Gerrit Code Review
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):