Skip to content

Base migrate placement port

Base functionality for migrating Placement Port services.

initial_input_form_generator(subscription_id)

Generate the initial input form for migrating a Placement Port service.

Source code in gso/workflows/placement_port/base_migrate_placement_port.py
def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator:
    """Generate the initial input form for migrating a Placement Port service."""
    subscription = SubscriptionModel.from_subscription(subscription_id)
    product_name = subscription.product.name
    geant_partner_id = get_partner_by_name("GEANT")
    l3_interface = subscription.l3_interface  # type: ignore[attr-defined]

    class ModifyPlacementPortForm(SubmitFormPage):
        model_config = ConfigDict(title=f"Modify {product_name}")

        tt_number: TTNumber
        current_edge_port: read_only_field(  # type: ignore[valid-type]
            EdgePort.from_subscription(l3_interface.edge_port.owner_subscription_id).description
        )
        new_edge_port: active_edge_port_selector(  # type: ignore[valid-type]
            partner_id=subscription.customer_id if subscription.customer_id != geant_partner_id else None
        ) = l3_interface.edge_port

    modified_input = yield ModifyPlacementPortForm

    return modified_input.model_dump()

update_subscription_model(subscription, new_edge_port)

Update the subscription model with new edge port information.

Source code in gso/workflows/placement_port/base_migrate_placement_port.py
@step("Update subscription with new edge port")
def update_subscription_model(
    subscription: SubscriptionModel,
    new_edge_port: UUIDstr,
) -> State:
    """Update the subscription model with new edge port information."""
    subscription.l3_interface.edge_port = EdgePort.from_subscription(new_edge_port).edge_port  # type: ignore[attr-defined]

    return {"subscription": subscription}