def stage(action, name, tag, d): if action and (name or tag): resource.stage_resources(name or tag, action) log = change.staged_log(populate_with_changes=True) for item in log: click.echo(data.compact(item)) if d: for line in data.details(item.diff): click.echo(' ' * 4 + line) if not log: click.echo('No changes')
def stage(action, name, tag, d): if action and (name or tag): resource.stage_resources(name or tag, action) log = change.staged_log() for item in log: click.echo(data.compact(item)) if d: for line in data.details(item.diff): click.echo(' ' * 4 + line) if not log: click.echo('No changes')
def test_childs_added_on_stage(): res_0, res_1 = [create_resource(str(n)) for n in range(2)] res_0.connect(res_1, {'a': 'a'}) ModelMeta.save_all_lazy() created_log_items = stage_resources(res_0.name, 'run') assert len(created_log_items) == 1 assert created_log_items[0].resource == res_0.name staged_log = change.staged_log() assert len(staged_log) == 2 child_log_item = next(li for li in staged_log if li.resource == res_1.name) assert child_log_item.action == 'run'
def test_stage_and_process_partially(): a = ['a'] b = ['b'] both = a + b range_a = range(1, 4) range_b = range(4, 6) with_tag_a = [create_resource(str(n), tags=a) for n in range_a] with_tag_b = [create_resource(str(n), tags=b) for n in range_b] ModelMeta.save_all_lazy() created_log_items_with_a = stage_resources(a, 'restart') assert len(created_log_items_with_a) == len(with_tag_a) created_log_items_with_b = stage_resources(b, 'restart') assert len(created_log_items_with_b) == len(with_tag_b) a_graph = change.send_to_orchestration(a) a_expected = set(['%s.restart' % n for n in range_a]) compare_task_to_names(set(a_graph.nodes()), a_expected) b_graph = change.send_to_orchestration(b) b_expected = set(['%s.restart' % n for n in range_b]) compare_task_to_names(set(b_graph.nodes()), b_expected) both_graph = change.send_to_orchestration(both) compare_task_to_names(set(both_graph.nodes()), a_expected | b_expected)
def test_stage_and_process_partially(): a = ['a'] b = ['b'] both = a + b range_a = range(1, 4) range_b = range(4, 6) with_tag_a = [create_resource(str(n), tags=a) for n in range_a] with_tag_b = [create_resource(str(n), tags=b) for n in range_b] ModelMeta.save_all_lazy() created_log_items_with_a = stage_resources(a, 'restart') assert len(created_log_items_with_a) == len(with_tag_a) created_log_items_with_b = stage_resources(b, 'restart') assert len(created_log_items_with_b) == len(with_tag_b) a_graph = change.send_to_orchestration(a) a_expected = set(['%s.restart' % n for n in range_a]) assert set(a_graph.nodes()) == a_expected b_graph = change.send_to_orchestration(b) b_expected = set(['%s.restart' % n for n in range_b]) assert set(b_graph.nodes()) == b_expected both_graph = change.send_to_orchestration(both) assert set(both_graph.nodes()) == a_expected | b_expected