diff --git a/ironic/conductor/utils.py b/ironic/conductor/utils.py index b7a6b1d9c2..0aac967a09 100644 --- a/ironic/conductor/utils.py +++ b/ironic/conductor/utils.py @@ -101,9 +101,10 @@ def node_power_action(task, new_state): node['power_state'] = new_state node['target_power_state'] = states.NOSTATE node.save() - LOG.warning(_LW("Not going to change node power state because " - "current state = requested state = '%(state)s'."), - {'state': curr_state}) + LOG.warning(_LW("Not going to change node %(node)s power " + "state because current state = requested state " + "= '%(state)s'."), + {'node': node.uuid, 'state': curr_state}) return if curr_state == states.ERROR: diff --git a/ironic/tests/unit/conductor/test_utils.py b/ironic/tests/unit/conductor/test_utils.py index 81f4a5aa9c..5e99cb445d 100644 --- a/ironic/tests/unit/conductor/test_utils.py +++ b/ironic/tests/unit/conductor/test_utils.py @@ -178,7 +178,8 @@ class NodePowerActionTestCase(base.DbTestCase): self.assertEqual(states.NOSTATE, node['target_power_state']) self.assertIsNone(node['last_error']) - def test_node_power_action_in_same_state(self): + @mock.patch.object(conductor_utils, 'LOG', autospec=True) + def test_node_power_action_in_same_state(self, log_mock): """Test setting node state to its present state. Test that we don't try to set the power state if the requested @@ -206,6 +207,10 @@ class NodePowerActionTestCase(base.DbTestCase): self.assertEqual(states.POWER_ON, node['power_state']) self.assertIsNone(node['target_power_state']) self.assertIsNone(node['last_error']) + log_mock.warning.assert_called_once_with( + u"Not going to change node %(node)s power state because " + u"current state = requested state = '%(state)s'.", + {'state': states.POWER_ON, 'node': node.uuid}) def test_node_power_action_in_same_state_db_not_in_sync(self): """Test setting node state to its present state if DB is out of sync.