From 4b775db3d43d6fb68d122fe8cd2c00ebb469093b Mon Sep 17 00:00:00 2001 From: "Brad P. Crochet" Date: Wed, 16 Nov 2016 10:41:53 -0500 Subject: [PATCH] Remove separate call to provide workflow The provide workflow is now called directly from the register_or_update workflow. It should no longer be called from the client. Change-Id: I127061eff8763c159f380dd47d3a06813184faba Depends-On: I40f0b27a0f38447372181f9fae6a31e57dbd79e4 Closes-Bug: #1637474 --- .../tests/v1/baremetal/test_baremetal.py | 36 +++---------------- tripleoclient/v1/baremetal.py | 17 +++------ 2 files changed, 9 insertions(+), 44 deletions(-) diff --git a/tripleoclient/tests/v1/baremetal/test_baremetal.py b/tripleoclient/tests/v1/baremetal/test_baremetal.py index 185472b79..27ed7f0ff 100644 --- a/tripleoclient/tests/v1/baremetal/test_baremetal.py +++ b/tripleoclient/tests/v1/baremetal/test_baremetal.py @@ -344,6 +344,8 @@ pxe_ssh,192.168.122.2,stack,"KEY2",00:0b:d0:69:7e:58""") ], }, { "status": "SUCCESS" + }, { + "status": "SUCCESS" }] self.workflow = self.app.client_manager.workflow_engine @@ -375,22 +377,14 @@ pxe_ssh,192.168.122.2,stack,"KEY2",00:0b:d0:69:7e:58""") 'nodes_json': self.nodes_list, 'queue_name': 'UUID4', 'ramdisk_name': ramdisk_name, - 'instance_boot_option': 'local' if local else 'netboot' + 'instance_boot_option': 'local' if local else 'netboot', + 'initial_state': 'available', } )] - if provide: - call_list.append(mock.call( - 'tripleo.baremetal.v1.provide', workflow_input={ - 'node_uuids': ['MOCK_NODE_UUID', ], - 'queue_name': 'UUID4' - } - )) - self.workflow.executions.create.assert_has_calls(call_list) - self.assertEqual(self.workflow.executions.create.call_count, - 2 if provide else 1) + self.assertEqual(self.workflow.executions.create.call_count, 1) def test_json_import(self): @@ -407,26 +401,6 @@ pxe_ssh,192.168.122.2,stack,"KEY2",00:0b:d0:69:7e:58""") self._check_workflow_call() - def test_json_import_initial_state_enroll(self): - - arglist = [ - self.json_file.name, - '--json', - '-s', 'http://localhost', - '--initial-state', 'enroll' - ] - - verifylist = [ - ('csv', False), - ('json', True), - ] - - parsed_args = self.check_parser(self.cmd, arglist, verifylist) - - self.cmd.take_action(parsed_args) - self._check_workflow_call(provide=False) - self.assertEqual([], self.baremetal.node.updates) - def test_available_does_not_require_api_1_11(self): arglist = [self.json_file.name, '--json', '-s', 'http://localhost'] diff --git a/tripleoclient/v1/baremetal.py b/tripleoclient/v1/baremetal.py index c345aae48..5d7a1a83c 100644 --- a/tripleoclient/v1/baremetal.py +++ b/tripleoclient/v1/baremetal.py @@ -145,7 +145,7 @@ class ImportBaremetal(command.Command): parser.add_argument('file_in', type=argparse.FileType('r')) parser.add_argument( '--initial-state', - choices=['enroll', 'available'], + choices=['enroll', 'manageable', 'available'], default='available', help=_('Provision state for newly-enrolled nodes.') ) @@ -181,25 +181,16 @@ class ImportBaremetal(command.Command): deploy_kernel = parsed_args.deploy_kernel deploy_ramdisk = parsed_args.deploy_ramdisk - nodes = baremetal.register_or_update( + baremetal.register_or_update( self.app.client_manager, nodes_json=nodes_config, queue_name=queue_name, kernel_name=deploy_kernel, ramdisk_name=deploy_ramdisk, - instance_boot_option=parsed_args.instance_boot_option + instance_boot_option=parsed_args.instance_boot_option, + initial_state=parsed_args.initial_state, ) - if parsed_args.initial_state == "available": - # NOTE(dtantsur): newly enrolled nodes state is reported as - # "enroll" from the workflow even though it's actually "manageable" - # because the node list is built before "manage" action is run. - node_uuids = [node['uuid'] for node in nodes - if node['provision_state'] in {'manageable', - 'enroll'}] - baremetal.provide(self.app.client_manager, node_uuids=node_uuids, - queue_name=queue_name) - class StartBaremetalIntrospectionBulk(command.Command): """Start bulk introspection on all baremetal nodes (Deprecated).