Add node UUID to response from /v1/continue

This patch modifies the _process_node function's return value to ensure
that it always includes the nodes UUID.

Change-Id: I33078d137526433fdd7c9b7f6f779981c7145f0d
Closes-Bug: #1460689
This commit is contained in:
Sam Betts 2015-06-02 14:01:28 +01:00
parent 99c6e27d67
commit 22bd600ada
2 changed files with 18 additions and 4 deletions

View File

@ -153,18 +153,21 @@ def _process_node(ironic, node, node_info, cached_node):
firewall.update_filters(ironic)
resp = {'uuid': node.uuid}
if cached_node.options.get('new_ipmi_credentials'):
new_username, new_password = (
cached_node.options.get('new_ipmi_credentials'))
utils.spawn_n(_finish_set_ipmi_credentials,
ironic, node, cached_node, node_info,
new_username, new_password)
return {'ipmi_setup_credentials': True,
'ipmi_username': new_username,
'ipmi_password': new_password}
resp['ipmi_setup_credentials'] = True
resp['ipmi_username'] = new_username
resp['ipmi_password'] = new_password
else:
utils.spawn_n(_finish, ironic, cached_node)
return {}
return resp
def _finish_set_ipmi_credentials(ironic, node, cached_node, node_info,

View File

@ -347,6 +347,17 @@ class TestProcessNode(BaseTest):
return process._process_node(self.cli, self.node, self.data,
self.cached_node)
def test_return_includes_uuid(self, filters_mock, post_hook_mock):
ret_val = self.call()
self.assertEqual(self.uuid, ret_val.get('uuid'))
def test_return_includes_uuid_with_ipmi_creds(self, filters_mock,
post_hook_mock):
self.cached_node.set_option('new_ipmi_credentials', self.new_creds)
ret_val = self.call()
self.assertEqual(self.uuid, ret_val.get('uuid'))
self.assertTrue(ret_val.get('ipmi_setup_credentials'))
def test_wrong_provision_state(self, filters_mock, post_hook_mock):
self.node.provision_state = 'active'
self.assertRaises(utils.Error, self.call)