From ab0930ec6c66b655ac1c546bde0a79f6899ed94f Mon Sep 17 00:00:00 2001 From: Ilya Shakhat Date: Fri, 19 Jul 2019 16:22:58 +0200 Subject: [PATCH] Fix reboot command Change-Id: Ie7598a69f336618a6daab66f3854d9ebcebe5b3a Closes-Bug: #1836736 --- os_faults/api/node_collection.py | 9 +++++++-- os_faults/tests/unit/api/test_node_collection.py | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/os_faults/api/node_collection.py b/os_faults/api/node_collection.py index 18d5be0..e0a338d 100644 --- a/os_faults/api/node_collection.py +++ b/os_faults/api/node_collection.py @@ -137,8 +137,13 @@ class NodeCollection(utils.ReprMixin): """ LOG.info('Reboot nodes: %s', self) - task = {'command': 'reboot now'} - self.cloud_management.execute_on_cloud(self.hosts, task) + task = { + 'command': 'reboot now', + 'become': 'yes', + } + # note that all errors are ignored + self.cloud_management.execute_on_cloud(self.hosts, task, + raise_on_error=False) @public def poweroff(self): diff --git a/os_faults/tests/unit/api/test_node_collection.py b/os_faults/tests/unit/api/test_node_collection.py index 0cfc86c..78fe1f3 100644 --- a/os_faults/tests/unit/api/test_node_collection.py +++ b/os_faults/tests/unit/api/test_node_collection.py @@ -193,7 +193,8 @@ class NodeCollectionTestCase(test.TestCase): def test_reboot(self): self.node_collection.reboot() self.mock_cloud_management.execute_on_cloud.assert_called_once_with( - self.hosts, {'command': 'reboot now'}) + self.hosts, {'command': 'reboot now', 'become': 'yes'}, + raise_on_error=False) def test_snapshot(self): self.node_collection.snapshot('foo')