diff --git a/gso/workflows/iptrunk/migrate_iptrunk.py b/gso/workflows/iptrunk/migrate_iptrunk.py index 1c18cf122fea26222c2982ad60ba73e0cf52a672..555a41b85aa92e3e8521cb18056fc7282f5f52e3 100644 --- a/gso/workflows/iptrunk/migrate_iptrunk.py +++ b/gso/workflows/iptrunk/migrate_iptrunk.py @@ -100,7 +100,8 @@ def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator: new_router = new_side_iptrunk_router_input.new_node side_a_ae_iface = available_lags_choices(new_router) or str - if get_router_vendor(new_router) == RouterVendor.NOKIA: + new_side_is_nokia = get_router_vendor(new_router) == RouterVendor.NOKIA + if new_side_is_nokia: class NokiaLAGMember(LAGMember): interface_name: available_interfaces_choices( # type: ignore[valid-type] @@ -163,6 +164,7 @@ def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator: | new_side_iptrunk_router_input.dict() | new_side_input.dict() | {"replace_index": replace_index} + | {"new_side_is_nokia": new_side_is_nokia} ) @@ -531,32 +533,30 @@ def reserve_interfaces_in_netbox( new_lag_interface: str, new_lag_member_interfaces: list[dict], ) -> State: - """Reserve new interfaces in Netbox.""" + """Reserve new interfaces in Netbox, only when the new side's router is a NOKIA router.""" new_side = Router.from_subscription(new_node).router - nbclient = NetboxClient() - if new_side.vendor == RouterVendor.NOKIA: - # Create :term:`LAG` interfaces - lag_interface: Interfaces = nbclient.create_interface( - iface_name=new_lag_interface, - interface_type="lag", + # Create :term:`LAG` interfaces + lag_interface: Interfaces = nbclient.create_interface( + iface_name=new_lag_interface, + interface_type="lag", + device_name=new_side.router_fqdn, + description=str(subscription.subscription_id), + enabled=True, + ) + # Attach physical interfaces to :term:`LAG` + # Reserve interfaces + for interface in new_lag_member_interfaces: + nbclient.attach_interface_to_lag( device_name=new_side.router_fqdn, + lag_name=lag_interface.name, + iface_name=interface["interface_name"], description=str(subscription.subscription_id), - enabled=True, ) - # Attach physical interfaces to :term:`LAG` - # Reserve interfaces - for interface in new_lag_member_interfaces: - nbclient.attach_interface_to_lag( - device_name=new_side.router_fqdn, - lag_name=lag_interface.name, - iface_name=interface["interface_name"], - description=str(subscription.subscription_id), - ) - nbclient.reserve_interface( - device_name=new_side.router_fqdn, - iface_name=interface["interface_name"], - ) + nbclient.reserve_interface( + device_name=new_side.router_fqdn, + iface_name=interface["interface_name"], + ) return {"subscription": subscription} @@ -614,13 +614,14 @@ def migrate_iptrunk() -> StepList: TODO: add interface checks """ + new_side_is_nokia = conditional(lambda state: state["new_side_is_nokia"]) should_restore_isis_metric = conditional(lambda state: state["restore_isis_metric"]) return ( init >> store_process_subscription(Target.MODIFY) >> unsync - >> reserve_interfaces_in_netbox + >> new_side_is_nokia(reserve_interfaces_in_netbox) >> pp_interaction(set_isis_to_90000) >> pp_interaction(disable_old_config_dry) >> pp_interaction(disable_old_config_real)