Skip to content

Terminate vrf

A workflow for terminating a VRF subscription.

initial_input_form_generator(subscription_id)

Ask the user for confirmation whether to terminate the selected VRF.

Source code in gso/workflows/vrf/terminate_vrf.py
def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator:
    """Ask the user for confirmation whether to terminate the selected VRF."""
    vrf_subscription = VRF.from_subscription(subscription_id)

    class TerminateForm(SubmitFormPage):
        termination_label: Label = f"Are you sure you want to delete {vrf_subscription.vrf.vrf_name} VRF?"
        tt_number: TTNumber

        @model_validator(mode="before")
        def vrf_must_have_empty_router_list(cls, data: Any) -> Any:
            if vrf_subscription.vrf.vrf_router_list:
                msg = (
                    "VRF must not have any routers assigned to it before it can be deleted. Please remove all"
                    " routers from the VRF first."
                )
                raise ValueError(msg)
            return data

    user_input = yield TerminateForm
    return user_input.model_dump()

terminate_vrf()

Terminate a VRF subscription.

Source code in gso/workflows/vrf/terminate_vrf.py
@workflow(
    "Terminate VRF",
    initial_input_form=wrap_modify_initial_input_form(initial_input_form_generator),
    target=Target.TERMINATE,
)
def terminate_vrf() -> StepList:
    """Terminate a VRF subscription."""
    return (
        begin
        >> store_process_subscription(Target.TERMINATE)
        >> unsync
        >> set_status(SubscriptionLifecycle.TERMINATED)
        >> resync
        >> done
    )