From a4b2ba4304ff498115e202975f9d5df03dd687d5 Mon Sep 17 00:00:00 2001
From: Karel van Klink <karel.vanklink@geant.org>
Date: Wed, 27 Dec 2023 16:44:27 +0100
Subject: [PATCH] add module for shared workflow steps

---
 gso/utils/workflow_steps.py | 62 +++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644 gso/utils/workflow_steps.py

diff --git a/gso/utils/workflow_steps.py b/gso/utils/workflow_steps.py
new file mode 100644
index 00000000..f4308838
--- /dev/null
+++ b/gso/utils/workflow_steps.py
@@ -0,0 +1,62 @@
+"""Workflow steps that are shared across multiple workflows."""
+
+from typing import Any
+
+from orchestrator import step
+from orchestrator.types import State, UUIDstr
+
+from gso.services.provisioning_proxy import execute_playbook
+
+
+@step("[DRY RUN] Deploy base config")
+def deploy_base_config_dry(
+    subscription: dict[str, Any],
+    tt_number: str,
+    callback_route: str,
+    process_id: UUIDstr,
+) -> State:
+    """Perform a dry run of provisioning base config on a router."""
+    inventory = subscription["router"]["router_fqdn"]
+
+    extra_vars = {
+        "wfo_router_json": subscription,
+        "dry_run": True,
+        "verb": "deploy",
+        "commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - Deploy base config",
+    }
+
+    execute_playbook(
+        playbook_name="base_config.yaml",
+        callback_route=callback_route,
+        inventory=inventory,
+        extra_vars=extra_vars,
+    )
+
+    return {"subscription": subscription}
+
+
+@step("[FOR REAL] Deploy base config")
+def deploy_base_config_real(
+    subscription: dict[str, Any],
+    tt_number: str,
+    callback_route: str,
+    process_id: UUIDstr,
+) -> State:
+    """Deploy base config on a router using the provisioning proxy."""
+    inventory = subscription["router"]["router_fqdn"]
+
+    extra_vars = {
+        "wfo_router_json": subscription,
+        "dry_run": False,
+        "verb": "deploy",
+        "commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - Deploy base config",
+    }
+
+    execute_playbook(
+        playbook_name="base_config.yaml",
+        callback_route=callback_route,
+        inventory=inventory,
+        extra_vars=extra_vars,
+    )
+
+    return {"subscription": subscription}
-- 
GitLab