diff --git a/gso/workflows/router/validate_router.py b/gso/workflows/router/validate_router.py index abc23133bcab743b3f04bd10b91de52a4f5fa0d6..ab12ffd831cc9fe0717f24963578e1222bf66c59 100644 --- a/gso/workflows/router/validate_router.py +++ b/gso/workflows/router/validate_router.py @@ -14,6 +14,18 @@ from gso.services import infoblox from gso.services.lso_client import execute_playbook, lso_interaction +@step("Verify IPAM resources for loopback interface") +def verify_ipam_loopback(subscription: Router) -> None: + """Validate the :term:`IPAM` resources for the loopback interface. + + Raises an :class:`orchestrator.utils.errors.ProcessFailureError` if :term:`IPAM` is configured incorrectly. + """ + host_record = infoblox.find_host_by_fqdn(f"lo0.{subscription.router.router_fqdn}") + if not host_record or str(subscription.subscription_id) not in host_record.comment: + msg = "Loopback record is incorrectly configured in IPAM, please investigate this manually!" + raise ProcessFailureError(msg) + + @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.""" @@ -27,18 +39,6 @@ def validate_router_config(subscription: Router, callback_route: str) -> None: ) -@step("Verify IPAM resources for loopback interface") -def verify_ipam_loopback(subscription: Router) -> None: - """Validate the :term:`IPAM` resources for the loopback interface. - - Raises an :class:`orchestrator.utils.errors.ProcessFailureError` if :term:`IPAM` is configured incorrectly. - """ - host_record = infoblox.find_host_by_fqdn(f"lo0.{subscription.router.router_fqdn}") - if not host_record or str(subscription.subscription_id) not in host_record.comment: - msg = "Loopback record is incorrectly configured in IPAM, please investigate this manually!" - raise ProcessFailureError(msg) - - @workflow( "Validate router configuration", target=Target.SYSTEM, @@ -47,15 +47,15 @@ def verify_ipam_loopback(subscription: Router) -> None: def validate_router() -> StepList: """Validate an existing, active Router subscription. - * Run an Ansible playbook to verify the configuration is intact. * Verify that the loopback interface is correctly configured in :term:`IPAM`. + * Redeploy base config to verify the configuration is intact. """ return ( init >> store_process_subscription(Target.SYSTEM) >> unsync - >> lso_interaction(validate_router_config) >> verify_ipam_loopback + >> lso_interaction(validate_router_config) >> resync >> done )