Merge "Control port updates with update_pxe_enabled flag" into stable/2024.2
This commit is contained in:
@@ -22,6 +22,7 @@ from ironic.common import exception
|
||||
from ironic.common.i18n import _
|
||||
from ironic.common import states
|
||||
from ironic.common import utils
|
||||
from ironic.conf import CONF
|
||||
from ironic.drivers import base
|
||||
from ironic.drivers.modules import inspect_utils
|
||||
from ironic.drivers.modules.redfish import utils as redfish_utils
|
||||
@@ -183,7 +184,7 @@ class RedfishInspect(base.InspectInterface):
|
||||
if pxe_port_macs is None:
|
||||
LOG.warning("No PXE enabled NIC was found for node "
|
||||
"%(node_uuid)s.", {'node_uuid': task.node.uuid})
|
||||
else:
|
||||
elif CONF.inspector.update_pxe_enabled:
|
||||
pxe_port_macs = [macs.lower() for macs in pxe_port_macs]
|
||||
|
||||
ports = objects.Port.list_by_node_id(task.context, task.node.id)
|
||||
|
||||
@@ -475,6 +475,29 @@ class RedfishInspectTestCase(db_base.DbTestCase):
|
||||
port = mock_list_by_node_id.return_value
|
||||
self.assertFalse(port[0].pxe_enabled)
|
||||
|
||||
@mock.patch.object(objects.Port, 'list_by_node_id') # noqa
|
||||
@mock.patch.object(redfish_utils, 'get_system', autospec=True)
|
||||
def test_inspect_hardware_with_conf_update_pxe_disabled_false(
|
||||
self, mock_get_system, mock_list_by_node_id):
|
||||
self.init_system_mock(mock_get_system.return_value)
|
||||
|
||||
pxe_enabled_port = obj_utils.create_test_port(
|
||||
self.context, uuid=self.node.uuid,
|
||||
node_id=self.node.id, address='24:6E:96:70:49:01',
|
||||
pxe_enabled=True)
|
||||
mock_list_by_node_id.return_value = [pxe_enabled_port]
|
||||
|
||||
self.config(update_pxe_enabled=False, group='inspector')
|
||||
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=True) as task:
|
||||
task.driver.inspect._get_pxe_port_macs = mock.Mock()
|
||||
task.driver.inspect._get_pxe_port_macs.return_value = \
|
||||
['24:6E:96:70:49:00']
|
||||
task.driver.inspect.inspect_hardware(task)
|
||||
port = mock_list_by_node_id.return_value
|
||||
self.assertTrue(port[0].pxe_enabled)
|
||||
|
||||
@mock.patch.object(redfish_utils, 'get_system', autospec=True)
|
||||
def test_inspect_hardware_with_no_mac(self, mock_get_system):
|
||||
self.init_system_mock(mock_get_system.return_value)
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
In the redfish inspector, use condition to control whether the pxe_enabled field of a port is updated during inspection.
|
||||
[inspector]update_pxe_enabled is used to control this so it behaves like all other inspection interfaces.
|
||||
The default value for this configuration is True.
|
||||
|
||||
Reference in New Issue
Block a user