def test_extract_and_merge_to_install_executes_correctly(self): with mock.patch('cloudify.utils.merge_plugins') as merge_plugins_mock: dep_plugins = [{PLUGIN_INSTALL_KEY: True, 'dummy': 1}, {PLUGIN_INSTALL_KEY: True, 'dummy': 2}] wf_plugins = [{PLUGIN_INSTALL_KEY: True, 'dummy': 2}] utils.extract_and_merge_plugins( dep_plugins, wf_plugins, lambda x: x['dummy'] == 2) merge_plugins_mock.assert_called_with(dep_plugins[1:], wf_plugins)
def test_extract_and_merge_to_uninstall_executes_correctly(self): dep_plugins = [{PLUGIN_INSTALL_KEY: True, 'dummy': 1}, {PLUGIN_INSTALL_KEY: True, 'dummy': 2}] wf_plugins = [{PLUGIN_INSTALL_KEY: True, 'dummy': 2}] res = utils.extract_and_merge_plugins( dep_plugins, wf_plugins, lambda x: x['dummy'] == 2, with_repetition=True) self.assertListEqual(dep_plugins[1:] + wf_plugins, res)
def delete(ctx, deployment_plugins_to_uninstall, workflow_plugins_to_uninstall, delete_logs, **_): graph = ctx.graph_mode() sequence = graph.sequence() sequence.add( ctx.send_event('Deleting deployment [{}] environment'.format( ctx.deployment.id))) plugins_to_uninstall = extract_and_merge_plugins( deployment_plugins_to_uninstall, workflow_plugins_to_uninstall, with_repetition=True) add_plugins_to_uninstall(ctx, plugins_to_uninstall, sequence) graph.execute() _delete_deployment_workdir(ctx) if delete_logs: ctx.send_event("Deleting management workers' logs for deployment") _delete_logs(ctx) _send_request_to_delete_deployment_from_db(ctx)
def generate_create_dep_tasks_graph(ctx, deployment_plugins_to_install, workflow_plugins_to_install, policy_configuration=None): graph = ctx.graph_mode() sequence = graph.sequence() plugins_to_install = extract_and_merge_plugins( deployment_plugins_to_install, workflow_plugins_to_install) add_plugins_to_install(ctx, plugins_to_install, sequence) sequence.add( ctx.send_event('Creating deployment work directory'), ctx.local_task(_create_deployment_workdir, kwargs={ 'deployment_id': ctx.deployment.id, 'tenant': ctx.tenant_name, 'logger': ctx.logger })) return graph
def get_plugins_to_install(plan, is_old_plan): return extract_and_merge_plugins( plan[constants.DEPLOYMENT_PLUGINS_TO_INSTALL], plan[constants.WORKFLOW_PLUGINS_TO_INSTALL], filter_func=is_centrally_deployed, with_repetition=is_old_plan)