Skip to content

Validate switch

Validation workflow for switch subscription objects.

check_netbox_device(subscription)

Fetch the device in Netbox. Will raise an exception if it is not found.

Source code in gso/workflows/switch/validate_switch.py
@step("Validate switch in Netbox")
def check_netbox_device(subscription: Switch) -> None:
    """Fetch the device in Netbox. Will raise an exception if it is not found."""
    NetboxClient().get_device_by_name(subscription.switch.fqdn)

verify_base_config(subscription)

Workflow step for running a playbook that checks whether base config has drifted.

Source code in gso/workflows/switch/validate_switch.py
@step("Check base config for drift")
def verify_base_config(subscription: dict[str, Any]) -> LSOState:
    """Workflow step for running a playbook that checks whether base config has drifted."""
    return {
        "playbook_name": "switch_base_config.yaml",
        "inventory": {"all": {"hosts": {subscription["switch"]["fqdn"]: None}}},
        "extra_vars": {
            "subscription_json": subscription,
            "verb": "deploy",
            "dry_run": "true",
            "is_verification_workflow": "true",
        },
    }

validate_switch()

Validate an existing, active switch subscription.

Source code in gso/workflows/switch/validate_switch.py
@workflow(
    "Validate switch subscription", target=Target.SYSTEM, initial_input_form=(wrap_modify_initial_input_form(None))
)
def validate_switch() -> StepList:
    """Validate an existing, active switch subscription."""
    return (
        begin
        >> store_process_subscription(Target.SYSTEM)
        >> unsync
        >> check_netbox_device
        >> anonymous_lso_interaction(verify_base_config)
        >> resync
        >> done
    )