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

Implement feedback for GÉANT IP input form

parent d4056c6a
No related branches found
Tags 2.27
1 merge request!286Add Edge Port, GÉANT IP and IAS products
......@@ -25,7 +25,7 @@ from gso.utils.helpers import (
partner_choice,
)
from gso.utils.shared_enums import APType, SBPType
from gso.utils.types.ip_address import IPv4AddressType, IPv6AddressType
from gso.utils.types.ip_address import IPAddress, IPv4AddressType, IPv6AddressType
from gso.utils.types.tt_number import TTNumber
......@@ -44,14 +44,19 @@ def initial_input_form_generator(product_name: str) -> FormGenerator:
edge_port: active_edge_port_selector(partner_id=initial_user_input.partner) # type: ignore[valid-type]
ap_type: APType
def __hash__(self) -> int:
return self.edge_port.__hash__()
def validate_edge_ports_are_unique(edge_ports: list[EdgePortSelection]) -> list[EdgePortSelection]:
"""Verify if interfaces are unique."""
port_names = [port.edge_port for port in edge_ports]
if len(port_names) != len(set(port_names)):
msg = "Edge Ports must be unique."
raise ValueError(msg)
return edge_ports
class EdgePortSelectionForm(FormPage):
model_config = ConfigDict(title=f"{product_name} - Select Edge Ports")
info_label: Label = "Please select the Edge Ports where this GÉANT IP service will terminate"
edge_ports: Annotated[list[EdgePortSelection], AfterValidator(validate_unique_list)]
edge_ports: Annotated[list[EdgePortSelection], AfterValidator(validate_edge_ports_are_unique)]
selected_edge_ports = yield EdgePortSelectionForm
ep_list = selected_edge_ports.edge_ports
......@@ -60,21 +65,23 @@ def initial_input_form_generator(product_name: str) -> FormGenerator:
binding_port_inputs = []
while current_ep_index < total_ep_count:
current_edge_port_description = EdgePort.from_subscription(ep_list[current_ep_index].edge_port).description
current_edge_port = EdgePort.from_subscription(ep_list[current_ep_index].edge_port)
class BindingPortsInputForm(FormPage):
model_config = ConfigDict(
title=f"{product_name} - Configure Service Binding Ports ({current_ep_index + 1}/{total_ep_count})"
)
info_label: Label = "Please configure the Service Binding Ports for each Edge Port."
current_ep_label: Label = f"Currently configuring on {current_edge_port_description}"
current_ep_label: Label = (
f"Currently configuring on {current_edge_port.description} "
f"(Access Port type: {ep_list[current_ep_index].ap_type})"
)
geant_sid: str
is_tagged: bool = False
sbp_type: SBPType
vlan_id: VLAN_ID | None
ipv4_address: IPv4AddressType | None = None
ipv6_address: IPv6AddressType | None = None
vlan_id: VLAN_ID
ipv4_address: IPv4AddressType
ipv6_address: IPv6AddressType
custom_firewall_filters: bool = False
divider: Divider
bgp_peer_count: PositiveInt = 1
......@@ -90,11 +97,11 @@ def initial_input_form_generator(product_name: str) -> FormGenerator:
class BGPPeerForm(FormPage):
model_config = ConfigDict(
title=(
f"Configure BGP peers for {current_edge_port_description} - "
f"Configure BGP peers for {current_edge_port.description} - "
f"({bgp_peer_index + 1}/{binding_port_input_form.bgp_peer_count})"
)
)
peer_address: IPv4AddressType | IPv6AddressType
peer_address: IPAddress
bfd_enabled: bool = False
bfd_interval: int | None = None
bfd_multiplier: int | None = None
......@@ -109,6 +116,7 @@ def initial_input_form_generator(product_name: str) -> FormGenerator:
bgp_peers.append(bgp_peer_input_form.model_dump())
binding_port_input["bgp_peers"] = bgp_peers
binding_port_input["sbp_type"] = SBPType.L3
binding_port_inputs.append(binding_port_input)
current_ep_index += 1
......
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