Skip to content
Snippets Groups Projects
Verified Commit a91e5d54 authored by Aleksandr Kurbatov's avatar Aleksandr Kurbatov Committed by Karel van Klink
Browse files

`validate_router` - check BGP depending on the router role.

parent 98f0e3b6
No related branches found
Tags 2.0
1 merge request!310`validate_router` - change in P-BGP verb
......@@ -52,9 +52,9 @@ def check_netbox_entry_exists(subscription: Router) -> None:
client.get_device_by_name(subscription.router.router_fqdn)
@step("Verify BGP configuration on P router")
@step("Verify P BGP P-ONLY neighbors")
def verify_p_ibgp(subscription: dict[str, Any]) -> LSOState:
"""Perform a dry run of adding the list of all PE routers to the new P router."""
"""Verify PE neighbors in P-ONLY group on a P router."""
extra_vars = {
"dry_run": True,
"subscription": subscription,
......@@ -70,6 +70,60 @@ def verify_p_ibgp(subscription: dict[str, Any]) -> LSOState:
}
@step("Verify PE BGP internal mesh neighbors")
def verify_pe_mesh_in_pe(subscription: dict[str, Any]) -> LSOState:
"""Verify PE internal mesh neighbors on a PE router."""
extra_vars = {
"dry_run": True,
"subscription": subscription,
"verb": "add_pe_mesh_to_pe",
"pe_router_list": generate_inventory_for_active_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_ibgp_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."""
extra_vars = {
"dry_run": True,
"subscription": subscription,
"verb": "add_all_p_to_pe",
"p_router_list": generate_inventory_for_active_routers(
router_role=RouterRole.P, exclude_routers=[subscription["router"]["router_fqdn"]]
)["all"]["hosts"],
"is_verification_workflow": "true",
}
if not extra_vars["p_router_list"]:
return {
"playbook_name": "",
"inventory": {"all": {"hosts": {}}},
"extra_vars": {},
}
return {
"playbook_name": "gap_ansible/playbooks/update_ibgp_mesh.yaml",
"inventory": {"all": {"hosts": {subscription["router"]["router_fqdn"]: None}}},
"extra_vars": extra_vars,
}
@step("Verify correct LibreNMS entry")
def check_librenms_entry_exists(subscription: Router) -> None:
"""Validate the LibreNMS entry for a Router.
......@@ -125,6 +179,7 @@ def validate_router() -> StepList:
"""
is_juniper_router = conditional(lambda state: state["subscription"]["router"]["vendor"] == Vendor.JUNIPER)
is_pe_router = conditional(lambda state: state["subscription"]["router"]["router_role"] == RouterRole.PE)
is_p_router = conditional(lambda state: state["subscription"]["router"]["router_role"] == RouterRole.P)
return (
begin
......@@ -137,7 +192,9 @@ def validate_router() -> StepList:
>> check_librenms_entry_exists
>> is_pe_router(check_kentik_entry_exists)
>> anonymous_lso_interaction(verify_base_config)
>> anonymous_lso_interaction(verify_p_ibgp)
>> 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))
>> resync
>> done
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment