From e9dadc8d62b1d8d1f48d8c69fe701af8080cbe7c Mon Sep 17 00:00:00 2001
From: Aleksandr Kurbatov <ak@geant.org>
Date: Tue, 26 Nov 2024 15:22:17 +0000
Subject: [PATCH] rework of the parms order on the form

---
 .../create_nren_l3_core_service.py            | 42 ++++++++++++-------
 .../modify_nren_l3_core_service.py            | 20 +++++----
 2 files changed, 40 insertions(+), 22 deletions(-)

diff --git a/gso/workflows/nren_l3_core_service/create_nren_l3_core_service.py b/gso/workflows/nren_l3_core_service/create_nren_l3_core_service.py
index 16380b6c..d8e537bd 100644
--- a/gso/workflows/nren_l3_core_service/create_nren_l3_core_service.py
+++ b/gso/workflows/nren_l3_core_service/create_nren_l3_core_service.py
@@ -57,32 +57,40 @@ def initial_input_form_generator(product_name: str) -> FormGenerator:
 
     class BFDSettingsForm(BaseModel):
         bfd_enabled: bool = False
-        bfd_interval_rx: int | None = None
+        bfd_interval_rx: int | None = Field(default=None, examples=["BFD RX defaults"])
         bfd_interval_tx: int | None = None
         bfd_multiplier: int | None = None
 
-    class BaseBGPPeer(BaseModel):
-        bfd_enabled: bool = False
-        has_custom_policies: bool = False
+    class IPv4BGPPeer(BaseModel):
+        peer_address: IPv4AddressType
         authentication_key: str | None = None
+        has_custom_policies: bool = False
+        bfd_enabled: bool = False
         multipath_enabled: bool = False
-        send_default_route: bool = False
         is_passive: bool = False
-
-    class IPv4BGPPeer(BaseBGPPeer):
-        peer_address: IPv4AddressType
         add_v4_multicast: bool = Field(default=False, exclude=True)
-        ip_type: IPTypes = IPTypes.IPV4
+        send_default_route: bool = False
 
         @computed_field  # type: ignore[misc]
         @property
         def families(self) -> list[IPFamily]:
             return [IPFamily.V4UNICAST, IPFamily.V4MULTICAST] if self.add_v4_multicast else [IPFamily.V4UNICAST]
 
-    class IPv6BGPPeer(BaseBGPPeer):
+        @computed_field  # type: ignore[misc]
+        @property
+        def ip_type(self) -> IPTypes:
+            return IPTypes.IPV4
+
+    class IPv6BGPPeer(BaseModel):
+        ip_type: IPTypes = IPTypes.IPV6
         peer_address: IPv6AddressType
+        authentication_key: str | None = None
+        has_custom_policies: bool = False
+        bfd_enabled: bool = False
+        multipath_enabled: bool = False
+        is_passive: bool = False
         add_v6_multicast: bool = Field(default=False, exclude=True)
-        ip_type: IPTypes = IPTypes.IPV6
+        send_default_route: bool = False
 
         @computed_field  # type: ignore[misc]
         @property
@@ -100,15 +108,19 @@ def initial_input_form_generator(product_name: str) -> FormGenerator:
 
         geant_sid: str
         is_tagged: bool = False
-        v4_bfd_settings: BFDSettingsForm = BFDSettingsForm(bfd_enabled=False)
-        v6_bfd_settings: BFDSettingsForm = BFDSettingsForm(bfd_enabled=False)
         vlan_id: VLAN_ID
+        custom_firewall_filters: bool = False
+        divider: Divider = Field(None, exclude=True)
+        v4_label: Label = Field("IPV4 SBP interface params", exclude=True)
         ipv4_address: IPv4AddressType
         ipv4_mask: IPV4Netmask
+        v4_bfd_settings: BFDSettingsForm = BFDSettingsForm(bfd_enabled=False)
+        divider2: Divider = Field(None, exclude=True)
+        v6_label: Label = Field("IPV6 SBP interface params", exclude=True)
         ipv6_address: IPv6AddressType
         ipv6_mask: IPV6Netmask
-        custom_firewall_filters: bool = False
-        divider: Divider = Field(None, exclude=True)
+        v6_bfd_settings: BFDSettingsForm = BFDSettingsForm(bfd_enabled=False)
+        divider3: Divider = Field(None, exclude=True)
         v4_bgp_peer: IPv4BGPPeer
         v6_bgp_peer: IPv6BGPPeer
 
diff --git a/gso/workflows/nren_l3_core_service/modify_nren_l3_core_service.py b/gso/workflows/nren_l3_core_service/modify_nren_l3_core_service.py
index c5ddd8ab..e99a994e 100644
--- a/gso/workflows/nren_l3_core_service/modify_nren_l3_core_service.py
+++ b/gso/workflows/nren_l3_core_service/modify_nren_l3_core_service.py
@@ -65,7 +65,11 @@ def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator:
         bfd_interval_tx: int | None = None
         bfd_multiplier: int | None = None
 
-    class BaseBGPPeer(BaseModel):
+    class IPv4BGPPeer(BaseModel):
+        peer_address: IPv4AddressType
+        add_v4_multicast: bool = Field(default=False, exclude=True)
+        ip_type: IPTypes = IPTypes.IPV4
+
         bfd_enabled: bool = False
         has_custom_policies: bool = False
         authentication_key: str | None
@@ -73,21 +77,23 @@ def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator:
         send_default_route: bool = False
         is_passive: bool = False
 
-    class IPv4BGPPeer(BaseBGPPeer):
-        peer_address: IPv4AddressType
-        add_v4_multicast: bool = Field(default=False, exclude=True)
-        ip_type: IPTypes = IPTypes.IPV4
-
         @computed_field  # type: ignore[misc]
         @property
         def families(self) -> list[IPFamily]:
             return [IPFamily.V4UNICAST, IPFamily.V4MULTICAST] if self.add_v4_multicast else [IPFamily.V4UNICAST]
 
-    class IPv6BGPPeer(BaseBGPPeer):
+    class IPv6BGPPeer(BaseModel):
         peer_address: IPv6AddressType
         add_v6_multicast: bool = Field(default=False, exclude=True)
         ip_type: IPTypes = IPTypes.IPV6
 
+        bfd_enabled: bool = False
+        has_custom_policies: bool = False
+        authentication_key: str | None
+        multipath_enabled: bool = False
+        send_default_route: bool = False
+        is_passive: bool = False
+
         @computed_field  # type: ignore[misc]
         @property
         def families(self) -> list[IPFamily]:
-- 
GitLab