From cec2f82ec24b92dfe527d4c81c71e01a5590fc33 Mon Sep 17 00:00:00 2001 From: Karel van Klink <karel.vanklink@geant.org> Date: Mon, 7 Oct 2024 14:11:51 +0200 Subject: [PATCH] =?UTF-8?q?Update=20domain=20models=20for=20G=C3=89ANT=20I?= =?UTF-8?q?P=20and=20Edge=20Port?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...da39379a0_update_g\303\251ant_ip_model.py" | 29 ------------- ...e_g\303\251ant_ip_and_edge_port_models.py" | 41 +++++++++++++++++++ gso/products/product_blocks/edge_port.py | 10 ----- gso/products/product_blocks/geant_ip.py | 5 --- .../product_blocks/service_binding_port.py | 5 +++ 5 files changed, 46 insertions(+), 44 deletions(-) delete mode 100644 "gso/migrations/versions/2024-10-03_b3cda39379a0_update_g\303\251ant_ip_model.py" create mode 100644 "gso/migrations/versions/2024-10-07_6dd8a91b8ce0_update_g\303\251ant_ip_and_edge_port_models.py" diff --git "a/gso/migrations/versions/2024-10-03_b3cda39379a0_update_g\303\251ant_ip_model.py" "b/gso/migrations/versions/2024-10-03_b3cda39379a0_update_g\303\251ant_ip_model.py" deleted file mode 100644 index 4f4cbd6e..00000000 --- "a/gso/migrations/versions/2024-10-03_b3cda39379a0_update_g\303\251ant_ip_model.py" +++ /dev/null @@ -1,29 +0,0 @@ -"""Update GÉANT IP model. - -Revision ID: b3cda39379a0 -Revises: 289e5334848f -Create Date: 2024-10-03 15:47:51.942674 - -""" -import sqlalchemy as sa -from alembic import op - -# revision identifiers, used by Alembic. -revision = 'b3cda39379a0' -down_revision = '289e5334848f' -branch_labels = None -depends_on = None - - -def upgrade() -> None: - conn = op.get_bind() - conn.execute(sa.text(""" -INSERT INTO product_block_relations (in_use_by_id, depends_on_id) VALUES ((SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('NRENAccessPort')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('ServiceBindingPort'))) - """)) - - -def downgrade() -> None: - conn = op.get_bind() - conn.execute(sa.text(""" -DELETE FROM product_block_relations WHERE product_block_relations.in_use_by_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('NRENAccessPort')) AND product_block_relations.depends_on_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('ServiceBindingPort')) - """)) diff --git "a/gso/migrations/versions/2024-10-07_6dd8a91b8ce0_update_g\303\251ant_ip_and_edge_port_models.py" "b/gso/migrations/versions/2024-10-07_6dd8a91b8ce0_update_g\303\251ant_ip_and_edge_port_models.py" new file mode 100644 index 00000000..2e4d52a2 --- /dev/null +++ "b/gso/migrations/versions/2024-10-07_6dd8a91b8ce0_update_g\303\251ant_ip_and_edge_port_models.py" @@ -0,0 +1,41 @@ +"""Update GÉANT IP and Edge Port models. + +Revision ID: 6dd8a91b8ce0 +Revises: 289e5334848f +Create Date: 2024-10-07 14:11:14.041301 + +""" +import sqlalchemy as sa +from alembic import op + +# revision identifiers, used by Alembic. +revision = '6dd8a91b8ce0' +down_revision = '289e5334848f' +branch_labels = None +depends_on = None + + +def upgrade() -> None: + conn = op.get_bind() + conn.execute(sa.text(""" +DELETE FROM product_block_relations WHERE product_block_relations.in_use_by_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('EdgePortBlock')) AND product_block_relations.depends_on_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('ServiceBindingPort')) + """)) + conn.execute(sa.text(""" +DELETE FROM product_block_relations WHERE product_block_relations.in_use_by_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('NRENAccessPort')) AND product_block_relations.depends_on_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('EdgePortBlock')) + """)) + conn.execute(sa.text(""" +INSERT INTO product_block_relations (in_use_by_id, depends_on_id) VALUES ((SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('ServiceBindingPort')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('EdgePortBlock'))) + """)) + conn.execute(sa.text(""" +INSERT INTO product_block_relations (in_use_by_id, depends_on_id) VALUES ((SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('NRENAccessPort')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('ServiceBindingPort'))) + """)) + + +def downgrade() -> None: + conn = op.get_bind() + conn.execute(sa.text(""" +DELETE FROM product_block_relations WHERE product_block_relations.in_use_by_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('ServiceBindingPort')) AND product_block_relations.depends_on_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('EdgePortBlock')) + """)) + conn.execute(sa.text(""" +DELETE FROM product_block_relations WHERE product_block_relations.in_use_by_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('NRENAccessPort')) AND product_block_relations.depends_on_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('ServiceBindingPort')) + """)) diff --git a/gso/products/product_blocks/edge_port.py b/gso/products/product_blocks/edge_port.py index b77fd938..d8228a89 100644 --- a/gso/products/product_blocks/edge_port.py +++ b/gso/products/product_blocks/edge_port.py @@ -6,14 +6,8 @@ domain still managed by GEANT. In other words, an Edge port determines where the from orchestrator.domain.base import ProductBlockModel from orchestrator.types import SubscriptionLifecycle, strEnum -from pydantic import Field from gso.products.product_blocks.router import RouterBlock, RouterBlockInactive, RouterBlockProvisioning -from gso.products.product_blocks.service_binding_port import ( - ServiceBindingPort, - ServiceBindingPortInactive, - ServiceBindingPortProvisioning, -) from gso.utils.types.interfaces import LAGMemberList, PhysicalPortCapacity @@ -80,7 +74,6 @@ class EdgePortBlockInactive( edge_port_ignore_if_down: bool = False edge_port_geant_ga_id: str | None = None edge_port_ae_members: LAGMemberList[EdgePortAEMemberBlockInactive] - edge_port_sbp_list: list[ServiceBindingPortInactive] = Field(default_factory=list) class EdgePortBlockProvisioning(EdgePortBlockInactive, lifecycle=[SubscriptionLifecycle.PROVISIONING]): @@ -98,7 +91,6 @@ class EdgePortBlockProvisioning(EdgePortBlockInactive, lifecycle=[SubscriptionLi edge_port_ignore_if_down: bool = False edge_port_geant_ga_id: str | None = None edge_port_ae_members: LAGMemberList[EdgePortAEMemberBlockProvisioning] # type: ignore[assignment] - edge_port_sbp_list: list[ServiceBindingPortProvisioning] # type: ignore[assignment] class EdgePortBlock(EdgePortBlockProvisioning, lifecycle=[SubscriptionLifecycle.ACTIVE]): @@ -128,5 +120,3 @@ class EdgePortBlock(EdgePortBlockProvisioning, lifecycle=[SubscriptionLifecycle. edge_port_geant_ga_id: str | None = None #: A list of :term:`LAG` members associated with this edge port. edge_port_ae_members: LAGMemberList[EdgePortAEMemberBlock] # type: ignore[assignment] - #: A list of Service Binding Ports associated with this Edge Port - edge_port_sbp_list: list[ServiceBindingPort] # type: ignore[assignment] diff --git a/gso/products/product_blocks/geant_ip.py b/gso/products/product_blocks/geant_ip.py index c6f94179..89ee59fb 100644 --- a/gso/products/product_blocks/geant_ip.py +++ b/gso/products/product_blocks/geant_ip.py @@ -4,7 +4,6 @@ from orchestrator.domain.base import ProductBlockModel from orchestrator.types import SubscriptionLifecycle from pydantic import Field -from gso.products.product_blocks.edge_port import EdgePortBlock, EdgePortBlockInactive, EdgePortBlockProvisioning from gso.products.product_blocks.service_binding_port import ( ServiceBindingPort, ServiceBindingPortInactive, @@ -19,7 +18,6 @@ class NRENAccessPortInactive( """An access port for an R&E :term:`NREN` service that is inactive.""" nren_ap_type: APType | None = None - geant_ip_ep: EdgePortBlockInactive geant_ip_sbp: ServiceBindingPortInactive @@ -27,7 +25,6 @@ class NRENAccessPortProvisioning(NRENAccessPortInactive, lifecycle=[Subscription """An access port for an R&E :term:`NREN` service that is being provisioned.""" nren_ap_type: APType - geant_ip_ep: EdgePortBlockProvisioning geant_ip_sbp: ServiceBindingPortProvisioning @@ -36,8 +33,6 @@ class NRENAccessPort(NRENAccessPortProvisioning, lifecycle=[SubscriptionLifecycl #: The type of Access Port nren_ap_type: APType - #: The Edge Port where this :term:`NREN` Access Port terminates. - geant_ip_ep: EdgePortBlock #: The corresponding :term:`SBP` of this Access Port. geant_ip_sbp: ServiceBindingPort diff --git a/gso/products/product_blocks/service_binding_port.py b/gso/products/product_blocks/service_binding_port.py index 1f031e52..44423f04 100644 --- a/gso/products/product_blocks/service_binding_port.py +++ b/gso/products/product_blocks/service_binding_port.py @@ -10,6 +10,7 @@ from orchestrator.types import SubscriptionLifecycle from pydantic import Field from gso.products.product_blocks.bgp_session import BGPSession, BGPSessionInactive, BGPSessionProvisioning +from gso.products.product_blocks.edge_port import EdgePortBlock, EdgePortBlockInactive, EdgePortBlockProvisioning from gso.utils.shared_enums import SBPType from gso.utils.types.ip_address import IPv4AddressType, IPv6AddressType @@ -29,6 +30,7 @@ class ServiceBindingPortInactive( custom_firewall_filters: bool | None = None geant_sid: str | None = None sbp_bgp_session_list: list[BGPSessionInactive] = Field(default_factory=list) + edge_port: EdgePortBlockInactive | None = None class ServiceBindingPortProvisioning(ServiceBindingPortInactive, lifecycle=[SubscriptionLifecycle.PROVISIONING]): @@ -42,6 +44,7 @@ class ServiceBindingPortProvisioning(ServiceBindingPortInactive, lifecycle=[Subs custom_firewall_filters: bool geant_sid: str sbp_bgp_session_list: list[BGPSessionProvisioning] # type: ignore[assignment] + edge_port: EdgePortBlockProvisioning # type: ignore[assignment] class ServiceBindingPort(ServiceBindingPortProvisioning, lifecycle=[SubscriptionLifecycle.ACTIVE]): @@ -63,3 +66,5 @@ class ServiceBindingPort(ServiceBindingPortProvisioning, lifecycle=[Subscription geant_sid: str #: The :term:`BGP` sessions associated with this service binding port. sbp_bgp_session_list: list[BGPSession] # type: ignore[assignment] + #: The Edge Port on which this :term:`SBP` resides. + edge_port: EdgePortBlock # type: ignore[assignment] -- GitLab