From 83a560401f8be0db8ae21414edc0b8415603c0d0 Mon Sep 17 00:00:00 2001
From: Karel van Klink <karel.vanklink@geant.org>
Date: Thu, 28 Dec 2023 10:12:02 +0100
Subject: [PATCH] move create router workflow to new provisioning proxy
 endpoint

---
 gso/workflows/router/create_router.py       | 33 +++------------------
 test/workflows/router/test_create_router.py |  4 +--
 2 files changed, 6 insertions(+), 31 deletions(-)

diff --git a/gso/workflows/router/create_router.py b/gso/workflows/router/create_router.py
index 4cb22261..72f9dd9b 100644
--- a/gso/workflows/router/create_router.py
+++ b/gso/workflows/router/create_router.py
@@ -20,11 +20,12 @@ from gso.products.product_blocks.router import (
 )
 from gso.products.product_types.router import RouterInactive, RouterProvisioning
 from gso.products.product_types.site import Site
-from gso.services import infoblox, provisioning_proxy, subscriptions
+from gso.services import infoblox, subscriptions
 from gso.services.crm import customer_selector
 from gso.services.netbox_client import NetboxClient
 from gso.services.provisioning_proxy import pp_interaction
 from gso.utils.helpers import iso_from_ipv4
+from gso.utils.workflow_steps import deploy_base_config_dry, deploy_base_config_real
 
 
 def _site_selector() -> Choice:
@@ -123,32 +124,6 @@ def ipam_allocate_loopback(subscription: RouterProvisioning) -> State:
     return {"subscription": subscription}
 
 
-@step("Provision router [DRY RUN]")
-def provision_router_dry(
-    subscription: RouterProvisioning,
-    process_id: UUIDstr,
-    callback_route: str,
-    tt_number: str,
-) -> State:
-    """Perform a dry run of deploying configuration on the router."""
-    provisioning_proxy.provision_router(subscription, process_id, callback_route, tt_number)
-
-    return {"subscription": subscription}
-
-
-@step("Provision router [FOR REAL]")
-def provision_router_real(
-    subscription: RouterProvisioning,
-    process_id: UUIDstr,
-    callback_route: str,
-    tt_number: str,
-) -> State:
-    """Deploy configuration on the router."""
-    provisioning_proxy.provision_router(subscription, process_id, callback_route, tt_number, dry_run=False)
-
-    return {"subscription": subscription}
-
-
 @step("Create NetBox Device")
 def create_netbox_device(subscription: RouterProvisioning) -> State:
     """Create a new device in Netbox.
@@ -194,8 +169,8 @@ def create_router() -> StepList:
         >> store_process_subscription(Target.CREATE)
         >> initialize_subscription
         >> ipam_allocate_loopback
-        >> pp_interaction(provision_router_dry)
-        >> pp_interaction(provision_router_real)
+        >> pp_interaction(deploy_base_config_dry)
+        >> pp_interaction(deploy_base_config_real)
         >> verify_ipam_loopback
         >> create_netbox_device
         >> set_status(SubscriptionLifecycle.ACTIVE)
diff --git a/test/workflows/router/test_create_router.py b/test/workflows/router/test_create_router.py
index 71929a91..8f9129ac 100644
--- a/test/workflows/router/test_create_router.py
+++ b/test/workflows/router/test_create_router.py
@@ -33,7 +33,7 @@ def router_creation_input_form_data(site_subscription_factory, faker):
 
 
 @pytest.mark.workflow()
-@patch("gso.workflows.router.create_router.provisioning_proxy.provision_router")
+@patch("gso.utils.workflow_steps.execute_playbook")
 @patch("gso.workflows.router.create_router.NetboxClient.create_device")
 @patch("gso.workflows.router.create_router.infoblox.hostname_available")
 @patch("gso.workflows.router.create_router.infoblox.find_host_by_fqdn")
@@ -100,7 +100,7 @@ def test_create_nokia_router_success(
 
 
 @pytest.mark.workflow()
-@patch("gso.workflows.router.create_router.provisioning_proxy.provision_router")
+@patch("gso.utils.workflow_steps.execute_playbook")
 @patch("gso.workflows.router.create_router.NetboxClient.create_device")
 @patch("gso.workflows.router.create_router.infoblox.hostname_available")
 @patch("gso.workflows.router.create_router.infoblox.find_network_by_cidr")
-- 
GitLab