Always set the provision state to Manage before discovery

Change-Id: If78f87b967aaea21ac208f1890601c4b8c1f3f2f
This commit is contained in:
Dougal Matthews 2015-04-16 14:56:44 +01:00
parent d5c251aab6
commit 1e5a4228e4
2 changed files with 17 additions and 3 deletions

View File

@ -222,14 +222,19 @@ class TestIntrospectionAll(fakes.TestBaremetal):
client = self.app.client_manager.rdomanager_oscplugin.baremetal()
client.node.list.return_value = [
mock.Mock(uuid="ABCDEFGH"),
mock.Mock(uuid="IJKLMNOP"),
mock.Mock(uuid="QRSTUVWX"),
mock.Mock(uuid="ABCDEFGH", provision_state="available"),
mock.Mock(uuid="IJKLMNOP", provision_state="manageable"),
mock.Mock(uuid="QRSTUVWX", provision_state="available"),
]
parsed_args = self.check_parser(self.cmd, [], [])
self.cmd.take_action(parsed_args)
client.node.set_provision_state.assert_has_calls([
mock.call('ABCDEFGH', 'manage'),
mock.call('QRSTUVWX', 'manage'),
])
discoverd_mock.assert_has_calls([
mock.call('ABCDEFGH', base_url=None, auth_token='TOKEN'),
mock.call('IJKLMNOP', base_url=None, auth_token='TOKEN'),

View File

@ -116,6 +116,15 @@ class IntrospectionAllPlugin(IntrospectionParser, command.Command):
client = self.app.client_manager.rdomanager_oscplugin.baremetal()
for node in client.node.list():
if node.provision_state == "available":
self.log.debug(("Setting provision state from {0} to "
"'manageable' for Node {1}"
).format(node.provision_state, node.uuid))
client.node.set_provision_state(node.uuid, 'manage')
self.log.debug("Starting introspection of Ironic node {0}".format(
node.uuid))
auth_token = self.app.client_manager.auth_ref.auth_token