Merge "Allow empty lookup attributes if node_not_found_hook is provided"
This commit is contained in:
commit
7e10d5c2fa
@ -126,7 +126,8 @@ def _background_introspect(ironic, node_info):
|
||||
{'macs': macs, 'node': node_info.uuid})
|
||||
firewall.update_filters(ironic)
|
||||
|
||||
if not node_info.attributes:
|
||||
attrs = node_info.attributes
|
||||
if CONF.processing.node_not_found_hook is None and not attrs:
|
||||
raise utils.Error(
|
||||
_('No lookup attributes were found for node %s, inspector won\'t '
|
||||
'be able to find it after introspection. Consider creating '
|
||||
@ -134,7 +135,7 @@ def _background_introspect(ironic, node_info):
|
||||
|
||||
LOG.info(_LI('The following attributes will be used for looking up '
|
||||
'node %(uuid)s: %(attrs)s'),
|
||||
{'attrs': node_info.attributes, 'uuid': node_info.uuid})
|
||||
{'attrs': attrs, 'uuid': node_info.uuid})
|
||||
|
||||
if not node_info.options.get('new_ipmi_credentials'):
|
||||
try:
|
||||
|
@ -195,6 +195,24 @@ class TestIntrospect(BaseTest):
|
||||
self.assertEqual(0, filters_mock.call_count)
|
||||
self.assertEqual(0, cli.node.set_power_state.call_count)
|
||||
|
||||
def test_no_lookup_attrs_with_node_not_found_hook(self, client_mock,
|
||||
add_mock, filters_mock):
|
||||
CONF.set_override('node_not_found_hook', 'example', 'processing')
|
||||
cli = self._prepare(client_mock)
|
||||
self.node_info.ports.return_value = []
|
||||
add_mock.return_value = self.node_info
|
||||
self.node_info.attributes = {}
|
||||
|
||||
introspect.introspect(self.uuid)
|
||||
|
||||
self.node_info.ports.assert_called_once_with()
|
||||
self.assertFalse(self.node_info.finished.called)
|
||||
cli.node.set_boot_device.assert_called_once_with(self.uuid,
|
||||
'pxe',
|
||||
persistent=False)
|
||||
cli.node.set_power_state.assert_called_once_with(self.uuid,
|
||||
'reboot')
|
||||
|
||||
def test_failed_to_get_node(self, client_mock, add_mock, filters_mock):
|
||||
cli = client_mock.return_value
|
||||
cli.node.get.side_effect = exceptions.NotFound()
|
||||
|
Loading…
Reference in New Issue
Block a user