From 8a9e0d4d64b7c020b9259199cdbb7921b8d2c97c Mon Sep 17 00:00:00 2001
From: Aleksandr Kurbatov <aleksandr.kurbatov@GL1342.local>
Date: Thu, 4 Jul 2024 11:38:02 +0100
Subject: [PATCH] Adding LLDP check after fiber move

---
 gso/workflows/iptrunk/migrate_iptrunk.py | 29 ++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/gso/workflows/iptrunk/migrate_iptrunk.py b/gso/workflows/iptrunk/migrate_iptrunk.py
index 15579738..a9229493 100644
--- a/gso/workflows/iptrunk/migrate_iptrunk.py
+++ b/gso/workflows/iptrunk/migrate_iptrunk.py
@@ -266,6 +266,34 @@ def check_ip_trunk_optical_levels_post(
     return {"subscription": subscription}
 
 
+@step("Check LLDP on the trunk endpoints")
+def check_ip_trunk_lldp(
+    subscription: Iptrunk,
+    callback_route: str,
+    new_node: Router,
+    new_lag_member_interfaces: list[dict],
+    replace_index: int,
+) -> State:
+    """Check LLDP on the new trunk endpoints."""
+    extra_vars = {
+        "wfo_ip_trunk_json": json.loads(json_dumps(subscription)),
+        "new_node": json.loads(json_dumps(new_node)),
+        "new_lag_member_interfaces": new_lag_member_interfaces,
+        "replace_index": replace_index,
+        "check": "lldp",
+    }
+
+    execute_playbook(
+        playbook_name="iptrunks_checks.yaml",
+        callback_route=callback_route,
+        inventory=f"{subscription.iptrunk.iptrunk_sides[1 - replace_index].iptrunk_side_node.router_fqdn}\n"
+        f"{new_node.router.router_fqdn}\n",
+        extra_vars=extra_vars,
+    )
+
+    return {"subscription": subscription}
+
+
 @step("[DRY RUN] Disable configuration on old router")
 def disable_old_config_dry(
     subscription: Iptrunk,
@@ -830,6 +858,7 @@ def migrate_iptrunk() -> StepList:
         >> trunk_type_is_leased(lso_interaction(update_remaining_side_bfd_real))
         >> confirm_continue_move_fiber
         >> lso_interaction(check_ip_trunk_optical_levels_post)
+        >> lso_interaction(check_ip_trunk_lldp)
         >> trunk_type_is_leased(lso_interaction(check_ip_trunk_bfd))
         >> lso_interaction(check_ip_trunk_connectivity)
         >> lso_interaction(deploy_new_isis)
-- 
GitLab