Merge "Fix incorrect pxe-enabled was set during introspection"

This commit is contained in:
Zuul 2020-06-28 19:42:06 +00:00 committed by Gerrit Code Review
commit f195fa5b42
4 changed files with 53 additions and 4 deletions

View File

@ -103,6 +103,11 @@ _OPTS = [
default=False,
help=_('Whether to process nodes that are in running '
'states.')),
cfg.BoolOpt('update_pxe_enabled',
default=True,
help=_('Whether to update the pxe_enabled value according '
'to the introspection data. This option has no effect '
'if [processing]overwrite_existing is set to False')),
]

View File

@ -294,7 +294,8 @@ class ValidateInterfacesHook(base.ProcessingHook):
node_info=node_info, data=introspection_data)
node_info.delete_port(port)
if CONF.processing.overwrite_existing:
if (CONF.processing.overwrite_existing
and CONF.processing.update_pxe_enabled):
# Make sure is_pxe_enabled is up-to-date
ports = node_info.ports()
for iface in introspection_data['interfaces'].values():

View File

@ -310,9 +310,46 @@ class Test(Base):
]
self.cli.create_port.assert_has_calls(calls, any_order=True)
self.cli.delete_port.assert_called_once_with(uuid_to_delete)
self.cli.patch_port.assert_called_once_with(
uuid_to_update,
[{'op': 'replace', 'path': '/pxe_enabled', 'value': False}])
status = self.call_get_status(self.uuid)
self.check_status(status, finished=True, state=istate.States.finished)
def test_port_not_update_pxe_enabled(self):
cfg.CONF.set_override('add_ports', 'active', 'processing')
cfg.CONF.set_override('keep_ports', 'added', 'processing')
cfg.CONF.set_override('update_pxe_enabled', False, 'processing')
uuid_to_update = uuidutils.generate_uuid()
# One port with incorrect pxe_enabled.
self.cli.ports.return_value = [
mock.Mock(address=self.macs[0], id=uuid_to_update,
node_id=self.uuid, extra={}, is_pxe_enabled=False)
]
# Two more ports are created, one with client_id. Make sure the
# returned object has the same properties as requested in create().
self.cli.create_port.side_effect = mock.Mock
self.call_introspect(self.uuid)
eventlet.greenthread.sleep(DEFAULT_SLEEP)
self.cli.set_node_power_state.assert_called_once_with(self.uuid,
'rebooting')
status = self.call_get_status(self.uuid)
self.check_status(status, finished=False, state=istate.States.waiting)
res = self.call_continue(self.data)
self.assertEqual({'uuid': self.uuid}, res)
eventlet.greenthread.sleep(DEFAULT_SLEEP)
self.cli.patch_node.assert_called_with(self.uuid, mock.ANY)
self.assertCalledWithPatch(self.patch, self.cli.patch_node)
calls = [
mock.call(node_uuid=self.uuid, address=self.macs[2],
extra={'client-id': self.client_id},
is_pxe_enabled=False),
]
self.assertFalse(self.cli.patch_port.called)
self.cli.create_port.assert_has_calls(calls, any_order=True)
status = self.call_get_status(self.uuid)
self.check_status(status, finished=True, state=istate.States.finished)

View File

@ -0,0 +1,6 @@
---
features:
- |
Adds a configuration option ``[processing]update_pxe_enabled`` to control
whether the pxe_enabled should be updated according to introspection data
for ports. The default value is True which is backwards compatible.