Merge "In node_power_action() add node.UUID to log message"

This commit is contained in:
Jenkins 2016-04-12 21:58:25 +00:00 committed by Gerrit Code Review
commit 349de67ab5
2 changed files with 10 additions and 4 deletions

View File

@ -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:

View File

@ -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.