From d1c4524de710b4651f133f4f96a3a8410431f6c1 Mon Sep 17 00:00:00 2001 From: Karel van Klink <karel.vanklink@geant.org> Date: Tue, 2 Jan 2024 15:41:40 +0100 Subject: [PATCH] split off duplicate code to helper method --- gso/utils/workflow_steps.py | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/gso/utils/workflow_steps.py b/gso/utils/workflow_steps.py index 1f87a2fa..9a8a14dd 100644 --- a/gso/utils/workflow_steps.py +++ b/gso/utils/workflow_steps.py @@ -11,19 +11,19 @@ from gso.products.product_types.iptrunk import Iptrunk from gso.services.provisioning_proxy import execute_playbook -@step("[DRY RUN] Deploy base config") -def deploy_base_config_dry( +def _deploy_base_config( 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.""" + *, + dry_run: bool, +) -> None: inventory = subscription["router"]["router_fqdn"] extra_vars = { "wfo_router_json": subscription, - "dry_run": True, + "dry_run": dry_run, "verb": "deploy", "commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - Deploy base config", } @@ -35,6 +35,17 @@ def deploy_base_config_dry( extra_vars=extra_vars, ) + +@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.""" + _deploy_base_config(subscription, tt_number, callback_route, process_id, dry_run=True) + return {"subscription": subscription} @@ -46,21 +57,7 @@ def deploy_base_config_real( 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, - ) + _deploy_base_config(subscription, tt_number, callback_route, process_id, dry_run=False) return {"subscription": subscription} -- GitLab