Skip to content
Snippets Groups Projects

Add Edge Port, GÉANT IP and IAS products

Merged Karel van Klink requested to merge feature/add-geant-ip into develop
All threads resolved!
2 files
+ 7
10
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 6
9
@@ -4,6 +4,7 @@ import re
from typing import TYPE_CHECKING
from uuid import UUID
from pydantic_forms.types import UUIDstr
from pydantic_forms.validators import Choice
from gso import settings
@@ -11,7 +12,7 @@ from gso.products.product_blocks.router import RouterRole
from gso.products.product_types.router import Router
from gso.services import subscriptions
from gso.services.netbox_client import NetboxClient
from gso.services.partners import get_all_partners, get_partner_by_name
from gso.services.partners import get_all_partners
from gso.utils.shared_enums import Vendor
from gso.utils.types.interfaces import PhysicalPortCapacity
from gso.utils.types.ip_address import IPv4AddressType
@@ -210,20 +211,16 @@ def active_switch_selector() -> Choice:
return Choice("Select a switch", zip(switch_subscriptions.keys(), switch_subscriptions.items(), strict=True)) # type: ignore[arg-type]
def active_edge_port_selector(*, geant_only: bool | None = None) -> Choice:
def active_edge_port_selector(*, partner_id: UUIDstr | None = None) -> Choice:
"""Generate a dropdown selector for choosing an active Edge Port in an input form."""
edge_port_subscriptions = subscriptions.get_active_edge_port_subscriptions(
includes=["subscription_id", "description", "customer_id"]
)
if geant_only is not None:
# ``geant_only`` is set, so we will filter accordingly.
geant_partner_id = get_partner_by_name("GEANT")["partner_id"]
if partner_id:
# ``partner_id`` is set, so we will filter accordingly.
edge_port_subscriptions = list(
filter(
lambda subscription: geant_only ^ bool(subscription["customer_id"] != geant_partner_id),
edge_port_subscriptions,
)
filter(lambda subscription: bool(subscription["customer_id"] == partner_id), edge_port_subscriptions)
)
edge_ports = {str(port["subscription_id"]): port["description"] for port in edge_port_subscriptions}
Loading