From 036b6b93a9e813043bfbbe2397ccb11be7e91f81 Mon Sep 17 00:00:00 2001
From: Aleksandr Kurbatov <ak@geant.org>
Date: Tue, 20 May 2025 10:31:05 +0100
Subject: [PATCH] Add verification of SDP mesh config on a PE in
 `validate_router`

Verification of P neighbors can be skipped as we don't have them
anymore.
---
 gso/workflows/router/validate_router.py | 35 ++++++++++++++++++++++---
 1 file changed, 32 insertions(+), 3 deletions(-)

diff --git a/gso/workflows/router/validate_router.py b/gso/workflows/router/validate_router.py
index 38f6c4b6e..884170ce9 100644
--- a/gso/workflows/router/validate_router.py
+++ b/gso/workflows/router/validate_router.py
@@ -100,6 +100,34 @@ def verify_pe_mesh_in_pe(subscription: dict[str, Any]) -> LSOState:
     }
 
 
+@step("Verify SDP mesh on the PE router")
+def verify_sdp_single_pe(subscription: dict[str, Any]) -> LSOState:
+    """Verify SDP mesh on the PE router."""
+    extra_vars = {
+        "dry_run": True,
+        "subscription": subscription,
+        "verb": "add_pe_to_sdp_mesh",
+        "pe_router_list": generate_inventory_for_routers(
+            router_role=RouterRole.PE,
+            exclude_routers=[subscription["router"]["router_fqdn"]],
+        )["all"]["hosts"],
+        "is_verification_workflow": "true",
+    }
+
+    if not extra_vars["pe_router_list"]:
+        return {
+            "playbook_name": "",
+            "inventory": {"all": {"hosts": {}}},
+            "extra_vars": {},
+        }
+
+    return {
+        "playbook_name": "gap_ansible/playbooks/update_pe_sdp_mesh.yaml",
+        "inventory": {"all": {"hosts": {subscription["router"]["router_fqdn"]: None}}},
+        "extra_vars": extra_vars,
+    }
+
+
 @step("Verify PE BGP P-ONLY neighbors")
 def verify_all_p_in_pe(subscription: dict[str, Any]) -> LSOState:
     """Verify P neighbors in `P-ONLY` group on a PE router."""
@@ -173,7 +201,7 @@ def check_kentik_entry_exists(subscription: Router) -> None:
             raise ProcessFailureError(
                 message="Device in Kentik incorrectly configured",
                 details=f"Kentik device {subscription.router.router_fqdn} has the archiving license "
-                f"{archive_plan["name"]} applied to it, despite the existence of active layer 3 services.",
+                f"{archive_plan['name']} applied to it, despite the existence of active layer 3 services.",
             )
 
         placeholder_plan = client.get_plan_by_name(kentik_params.placeholder_license_key)
@@ -181,7 +209,7 @@ def check_kentik_entry_exists(subscription: Router) -> None:
             raise ProcessFailureError(
                 message="Device in Kentik incorrectly configured",
                 details=f"Kentik device {subscription.router.router_fqdn} has the placeholder license "
-                f"{placeholder_plan["name"]} applied to it, despite the existence of active layer 3 services.",
+                f"{placeholder_plan['name']} applied to it, despite the existence of active layer 3 services.",
             )
 
 
@@ -231,7 +259,8 @@ def validate_router() -> StepList:
         >> anonymous_lso_interaction(verify_base_config)
         >> is_p_router(anonymous_lso_interaction(verify_p_ibgp))
         >> is_pe_router(anonymous_lso_interaction(verify_pe_mesh_in_pe))
-        >> is_pe_router(anonymous_lso_interaction(verify_all_p_in_pe))
+        >> is_pe_router(anonymous_lso_interaction(verify_sdp_single_pe))
+        # >> is_pe_router(anonymous_lso_interaction(verify_all_p_in_pe))
         >> resync
         >> done
     )
-- 
GitLab