From 43079a5c70769b32993f96ecb94662887d139c37 Mon Sep 17 00:00:00 2001 From: SteBaum <stephan.baum@edu.dsti.insitute> Date: Fri, 27 Oct 2023 17:25:37 +0200 Subject: [PATCH 1/2] feat: modified function operation in cli commands to ops --- tdp/cli/__main__.py | 4 ++-- tdp/cli/commands/operations.py | 2 +- tdp/cli/commands/test_operations.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tdp/cli/__main__.py b/tdp/cli/__main__.py index 9b5f14a7..0ef920b9 100644 --- a/tdp/cli/__main__.py +++ b/tdp/cli/__main__.py @@ -13,7 +13,7 @@ from tdp.cli.commands.default_diff import default_diff from tdp.cli.commands.deploy import deploy from tdp.cli.commands.init import init -from tdp.cli.commands.operations import operations +from tdp.cli.commands.operations import ops from tdp.cli.commands.plan import plan from tdp.cli.commands.playbooks import playbooks from tdp.cli.commands.status import status @@ -62,7 +62,7 @@ def main(): cli.add_command(default_diff) cli.add_command(deploy) cli.add_command(init) - cli.add_command(operations) + cli.add_command(ops) cli.add_command(plan) cli.add_command(playbooks) cli.add_command(status) diff --git a/tdp/cli/commands/operations.py b/tdp/cli/commands/operations.py index b301ccc9..e0620d15 100644 --- a/tdp/cli/commands/operations.py +++ b/tdp/cli/commands/operations.py @@ -28,7 +28,7 @@ help="Display DAG operations in topological order.", ) @collections -def operations( +def ops( collections: Collections, display_dag_operations: bool, hosts: list[str], diff --git a/tdp/cli/commands/test_operations.py b/tdp/cli/commands/test_operations.py index cefbd3da..de5bc063 100644 --- a/tdp/cli/commands/test_operations.py +++ b/tdp/cli/commands/test_operations.py @@ -5,11 +5,11 @@ from click.testing import CliRunner -from tdp.cli.commands.operations import operations +from tdp.cli.commands.operations import ops def test_tdp_nodes(collection_path: Path): args = ["--collection-path", collection_path] runner = CliRunner() - result = runner.invoke(operations, args) + result = runner.invoke(ops, args) assert result.exit_code == 0, result.output From 80c35e608dd3ec29418512be8c0463a97c8cb5ac Mon Sep 17 00:00:00 2001 From: SteBaum <stephan.baum@edu.dsti.insitute> Date: Fri, 27 Oct 2023 17:30:23 +0200 Subject: [PATCH 2/2] fix: make the --host option work without calling --dag --- tdp/cli/commands/operations.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tdp/cli/commands/operations.py b/tdp/cli/commands/operations.py index e0620d15..9046d50d 100644 --- a/tdp/cli/commands/operations.py +++ b/tdp/cli/commands/operations.py @@ -54,11 +54,13 @@ def ops( sorted_operations = sorted(operations, key=lambda operation: operation.name) _print_operations(sorted_operations) else: - _print_operations( - sorted( - collections.operations.values(), key=lambda operation: operation.name - ) - ) + operations = [ + operation + for operation in collections.operations.values() + if len(hosts) == 0 or bool(set(operation.host_names) & set(hosts)) + ] + sorted_operations = sorted(operations, key=lambda operation: operation.name) + _print_operations(sorted_operations) def _print_operations(operations: Iterable[Operation], /):