In node_power_action() add node.UUID to log message

In the node_power_action() function, add the node.uuid to the log warning message.

This is only a partial fix for the referenced bug.

Partial-Bug: #1567689
Change-Id: I8fb62dd341aba71062f47e82db2d0d85320827a4
This commit is contained in:
Anup Navare 2016-04-01 00:34:31 +00:00
parent 506808c1af
commit db02ef5173
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.