From f8638a9f1d8b8ca3aabc33814d8220466c58b705 Mon Sep 17 00:00:00 2001 From: Neda Moeini <neda.moeini@geant.org> Date: Wed, 9 Oct 2024 14:34:55 +0200 Subject: [PATCH] =?UTF-8?q?Improve=20Import=20G=C3=89ANT=20IP.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gso/workflows/geant_ip/create_geant_ip.py | 4 ++-- .../geant_ip/create_imported_geant_ip.py | 23 +++++++++---------- gso/workflows/geant_ip/import_geant_ip.py | 2 +- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/gso/workflows/geant_ip/create_geant_ip.py b/gso/workflows/geant_ip/create_geant_ip.py index 9e62accb..7c95268e 100644 --- a/gso/workflows/geant_ip/create_geant_ip.py +++ b/gso/workflows/geant_ip/create_geant_ip.py @@ -15,7 +15,7 @@ from pydantic_forms.validators import Divider from gso.products.product_blocks.bgp_session import BGPSession, IPFamily from gso.products.product_blocks.geant_ip import NRENAccessPortInactive -from gso.products.product_blocks.service_binding_port import VLAN_ID, ServiceBindingPort +from gso.products.product_blocks.service_binding_port import VLAN_ID, ServiceBindingPortInactive from gso.products.product_types.edge_port import EdgePort from gso.products.product_types.geant_ip import GeantIPInactive from gso.services.lso_client import LSOState, lso_interaction @@ -150,7 +150,7 @@ def initialize_subscription( BGPSession.new(subscription_id=uuid4(), **session, rtbh_enabled=True, is_multi_hop=True) for session in sbp_input["bgp_peers"] ] - service_binding_port = ServiceBindingPort.new( + service_binding_port = ServiceBindingPortInactive.new( subscription_id=uuid4(), **sbp_input, sbp_bgp_session_list=sbp_bgp_session_list, diff --git a/gso/workflows/geant_ip/create_imported_geant_ip.py b/gso/workflows/geant_ip/create_imported_geant_ip.py index dda9c3d9..fd2cb77c 100644 --- a/gso/workflows/geant_ip/create_imported_geant_ip.py +++ b/gso/workflows/geant_ip/create_imported_geant_ip.py @@ -14,7 +14,7 @@ from pydantic_forms.types import UUIDstr from gso.products import ProductName from gso.products.product_blocks.bgp_session import BGPSession, IPFamily from gso.products.product_blocks.geant_ip import NRENAccessPortInactive -from gso.products.product_blocks.service_binding_port import VLAN_ID, ServiceBindingPort +from gso.products.product_blocks.service_binding_port import VLAN_ID, ServiceBindingPortInactive from gso.products.product_types.edge_port import EdgePort from gso.products.product_types.geant_ip import ImportedGeantIPInactive from gso.services.partners import get_partner_by_name @@ -60,10 +60,7 @@ def initial_input_form_generator() -> FormGenerator: user_input = yield ImportGeantIPForm - return { - "partner": user_input.partner, - "initial_input": user_input.dict(), - } + return user_input.model_dump() @step("Create subscription") @@ -76,16 +73,18 @@ def create_subscription(partner: str) -> dict: @step("Initialize subscription") -def initialize_subscription(subscription: ImportedGeantIPInactive, initial_input: dict) -> dict: +def initialize_subscription(subscription: ImportedGeantIPInactive, service_binding_ports: list) -> dict: """Initialize the subscription with the user input.""" - for service_binding_port in initial_input["service_binding_ports"]: - edge_port_subscription = EdgePort.from_subscription(service_binding_port["edge_port"]) + for service_binding_port in service_binding_ports: + edge_port_subscription = EdgePort.from_subscription(service_binding_port.pop("edge_port")) + bgp_peers = service_binding_port.pop("bgp_peers") sbp_bgp_session_list = [ - BGPSession.new(subscription_id=uuid4(), **session) for session in service_binding_port["bgp_peers"] + BGPSession.new(subscription_id=uuid4(), **session) for session in bgp_peers ] - ServiceBindingPort.new( + + service_binding_port_subscription = ServiceBindingPortInactive.new( subscription_id=uuid4(), - edge_port=edge_port_subscription, + edge_port=edge_port_subscription.edge_port, sbp_bgp_session_list=sbp_bgp_session_list, **service_binding_port, ) @@ -93,7 +92,7 @@ def initialize_subscription(subscription: ImportedGeantIPInactive, initial_input NRENAccessPortInactive.new( subscription_id=uuid4(), nren_ap_type=service_binding_port["ap_type"], - geant_ip_sbp=service_binding_port, + geant_ip_sbp=service_binding_port_subscription, ) ) diff --git a/gso/workflows/geant_ip/import_geant_ip.py b/gso/workflows/geant_ip/import_geant_ip.py index 37be5a75..74fd2eb7 100644 --- a/gso/workflows/geant_ip/import_geant_ip.py +++ b/gso/workflows/geant_ip/import_geant_ip.py @@ -15,7 +15,7 @@ from gso.services.subscriptions import get_product_id_by_name def import_geant_ip_subscription(subscription_id: UUIDstr) -> State: """Take an ImportedGeantIP subscription, and turn it into an GeantIP subscription.""" old_geant_ip = ImportedGeantIP.from_subscription(subscription_id) - new_subscription_id = get_product_id_by_name(ProductName.IP_TRUNK) + new_subscription_id = get_product_id_by_name(ProductName.GEANT_IP) new_subscription = GeantIP.from_other_product(old_geant_ip, new_subscription_id) # type: ignore[arg-type] return {"subscription": new_subscription} -- GitLab