Merge "Fail introspection early if no lookup attributes can be detected"
This commit is contained in:
commit
e6016f0fa2
|
@ -131,6 +131,12 @@ def _background_introspect(ironic, node_info):
|
|||
{'macs': macs, 'node': node_info.uuid})
|
||||
firewall.update_filters(ironic)
|
||||
|
||||
if not node_info.attributes:
|
||||
raise utils.Error(
|
||||
_('No lookup attributes were found for node %s, inspector won\'t '
|
||||
'be able to find it after introspection. Consider creating '
|
||||
'ironic ports or providing an IPMI address.') % node_info.uuid)
|
||||
|
||||
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})
|
||||
|
|
|
@ -176,6 +176,19 @@ class TestIntrospect(BaseTest):
|
|||
cli.node.set_power_state.assert_called_once_with(self.uuid,
|
||||
'reboot')
|
||||
|
||||
def test_no_lookup_attrs(self, client_mock, add_mock, filters_mock):
|
||||
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(cli)
|
||||
self.node_info.finished.assert_called_once_with(error=mock.ANY)
|
||||
self.assertEqual(0, filters_mock.call_count)
|
||||
self.assertEqual(0, cli.node.set_power_state.call_count)
|
||||
|
||||
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