Try to set boot device to PXE before rebooting

Change-Id: I4c50048f6ceac609315a08282a50c3ca61568d8f
Closes-Bug: #1401801
This commit is contained in:
Dmitry Tantsur 2014-12-19 14:45:09 +01:00
parent 71451867ed
commit 98f8c0c005
2 changed files with 14 additions and 0 deletions

View File

@ -101,6 +101,13 @@ def _background_start_discover(ironic, node):
firewall.update_filters(ironic)
if not node.extra.get('ipmi_setup_credentials'):
try:
utils.retry_on_conflict(ironic.node.set_boot_device,
node.uuid, 'pxe', persistent=False)
except Exception as exc:
LOG.warning('Failed to set boot device to PXE for node %s: %s',
node.uuid, exc)
try:
utils.retry_on_conflict(ironic.node.set_power_state,
node.uuid, 'reboot')

View File

@ -76,6 +76,12 @@ class TestDiscover(test_base.BaseTest):
exceptions.Conflict(), # this is just retried
exceptions.InternalServerError(),
None]
# Failure to set boot device is also not fatal
cli.node.set_boot_device.side_effect = [
exceptions.Conflict(), # this is just retried
None,
exceptions.InternalServerError(),
None]
discover.discover(['uuid1', 'uuid2', 'uuid3'])
@ -96,6 +102,7 @@ class TestDiscover(test_base.BaseTest):
mac=[])
filters_mock.assert_called_with(cli)
self.assertEqual(2, filters_mock.call_count) # 1 node w/o ports
self.assertEqual(4, cli.node.set_boot_device.call_count)
self.assertEqual(4, cli.node.set_power_state.call_count)
cli.node.set_power_state.assert_called_with(mock.ANY, 'reboot')
patch = [{'op': 'add', 'path': '/extra/on_discovery', 'value': 'true'},