Skip to content
Snippets Groups Projects
Commit b248b3a1 authored by Karel van Klink's avatar Karel van Klink :smiley_cat: Committed by Neda Moeini
Browse files

convert scheduled router validation to celery task

parent 8d6f0d9d
No related branches found
No related tags found
1 merge request!139Feature/add validation workflows
"""Tasks that are scheduled to run periodically in :term:`GSO`."""
from orchestrator.schedules import SchedulingFunction # type:ignore[attr-defined]
from gso.schedules.validate_routers_nightly import run_validate_routers
# TODO: This list overwrites the default, and therefore leaves all default schedules unused.
# TODO: Consider using the default schedules.
ALL_SCHEDULERS: list[SchedulingFunction] = [run_validate_routers]
"""Nightly schedule for validating all active Routers' configuration."""
import logging
from orchestrator.schedules.scheduling import scheduler
from orchestrator.services.processes import start_process
from gso.services.subscriptions import get_active_router_subscriptions
logger = logging.getLogger(__name__)
@scheduler(name="Validate routers", time_unit="day", at="03:00")
def run_validate_routers() -> None:
"""Validate configuration on all active Routers, every night at 3AM."""
routers = get_active_router_subscriptions(includes=["subscription_id"])
for router in routers:
msg = f"Validating configuration of router subscription {router['subscription_id']}"
logger.info(msg)
start_process("validate_router", [{"subscription_id": router["subscription_id"]}])
......@@ -42,6 +42,7 @@ LazyWorkflowInstance("gso.workflows.router.update_ibgp_mesh", "update_ibgp_mesh"
LazyWorkflowInstance("gso.workflows.router.modify_connection_strategy", "modify_connection_strategy")
LazyWorkflowInstance("gso.workflows.router.import_router", "import_router")
LazyWorkflowInstance("gso.workflows.router.create_imported_router", "create_imported_router")
LazyWorkflowInstance("gso.workflows.router.validate_router", "validate_router")
# Site workflows
LazyWorkflowInstance("gso.workflows.site.create_site", "create_site")
......
......@@ -16,7 +16,7 @@ from gso.workflows.router.create_router import verify_ipam_loopback
@step("Validate router configuration")
def validate_router_config(subscription: Router, callback_route: str) -> None:
"""Run an Ansible playbook that validates the configuration that is present on an active Router."""
extra_vars = {"wfo_router_json": json.loads(json_dumps(subscription)), "verb": "validate"}
extra_vars = {"wfo_router": json.loads(json_dumps(subscription)), "verb": "validate"}
execute_playbook(
playbook_name="base_config.yaml",
......
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