diff --git a/ironicclient/tests/unit/v1/test_node_shell.py b/ironicclient/tests/unit/v1/test_node_shell.py index 66bc82d33..58b37bef3 100644 --- a/ironicclient/tests/unit/v1/test_node_shell.py +++ b/ironicclient/tests/unit/v1/test_node_shell.py @@ -73,6 +73,17 @@ class NodeShellTest(utils.BaseTestCase): client_mock.node.delete.assert_has_calls( [mock.call('node_uuid1'), mock.call('node_uuid2')]) + def test_do_node_delete_multiple_with_exception(self): + client_mock = mock.MagicMock() + client_mock.node.delete.side_effect = ( + [exceptions.ClientException, None]) + args = mock.MagicMock() + args.node = ['node_uuid1', 'node_uuid2'] + + n_shell.do_node_delete(client_mock, args) + client_mock.node.delete.assert_has_calls( + [mock.call('node_uuid1'), mock.call('node_uuid2')]) + def test_do_node_update(self): client_mock = mock.MagicMock() args = mock.MagicMock() diff --git a/ironicclient/v1/node_shell.py b/ironicclient/v1/node_shell.py index 16b4aa3ed..c9b1d016e 100644 --- a/ironicclient/v1/node_shell.py +++ b/ironicclient/v1/node_shell.py @@ -215,8 +215,12 @@ def do_node_create(cc, args): def do_node_delete(cc, args): """Unregister node(s) from the Ironic service.""" for n in args.node: - cc.node.delete(n) - print(_('Deleted node %s') % n) + try: + cc.node.delete(n) + print(_('Deleted node %s') % n) + except exceptions.ClientException as e: + print(_("Failed to delete node %(node)s: %(error)s") + % {'node': n, 'error': e}) @cliutils.arg('node', metavar='', help="Name or UUID of the node.") diff --git a/releasenotes/notes/continue-del-next-node-8827e67e1c41a0a5.yaml b/releasenotes/notes/continue-del-next-node-8827e67e1c41a0a5.yaml new file mode 100644 index 000000000..52f8accb9 --- /dev/null +++ b/releasenotes/notes/continue-del-next-node-8827e67e1c41a0a5.yaml @@ -0,0 +1,3 @@ +--- +fixes: + - when deleting multiple nodes, continue with deletes even if one fails.