Skip to content

Redeploy vrf

Redeploy VRF on all routers currently in the subscription's list.

initial_input_form_generator(subscription_id)

Redeploy VRF on all routers in the list of the subscription.

Source code in gso/workflows/vrf/redeploy_vrf.py
def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator:
    """Redeploy VRF on all routers in the list of the subscription."""
    subscription = VRF.from_subscription(subscription_id)

    def existing_router_list() -> type[list]:
        return cast(
            type[list],
            ReadOnlyField(
                [router.router_fqdn for router in subscription.vrf.vrf_router_list],
                default_type=list[str],
            ),
        )

    class RedeployVRFForm(FormPage):
        model_config = ConfigDict(title="Redeploy VRF router list.")
        tt_number: TTNumber

        divider: Divider
        label: Label = Field(
            "Running this workflow will redeploy the VRF on list of routers presented here:", exclude=True
        )
        existing_routers: existing_router_list()  # type: ignore[valid-type]

    initial_input = yield RedeployVRFForm
    return {
        "tt_number": initial_input.tt_number,
        "fqdn_list": [router.router_fqdn for router in subscription.vrf.vrf_router_list],
    }

update_vrf_on_router_dry(subscription, process_id, tt_number, fqdn_list)

Redeploy VRF on all routers - dry run.

Source code in gso/workflows/vrf/redeploy_vrf.py
@step("[DRY RUN] Update VRF on list of routers")
def update_vrf_on_router_dry(
    subscription: dict[str, Any], process_id: UUIDstr, tt_number: str, fqdn_list: list[str]
) -> LSOState:
    """Redeploy VRF on all routers - dry run."""
    extra_vars = {
        "subscription": subscription,
        "dry_run": True,
        "verb": "add",
        "commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - "
        f"Redeploy for {subscription["description"]}",
    }

    return {
        "playbook_name": "gap_ansible/playbooks/vrf_update.yaml",
        "inventory": {"all": {"hosts": dict.fromkeys(fqdn_list)}},
        "extra_vars": extra_vars,
    }

update_vrf_on_router_real(subscription, process_id, tt_number, fqdn_list)

Redeploy VRF on all routers - with commit.

Source code in gso/workflows/vrf/redeploy_vrf.py
@step("[FOR REAL] Update VRF on list of routers")
def update_vrf_on_router_real(
    subscription: dict[str, Any], process_id: UUIDstr, tt_number: str, fqdn_list: list[str]
) -> LSOState:
    """Redeploy VRF on all routers - with commit."""
    extra_vars = {
        "subscription": subscription,
        "dry_run": False,
        "verb": "add",
        "commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - "
        f"Redeploy for {subscription["description"]}",
    }

    return {
        "playbook_name": "gap_ansible/playbooks/vrf_update.yaml",
        "inventory": {"all": {"hosts": dict.fromkeys(fqdn_list)}},
        "extra_vars": extra_vars,
    }

redeploy_vrf()

Redeploy the VRF router list.

Source code in gso/workflows/vrf/redeploy_vrf.py
@workflow(
    "Redeploy VRF router list",
    initial_input_form=wrap_modify_initial_input_form(initial_input_form_generator),
    target=Target.MODIFY,
)
def redeploy_vrf() -> StepList:
    """Redeploy the VRF router list."""
    return (
        begin
        >> store_process_subscription(Target.MODIFY)
        >> unsync
        >> lso_interaction(update_vrf_on_router_dry)
        >> lso_interaction(update_vrf_on_router_real)
        >> resync
        >> done
    )