Browse Source

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

tags/10.2.0
Zuul 2 weeks ago
committed by Gerrit Code Review
parent
commit
f195fa5b42
4 changed files with 53 additions and 4 deletions
  1. +5
    -0
      ironic_inspector/conf/processing.py
  2. +2
    -1
      ironic_inspector/plugins/standard.py
  3. +40
    -3
      ironic_inspector/test/functional.py
  4. +6
    -0
      releasenotes/notes/pxe-enabled-for-pxe-a199e81128557bc0.yaml

+ 5
- 0
ironic_inspector/conf/processing.py 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')),
]




+ 2
- 1
ironic_inspector/plugins/standard.py 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():


+ 40
- 3
ironic_inspector/test/functional.py 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)


+ 6
- 0
releasenotes/notes/pxe-enabled-for-pxe-a199e81128557bc0.yaml 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.

Loading…
Cancel
Save