Skip to content

Modify isis metric

A modification workflow for setting a new ISIS metric for an IP trunk.

The strategy is to re-apply the necessary template to the configuration construct: using a "replace" strategy only the necessary modifications will be applied.

initial_input_form_generator(subscription_id)

Ask the operator for the new ISIS metric.

Source code in gso/workflows/iptrunk/modify_isis_metric.py
def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator:
    """Ask the operator for the new ISIS metric."""
    subscription = Iptrunk.from_subscription(subscription_id)

    class ModifyIptrunkForm(SubmitFormPage):
        tt_number: TTNumber
        isis_metric: int = subscription.iptrunk.iptrunk_isis_metric

    user_input = yield ModifyIptrunkForm
    user_input = user_input.model_dump()
    yield from modify_summary_form(
        {"iptrunk_isis_metric": user_input["isis_metric"]}, subscription.iptrunk, ["iptrunk_isis_metric"]
    )
    return user_input

modify_iptrunk_subscription(subscription, isis_metric)

Store the new ISIS metric in the database by updating the subscription.

Source code in gso/workflows/iptrunk/modify_isis_metric.py
@step("Update subscription")
def modify_iptrunk_subscription(subscription: Iptrunk, isis_metric: int) -> State:
    """Store the new ISIS metric in the database by updating the subscription."""
    subscription.iptrunk.iptrunk_isis_metric = isis_metric

    return {"subscription": subscription}

provision_ip_trunk_isis_iface_dry(subscription, process_id, tt_number)

Perform a dry run of deploying the new ISIS metric on both sides of the trunk.

Source code in gso/workflows/iptrunk/modify_isis_metric.py
@step("[DRY RUN] Provision IP trunk ISIS interface")
def provision_ip_trunk_isis_iface_dry(subscription: Iptrunk, process_id: UUIDstr, tt_number: str) -> LSOState:
    """Perform a dry run of deploying the new ISIS metric on both sides of the trunk."""
    extra_vars = {
        "wfo_trunk_json": json.loads(json_dumps(subscription)),
        "dry_run": True,
        "verb": "deploy",
        "config_object": "isis_interface",
        "commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - Deploy config for "
        f"{subscription.iptrunk.gs_id}",
    }

    return {
        "playbook_name": "gap_ansible/playbooks/iptrunks.yaml",
        "inventory": {
            "all": {
                "hosts": {
                    subscription.iptrunk.iptrunk_sides[0].iptrunk_side_node.router_fqdn: None,
                    subscription.iptrunk.iptrunk_sides[1].iptrunk_side_node.router_fqdn: None,
                }
            }
        },
        "extra_vars": extra_vars,
    }

provision_ip_trunk_isis_iface_real(subscription, process_id, tt_number)

Deploy the new ISIS metric on both sides of the trunk.

Source code in gso/workflows/iptrunk/modify_isis_metric.py
@step("[FOR REAL] Provision IP trunk ISIS interface")
def provision_ip_trunk_isis_iface_real(subscription: Iptrunk, process_id: UUIDstr, tt_number: str) -> LSOState:
    """Deploy the new ISIS metric on both sides of the trunk."""
    extra_vars = {
        "wfo_trunk_json": json.loads(json_dumps(subscription)),
        "dry_run": False,
        "verb": "deploy",
        "config_object": "isis_interface",
        "commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - Deploy config for "
        f"{subscription.iptrunk.gs_id}",
    }

    return {
        "playbook_name": "gap_ansible/playbooks/iptrunks.yaml",
        "inventory": {
            "all": {
                "hosts": {
                    subscription.iptrunk.iptrunk_sides[0].iptrunk_side_node.router_fqdn: None,
                    subscription.iptrunk.iptrunk_sides[1].iptrunk_side_node.router_fqdn: None,
                }
            }
        },
        "extra_vars": extra_vars,
    }

modify_isis_metric()

Modify the ISIS metric of an existing IP trunk.

  • Modify the subscription model in the database
  • Perform a dry run of setting the new ISIS metric
  • Deploy the new ISIS metric on both sides of the trunk
Source code in gso/workflows/iptrunk/modify_isis_metric.py
@workflow(
    "Modify ISIS metric",
    initial_input_form=wrap_modify_initial_input_form(initial_input_form_generator),
    target=Target.MODIFY,
)
def modify_isis_metric() -> StepList:
    """Modify the ISIS metric of an existing IP trunk.

    * Modify the subscription model in the database
    * Perform a dry run of setting the new ISIS metric
    * Deploy the new ISIS metric on both sides of the trunk
    """
    return (
        begin
        >> store_process_subscription(Target.MODIFY)
        >> unsync
        >> modify_iptrunk_subscription
        >> lso_interaction(provision_ip_trunk_isis_iface_dry)
        >> lso_interaction(provision_ip_trunk_isis_iface_real)
        >> resync
        >> done
    )