Skip to content
Snippets Groups Projects
Verified Commit 7038fa1c authored by Neda Moeini's avatar Neda Moeini Committed by Karel van Klink
Browse files

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

parent 6958d950
Branches
Tags
No related merge requests found
Pipeline #88541 failed
...@@ -12,7 +12,7 @@ from pydantic_core.core_schema import ValidationInfo ...@@ -12,7 +12,7 @@ from pydantic_core.core_schema import ValidationInfo
from pydantic_forms.validators import Choice from pydantic_forms.validators import Choice
from gso import settings 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.router import RouterRole
from gso.products.product_blocks.site import LatitudeCoordinate, LongitudeCoordinate, SiteTier from gso.products.product_blocks.site import LatitudeCoordinate, LongitudeCoordinate, SiteTier
from gso.products.product_types.router import Router from gso.products.product_types.router import Router
...@@ -332,3 +332,18 @@ def generate_inventory_for_active_routers( ...@@ -332,3 +332,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 ( ...@@ -35,6 +35,7 @@ from gso.utils.helpers import (
LAGMember, LAGMember,
available_interfaces_choices, available_interfaces_choices,
available_lags_choices, available_lags_choices,
calculate_recommended_minimum_links,
get_router_vendor, get_router_vendor,
validate_interface_name_list, validate_interface_name_list,
validate_iptrunk_unique_interface, validate_iptrunk_unique_interface,
...@@ -70,12 +71,13 @@ def initial_input_form_generator(product_name: str) -> FormGenerator: ...@@ -70,12 +71,13 @@ def initial_input_form_generator(product_name: str) -> FormGenerator:
return validate_tt_number(tt_number) return validate_tt_number(tt_number)
initial_user_input = yield CreateIptrunkForm 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): class VerifyMinimumLinksForm(FormPage):
info_label: Label = ( info_label: Label = f"This is the calculated minimum-links for this LAG: {recommended_minimum_links}"
f"This is the calculated minimum-links for this LAG: " f"{initial_user_input.iptrunk_number_of_members - 1}" iptrunk_minimum_links: int = recommended_minimum_links
)
iptrunk_minimum_links: int = initial_user_input.iptrunk_number_of_members - 1
info_label2: Label = "Please confirm or modify." info_label2: Label = "Please confirm or modify."
verify_minimum_links = yield VerifyMinimumLinksForm verify_minimum_links = yield VerifyMinimumLinksForm
......
...@@ -28,6 +28,7 @@ from gso.utils.helpers import ( ...@@ -28,6 +28,7 @@ from gso.utils.helpers import (
LAGMember, LAGMember,
available_interfaces_choices, available_interfaces_choices,
available_interfaces_choices_including_current_members, available_interfaces_choices_including_current_members,
calculate_recommended_minimum_links,
get_router_vendor, get_router_vendor,
validate_interface_name_list, validate_interface_name_list,
validate_iptrunk_unique_interface, validate_iptrunk_unique_interface,
...@@ -108,12 +109,15 @@ def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator: ...@@ -108,12 +109,15 @@ def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator:
initial_user_input = yield ModifyIptrunkForm 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): class VerifyMinimumLinksForm(FormPage):
info_label: Label = ( info_label: Label = f"Current value of minimum-links : {subscription.iptrunk.iptrunk_minimum_links}"
f"This is the calculated minimum-links for this LAG: " f"{initial_user_input.iptrunk_number_of_members - 1}" info_label1: Label = f"Recommended minimum-links for this LAG: {recommended_minimum_links}"
) iptrunk_minimum_links: int = recommended_minimum_links
iptrunk_minimum_links: int = initial_user_input.iptrunk_number_of_members - 1 info_label2: Label = "Please review the recommended value and adjust if necessary."
info_label2: Label = "Please confirm or modify."
verify_minimum_links = yield VerifyMinimumLinksForm verify_minimum_links = yield VerifyMinimumLinksForm
ae_members_side_a = initialize_ae_members(subscription, initial_user_input.model_dump(), 0) 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