def test_invoke_plan_env_workflows(self, mock_open, mock_safe_load): plan_env_data = { 'name': 'overcloud', 'workflow_parameters': { 'tripleo.derive_params.v1.derive_parameters': { 'num_phy_cores_per_numa_node_for_pmd': 2 } } } mock_safe_load.return_value = plan_env_data self.websocket.wait_for_messages.return_value = iter([{ "execution": { "id": "IDID" }, "status": "SUCCESS", "message": "", "result": {} }]) parameters.invoke_plan_env_workflows(self.app.client_manager, 'overcloud', 'the-plan-environment.yaml') self.workflow.executions.create.assert_called_once_with( 'tripleo.derive_params.v1.derive_parameters', workflow_input={ 'plan': 'overcloud', 'user_inputs': { 'num_phy_cores_per_numa_node_for_pmd': 2 } })
def test_invoke_plan_env_workflows_multi_playbook(self, mock_inventory, mock_playbook, mock_open, mock_safe_load): plan_env_data = { 'name': 'overcloud', 'playbook_parameters': { 'sample-playbook-1.yaml': { 'num_phy_cores_per_numa_node_for_pmd': 2 }, '/playbook/dir-1/sample-playbook-2.yaml': { 'some_opt': 0 } } } mock_safe_load.return_value = plan_env_data parameters.invoke_plan_env_workflows(self.app.client_manager, 'overcloud', 'the-plan-environment.yaml') calls = [ mock.call(playbook='sample-playbook-1.yaml', inventory=mock.ANY, workdir=mock.ANY, playbook_dir=mock.ANY, verbosity=0, extra_vars={'num_phy_cores_per_numa_node_for_pmd': 2}), mock.call(playbook='sample-playbook-2.yaml', inventory=mock.ANY, workdir=mock.ANY, playbook_dir='/playbook/dir-1', verbosity=0, extra_vars={'some_opt': 0}) ] mock_playbook.assert_has_calls(calls, any_order=True)
def _heat_deploy(self, stack, stack_name, template_path, parameters, env_files, timeout, tht_root, env, update_plan_only, run_validations, skip_deploy_identifier, plan_env_file, deployment_options=None): """Verify the Baremetal nodes are available and do a stack update""" if stack: self.log.debug( "Checking compatibilities of neutron drivers for {0}".format( stack_name)) msg = update.check_neutron_mechanism_drivers( env, stack, self.object_client, stack_name) if msg: raise oscexc.CommandError(msg) self.log.debug("Getting template contents from plan %s" % stack_name) # We need to reference the plan here, not the local # tht root, as we need template_object to refer to # the rendered overcloud.yaml, not the tht_root overcloud.j2.yaml # FIXME(shardy) we need to move more of this into mistral actions plan_yaml_path = os.path.relpath(template_path, tht_root) # heatclient template_utils needs a function that can # retrieve objects from a container by name/path def do_object_request(method='GET', object_path=None): obj = self.object_client.get_object(stack_name, object_path) return obj and obj[1] template_files, template = template_utils.get_template_contents( template_object=plan_yaml_path, object_request=do_object_request) files = dict(list(template_files.items()) + list(env_files.items())) moved_files = self._upload_missing_files( stack_name, files, tht_root) self._process_and_upload_environment( stack_name, env, moved_files, tht_root) # Invokes the workflows specified in plan environment file if plan_env_file: workflow_params.invoke_plan_env_workflows(self.clients, stack_name, plan_env_file) workflow_params.check_deprecated_parameters(self.clients, stack_name) if not update_plan_only: print("Deploying templates in the directory {0}".format( os.path.abspath(tht_root))) deployment.deploy_and_wait( self.log, self.clients, stack, stack_name, self.app_args.verbose_level, timeout=timeout, run_validations=run_validations, skip_deploy_identifier=skip_deploy_identifier, deployment_options=deployment_options)
def test_invoke_plan_env_workflows_no_workflow_params( self, mock_open, mock_safe_load): plan_env_data = {'name': 'overcloud'} mock_safe_load.return_value = plan_env_data parameters.invoke_plan_env_workflows(self.app.client_manager, 'overcloud', 'the-plan-environment.yaml') self.workflow.executions.create.assert_not_called()