Skip to content
Snippets Groups Projects
Commit 797cbc33 authored by Neda Moeini's avatar Neda Moeini
Browse files

Introduce new rules for calculating recommended minimum links. #NAT-749

parent af669244
No related branches found
No related tags found
1 merge request!256Fix the error on showing number of members in modify trunk interface workflow.
Pipeline #88445 passed
This commit is part of merge request !256. Comments created here will be created in the context of that merge request.
......@@ -12,7 +12,7 @@ from pydantic_core.core_schema import ValidationInfo
from pydantic_forms.validators import Choice
from gso import settings
from gso.products.product_blocks.iptrunk import IptrunkInterfaceBlock
from gso.products.product_blocks.iptrunk import IptrunkInterfaceBlock, PhysicalPortCapacity
from gso.products.product_blocks.router import RouterRole
from gso.products.product_blocks.site import LatitudeCoordinate, LongitudeCoordinate, SiteTier
from gso.products.product_types.router import Router
......@@ -336,3 +336,18 @@ def generate_inventory_for_active_routers(
}
}
}
def calculate_recommended_minimum_links(iptrunk_number_of_members: int, iptrunk_speed: PhysicalPortCapacity) -> int:
"""Calculate the recommended minimum number of links for an IP trunk based on the number of members and speed.
If the IP trunk speed is 400G, the recommended minimum number of links is the number of members minus 1.
Otherwise, the recommended minimum number of links is the number of members.
:param int iptrunk_number_of_members: The number of members in the IP trunk.
:param PhysicalPortCapacity iptrunk_speed: The speed of the IP trunk.
:return: The recommended minimum number of links for the IP trunk.
"""
if iptrunk_speed == PhysicalPortCapacity.FOUR_HUNDRED_GIGABIT_PER_SECOND:
return iptrunk_number_of_members - 1
return iptrunk_number_of_members
......@@ -35,6 +35,7 @@ from gso.utils.helpers import (
LAGMember,
available_interfaces_choices,
available_lags_choices,
calculate_recommended_minimum_links,
get_router_vendor,
validate_interface_name_list,
validate_iptrunk_unique_interface,
......@@ -66,12 +67,13 @@ def initial_input_form_generator(product_name: str) -> FormGenerator:
iptrunk_number_of_members: int
initial_user_input = yield CreateIptrunkForm
recommended_minimum_links = calculate_recommended_minimum_links(
initial_user_input.iptrunk_number_of_members, initial_user_input.iptrunk_speed
)
class VerifyMinimumLinksForm(FormPage):
info_label: Label = (
f"This is the calculated minimum-links for this LAG: " f"{initial_user_input.iptrunk_number_of_members - 1}"
)
iptrunk_minimum_links: int = initial_user_input.iptrunk_number_of_members - 1
info_label: Label = f"This is the calculated minimum-links for this LAG: {recommended_minimum_links}"
iptrunk_minimum_links: int = recommended_minimum_links
info_label2: Label = "Please confirm or modify."
verify_minimum_links = yield VerifyMinimumLinksForm
......
......@@ -28,6 +28,7 @@ from gso.utils.helpers import (
LAGMember,
available_interfaces_choices,
available_interfaces_choices_including_current_members,
calculate_recommended_minimum_links,
get_router_vendor,
validate_interface_name_list,
validate_iptrunk_unique_interface,
......@@ -104,12 +105,15 @@ def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator:
initial_user_input = yield ModifyIptrunkForm
recommended_minimum_links = calculate_recommended_minimum_links(
initial_user_input.iptrunk_number_of_members, initial_user_input.iptrunk_speed
)
class VerifyMinimumLinksForm(FormPage):
info_label: Label = (
f"This is the calculated minimum-links for this LAG: " f"{initial_user_input.iptrunk_number_of_members - 1}"
)
iptrunk_minimum_links: int = initial_user_input.iptrunk_number_of_members - 1
info_label2: Label = "Please confirm or modify."
info_label: Label = f"Current value of minimum-links : {subscription.iptrunk.iptrunk_minimum_links}"
info_label1: Label = f"Recommended minimum-links for this LAG: {recommended_minimum_links}"
iptrunk_minimum_links: int = recommended_minimum_links
info_label2: Label = "Please review the recommended value and adjust if necessary."
verify_minimum_links = yield VerifyMinimumLinksForm
ae_members_side_a = initialize_ae_members(subscription, initial_user_input.model_dump(), 0)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment