Skip to content
Snippets Groups Projects
Verified Commit a34051ad authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

use a conditional to skip a step in migrate_iptrunk

parent 6191d0fe
No related branches found
No related tags found
1 merge request!128Feature/use conditionals
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment