From 9d5834b259652c21fd2b552d01775d82ad4c27f9 Mon Sep 17 00:00:00 2001
From: Aleksandr Kurbatov <aleksandr.kurbatov@GL1342-AKURBATOV.local>
Date: Thu, 25 Jul 2024 15:35:38 +0100
Subject: [PATCH] Small fixes to terminate_router workflow

---
 gso/workflows/router/terminate_router.py | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/gso/workflows/router/terminate_router.py b/gso/workflows/router/terminate_router.py
index 395f8c7a..688e3ecc 100644
--- a/gso/workflows/router/terminate_router.py
+++ b/gso/workflows/router/terminate_router.py
@@ -98,7 +98,7 @@ def remove_config_from_router_real(
     }
 
     execute_playbook(
-        playbook_name="base_config.yaml",
+        playbook_name="base_config.yaml",  # FIX: need to use correct playbook.
         callback_route=callback_route,
         inventory=subscription.router.router_fqdn,
         extra_vars=extra_vars,
@@ -117,7 +117,7 @@ def remove_p_from_all_pe_dry(subscription: Router, callback_route: str, tt_numbe
     """Perform a dry run of removing the terminated router from all the PE routers."""
     extra_vars = {
         "dry_run": True,
-        "subscription": subscription,
+        "subscription": json.loads(json_dumps(subscription)),
         "commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - "
         f"Remove {subscription.router.router_fqdn} from all the PE routers",
         "verb": "remove_p_from_pe",
@@ -136,7 +136,7 @@ def remove_p_from_all_pe_real(subscription: Router, callback_route: str, tt_numb
     """Perform a real run of removing the terminated router from all the PE routers."""
     extra_vars = {
         "dry_run": False,
-        "subscription": subscription,
+        "subscription": json.loads(json_dumps(subscription)),
         "commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - "
         f"Remove {subscription.router.router_fqdn} from all the PE routers",
         "verb": "remove_p_from_pe",
@@ -152,13 +152,13 @@ def remove_p_from_all_pe_real(subscription: Router, callback_route: str, tt_numb
 
 @step("[DRY RUN] Remove PE router from all the PE routers")
 def remove_pe_from_all_pe_dry(subscription: Router, callback_route: str, tt_number: str, process_id: UUIDstr) -> None:
-    """Perform a dry run of removing the terminated router from all the PE routers."""
+    """Perform a dry run of removing the terminated PE router from the PE router mesh."""
     extra_vars = {
         "dry_run": True,
-        "subscription": subscription,
+        "subscription": json.loads(json_dumps(subscription)),
         "commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - "
         f"Remove {subscription.router.router_fqdn} from all the PE routers",
-        "verb": "remove_p_from_net",
+        "verb": "remove_pe_from_pe",
     }
 
     lso_client.execute_playbook(
@@ -173,13 +173,13 @@ def remove_pe_from_all_pe_dry(subscription: Router, callback_route: str, tt_numb
 
 @step("[REAL RUN] Remove all PE routers from all the PE routers")
 def remove_pe_from_all_pe_real(subscription: Router, callback_route: str, tt_number: str, process_id: UUIDstr) -> None:
-    """Perform a real run of removing PE router from P router iBGP table."""
+    """Perform a real run of removing terminated PE router from PE the router mesh."""
     extra_vars = {
         "dry_run": False,
-        "subscription": subscription,
+        "subscription": json.loads(json_dumps(subscription)),
         "commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - "
         f"Remove {subscription.router.router_fqdn} from iBGP mesh",
-        "verb": "remove_p_from_net",
+        "verb": "remove_pe_from_pe",
     }
 
     lso_client.execute_playbook(
@@ -197,7 +197,7 @@ def remove_pe_from_all_p_dry(subscription: Router, callback_route: str, tt_numbe
     """Perform a dry run of removing PE router from all P routers."""
     extra_vars = {
         "dry_run": True,
-        "subscription": subscription,
+        "subscription": json.loads(json_dumps(subscription)),
         "commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - "
         f"Remove {subscription.router.router_fqdn} from all the P routers",
         "verb": "remove_pe_from_p",
@@ -213,10 +213,10 @@ def remove_pe_from_all_p_dry(subscription: Router, callback_route: str, tt_numbe
 
 @step("[REAL RUN] Remove PE router from all P routers")
 def remove_pe_from_all_p_real(subscription: Router, callback_route: str, tt_number: str, process_id: UUIDstr) -> None:
-    """Perform a dry run of removing PE router from all P routers."""
+    """Perform a real run of removing PE router from all P routers."""
     extra_vars = {
         "dry_run": False,
-        "subscription": subscription,
+        "subscription": json.loads(json_dumps(subscription)),
         "commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - "
         f"Remove {subscription.router.router_fqdn} from all the P routers",
         "verb": "remove_pe_from_p",
-- 
GitLab