Skip to content
Snippets Groups Projects

Also include provisioning routers for iBGP mesh in trunk validation workflow

Merged Karel van Klink requested to merge feature/fix-ibgp-update-in-validation into develop
Files
7
+ 12
2
@@ -5,6 +5,7 @@ import re
from typing import TYPE_CHECKING
from uuid import UUID
from orchestrator.types import SubscriptionLifecycle
from pydantic_forms.types import UUIDstr
from pydantic_forms.validators import Choice
@@ -122,10 +123,12 @@ def generate_fqdn(hostname: str, site_name: str, country_code: str) -> str:
return f"{hostname}.{site_name.lower()}.{country_code.lower()}{oss.IPAM.LO.domain_name}"
def generate_inventory_for_active_routers(
def generate_inventory_for_routers(
router_role: RouterRole,
exclude_routers: list[str] | None = None,
router_vendor: Vendor | None = None,
*,
include_provisioning_routers: bool = True,
) -> dict:
"""Generate an Ansible-compatible inventory for executing playbooks.
@@ -134,11 +137,18 @@ def generate_inventory_for_active_routers(
:param RouterRole router_role: The role of the routers to include in the inventory.
:param list exclude_routers: List of routers to exclude from the inventory.
:param Vendor router_vendor: The vendor of the routers to include in the inventory.
:param bool include_provisioning_routers: Include routers that are in a ``PROVISIONING`` state.
:return: A dictionary representing the inventory of active routers.
:rtype: dict[str, Any]
"""
lifecycles = (
[SubscriptionLifecycle.PROVISIONING, SubscriptionLifecycle.ACTIVE]
if include_provisioning_routers
else [SubscriptionLifecycle.ACTIVE]
)
all_routers = [
Router.from_subscription(r["subscription_id"]) for r in subscriptions.get_active_router_subscriptions()
Router.from_subscription(r["subscription_id"])
for r in subscriptions.get_router_subscriptions(lifecycles=lifecycles)
]
exclude_routers = exclude_routers or []
Loading