Merge "Wiping agent tokens on reboot via API - take 2" into stable/victoria
This commit is contained in:
commit
9b6e996d25
|
@ -288,8 +288,8 @@ def node_power_action(task, new_state, timeout=None):
|
||||||
# NOTE(dtantsur): wipe token on shutting down, otherwise a reboot in
|
# NOTE(dtantsur): wipe token on shutting down, otherwise a reboot in
|
||||||
# fast-track (or an accidentally booted agent) will cause subsequent
|
# fast-track (or an accidentally booted agent) will cause subsequent
|
||||||
# actions to fail.
|
# actions to fail.
|
||||||
if target_state in (states.POWER_OFF, states.SOFT_POWER_OFF,
|
if new_state in (states.POWER_OFF, states.SOFT_POWER_OFF,
|
||||||
states.REBOOT, states.SOFT_REBOOT):
|
states.REBOOT, states.SOFT_REBOOT):
|
||||||
wipe_internal_info_on_power_off(node)
|
wipe_internal_info_on_power_off(node)
|
||||||
node.save()
|
node.save()
|
||||||
|
|
||||||
|
|
|
@ -278,10 +278,13 @@ class NodePowerActionTestCase(db_base.DbTestCase):
|
||||||
@mock.patch.object(fake.FakePower, 'get_power_state', autospec=True)
|
@mock.patch.object(fake.FakePower, 'get_power_state', autospec=True)
|
||||||
def test_node_power_action_power_reboot(self, get_power_mock, reboot_mock):
|
def test_node_power_action_power_reboot(self, get_power_mock, reboot_mock):
|
||||||
"""Test for reboot a node."""
|
"""Test for reboot a node."""
|
||||||
|
dii = {'agent_secret_token': 'token',
|
||||||
|
'agent_cached_deploy_steps': ['steps']}
|
||||||
node = obj_utils.create_test_node(self.context,
|
node = obj_utils.create_test_node(self.context,
|
||||||
uuid=uuidutils.generate_uuid(),
|
uuid=uuidutils.generate_uuid(),
|
||||||
driver='fake-hardware',
|
driver='fake-hardware',
|
||||||
power_state=states.POWER_ON)
|
power_state=states.POWER_ON,
|
||||||
|
driver_internal_info=dii)
|
||||||
task = task_manager.TaskManager(self.context, node.uuid)
|
task = task_manager.TaskManager(self.context, node.uuid)
|
||||||
|
|
||||||
conductor_utils.node_power_action(task, states.REBOOT)
|
conductor_utils.node_power_action(task, states.REBOOT)
|
||||||
|
@ -292,6 +295,7 @@ class NodePowerActionTestCase(db_base.DbTestCase):
|
||||||
self.assertEqual(states.POWER_ON, node['power_state'])
|
self.assertEqual(states.POWER_ON, node['power_state'])
|
||||||
self.assertIsNone(node['target_power_state'])
|
self.assertIsNone(node['target_power_state'])
|
||||||
self.assertIsNone(node['last_error'])
|
self.assertIsNone(node['last_error'])
|
||||||
|
self.assertNotIn('agent_secret_token', node['driver_internal_info'])
|
||||||
|
|
||||||
@mock.patch.object(fake.FakePower, 'get_power_state', autospec=True)
|
@mock.patch.object(fake.FakePower, 'get_power_state', autospec=True)
|
||||||
def test_node_power_action_invalid_state(self, get_power_mock):
|
def test_node_power_action_invalid_state(self, get_power_mock):
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Fixes wiping agent token on rebooting via API.
|
Loading…
Reference in New Issue