From 5503c2b66fe0c59caa46668679c9dca0d76c2824 Mon Sep 17 00:00:00 2001 From: Simone Spinelli <simone.spinelli@geant.org> Date: Fri, 28 Apr 2023 19:10:08 +0000 Subject: [PATCH] IPtrunk model works - but I need to add device block --- ...04-28_6b8483b46d06_add_iptrunk_product.py} | 78 ++++++++++++++----- ...d21cb2b05_add_iptrunk_create_workflows.py} | 10 +-- gso/products/product_blocks/iptrunk.py | 13 +++- gso/products/product_types/iptrunk.py | 2 + gso/workflows/iptrunk/create_iptrunk.py | 37 +++++---- 5 files changed, 99 insertions(+), 41 deletions(-) rename gso/migrations/versions/{2023-04-24_e13448650548_add_iptrunk_product.py => 2023-04-28_6b8483b46d06_add_iptrunk_product.py} (76%) rename gso/migrations/versions/{2023-04-24_37a3dcdcb110_add_iptrunk_create_workflows.py => 2023-04-28_95cd21cb2b05_add_iptrunk_create_workflows.py} (82%) diff --git a/gso/migrations/versions/2023-04-24_e13448650548_add_iptrunk_product.py b/gso/migrations/versions/2023-04-28_6b8483b46d06_add_iptrunk_product.py similarity index 76% rename from gso/migrations/versions/2023-04-24_e13448650548_add_iptrunk_product.py rename to gso/migrations/versions/2023-04-28_6b8483b46d06_add_iptrunk_product.py index a14cb52d..6770a04a 100644 --- a/gso/migrations/versions/2023-04-24_e13448650548_add_iptrunk_product.py +++ b/gso/migrations/versions/2023-04-28_6b8483b46d06_add_iptrunk_product.py @@ -1,15 +1,15 @@ """Add Iptrunk product. -Revision ID: e13448650548 +Revision ID: 6b8483b46d06 Revises: 857225661207 -Create Date: 2023-04-24 13:16:38.724103 +Create Date: 2023-04-28 12:35:22.996576 """ import sqlalchemy as sa from alembic import op # revision identifiers, used by Alembic. -revision = 'e13448650548' +revision = '6b8483b46d06' down_revision = '857225661207' branch_labels = None depends_on = None @@ -18,52 +18,61 @@ depends_on = None def upgrade() -> None: conn = op.get_bind() conn.execute(""" -INSERT INTO products (name, description, product_type, tag, status) VALUES ('Iptrunk', 'A core link', 'Iptrunk', 'IPTRUNK', 'active') RETURNING products.product_id +INSERT INTO products (name, description, product_type, tag, status) VALUES ('Iptrunk', 'An IPtrunk (product)', 'Iptrunk', 'IPTRUNK', 'active') RETURNING products.product_id """) conn.execute(""" -INSERT INTO product_blocks (name, description, tag, status) VALUES ('IptrunkBlock', 'IP trunk block', 'IPTRUNK', 'active') RETURNING product_blocks.product_block_id +INSERT INTO product_blocks (name, description, tag, status) VALUES ('IptrunkBlock', 'An IPtrunk (productBlock)', 'IPTRUNK', 'active') RETURNING product_blocks.product_block_id """) conn.execute(""" -INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_sideB_fqdn', 'FQDN side B') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_sideB_ae_iface', 'B-side: LAG interface name') RETURNING resource_types.resource_type_id """) conn.execute(""" -INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_speed', 'Speed of trunk members') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_ipv4_network', 'Global: IPv4 network') RETURNING resource_types.resource_type_id """) conn.execute(""" -INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_sideB_ae_iface', 'AE side B') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_sideA_ae_members', 'A-side: LAG members') RETURNING resource_types.resource_type_id """) conn.execute(""" -INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_sideB_ae_geant_a_sid', 'GA-SID side B') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_sideA_ae_iface', 'A-side: LAG interface name') RETURNING resource_types.resource_type_id """) conn.execute(""" -INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_type', 'leased vs darkfiber') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_sideB_ae_members', 'B-side: LAG members') RETURNING resource_types.resource_type_id """) conn.execute(""" -INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_sideA_ae_geant_a_sid', 'GA-SID side A') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_sideA_ae_geant_a_sid', 'A-side: GA identifier for the LAG') RETURNING resource_types.resource_type_id """) conn.execute(""" -INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_ipv4_network', 'IPv4 network for the trunk') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('geant_s_sid', 'Global: Service ID for the trunk') RETURNING resource_types.resource_type_id """) conn.execute(""" -INSERT INTO resource_types (resource_type, description) VALUES ('geant_s_sid', 'GS SID for trunk') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_description', 'Global: LAG human interface description') RETURNING resource_types.resource_type_id """) conn.execute(""" -INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_ipv6_network', 'IPv6 network for the trunk') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_sideA_fqdn', 'A-side: router FQDN') RETURNING resource_types.resource_type_id """) conn.execute(""" -INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_sideA_ae_iface', 'AE side A') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_sideB_ae_geant_a_sid', 'B-side: GA identifier for the LAG') RETURNING resource_types.resource_type_id """) conn.execute(""" -INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_sideA_fqdn', 'FQDN side A') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_speed', 'Global: LAG''s members speed') RETURNING resource_types.resource_type_id """) conn.execute(""" -INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_minimum_links', 'minimum links') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_ipv6_network', 'Global: IPv6 network') RETURNING resource_types.resource_type_id """) conn.execute(""" -INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_sideB_ae_members', 'side B members') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_minimum_links', 'Global: minimum links for the LAG') RETURNING resource_types.resource_type_id """) conn.execute(""" -INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_sideA_ae_members', 'side A members') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_sideB_fqdn', 'B-side: router FQDN') RETURNING resource_types.resource_type_id + """) + conn.execute(""" +INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_sideB_ae_members_description', 'B-side: human interface description for LAG''s members') RETURNING resource_types.resource_type_id + """) + conn.execute(""" +INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_sideA_ae_members_description', 'A-side: human interface description for LAG''s members') RETURNING resource_types.resource_type_id + """) + conn.execute(""" +INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_type', 'Global: dark fiber vs leased lines') RETURNING resource_types.resource_type_id """) conn.execute(""" INSERT INTO product_product_blocks (product_id, product_block_id) VALUES ((SELECT products.product_id FROM products WHERE products.name IN ('Iptrunk')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('IptrunkBlock'))) @@ -72,6 +81,9 @@ INSERT INTO product_product_blocks (product_id, product_block_id) VALUES ((SELEC INSERT INTO product_block_resource_types (product_block_id, resource_type_id) VALUES ((SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('IptrunkBlock')), (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('geant_s_sid'))) """) conn.execute(""" +INSERT INTO product_block_resource_types (product_block_id, resource_type_id) VALUES ((SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('IptrunkBlock')), (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('iptrunk_description'))) + """) + conn.execute(""" INSERT INTO product_block_resource_types (product_block_id, resource_type_id) VALUES ((SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('IptrunkBlock')), (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('iptrunk_type'))) """) conn.execute(""" @@ -99,6 +111,9 @@ INSERT INTO product_block_resource_types (product_block_id, resource_type_id) VA INSERT INTO product_block_resource_types (product_block_id, resource_type_id) VALUES ((SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('IptrunkBlock')), (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('iptrunk_sideA_ae_members'))) """) conn.execute(""" +INSERT INTO product_block_resource_types (product_block_id, resource_type_id) VALUES ((SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('IptrunkBlock')), (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('iptrunk_sideA_ae_members_description'))) + """) + conn.execute(""" INSERT INTO product_block_resource_types (product_block_id, resource_type_id) VALUES ((SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('IptrunkBlock')), (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('iptrunk_sideB_fqdn'))) """) conn.execute(""" @@ -110,6 +125,9 @@ INSERT INTO product_block_resource_types (product_block_id, resource_type_id) VA conn.execute(""" INSERT INTO product_block_resource_types (product_block_id, resource_type_id) VALUES ((SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('IptrunkBlock')), (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('iptrunk_sideB_ae_members'))) """) + conn.execute(""" +INSERT INTO product_block_resource_types (product_block_id, resource_type_id) VALUES ((SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('IptrunkBlock')), (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('iptrunk_sideB_ae_members_description'))) + """) def downgrade() -> None: @@ -121,6 +139,12 @@ DELETE FROM product_block_resource_types WHERE product_block_resource_types.prod DELETE FROM subscription_instance_values USING product_block_resource_types WHERE subscription_instance_values.subscription_instance_id IN (SELECT subscription_instances.subscription_instance_id FROM subscription_instances WHERE subscription_instances.subscription_instance_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('IptrunkBlock'))) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('geant_s_sid')) """) conn.execute(""" +DELETE FROM product_block_resource_types WHERE product_block_resource_types.product_block_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('IptrunkBlock')) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('iptrunk_description')) + """) + conn.execute(""" +DELETE FROM subscription_instance_values USING product_block_resource_types WHERE subscription_instance_values.subscription_instance_id IN (SELECT subscription_instances.subscription_instance_id FROM subscription_instances WHERE subscription_instances.subscription_instance_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('IptrunkBlock'))) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('iptrunk_description')) + """) + conn.execute(""" DELETE FROM product_block_resource_types WHERE product_block_resource_types.product_block_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('IptrunkBlock')) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('iptrunk_type')) """) conn.execute(""" @@ -175,6 +199,12 @@ DELETE FROM product_block_resource_types WHERE product_block_resource_types.prod DELETE FROM subscription_instance_values USING product_block_resource_types WHERE subscription_instance_values.subscription_instance_id IN (SELECT subscription_instances.subscription_instance_id FROM subscription_instances WHERE subscription_instances.subscription_instance_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('IptrunkBlock'))) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('iptrunk_sideA_ae_members')) """) conn.execute(""" +DELETE FROM product_block_resource_types WHERE product_block_resource_types.product_block_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('IptrunkBlock')) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('iptrunk_sideA_ae_members_description')) + """) + conn.execute(""" +DELETE FROM subscription_instance_values USING product_block_resource_types WHERE subscription_instance_values.subscription_instance_id IN (SELECT subscription_instances.subscription_instance_id FROM subscription_instances WHERE subscription_instances.subscription_instance_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('IptrunkBlock'))) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('iptrunk_sideA_ae_members_description')) + """) + conn.execute(""" DELETE FROM product_block_resource_types WHERE product_block_resource_types.product_block_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('IptrunkBlock')) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('iptrunk_sideB_fqdn')) """) conn.execute(""" @@ -199,10 +229,16 @@ DELETE FROM product_block_resource_types WHERE product_block_resource_types.prod DELETE FROM subscription_instance_values USING product_block_resource_types WHERE subscription_instance_values.subscription_instance_id IN (SELECT subscription_instances.subscription_instance_id FROM subscription_instances WHERE subscription_instances.subscription_instance_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('IptrunkBlock'))) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('iptrunk_sideB_ae_members')) """) conn.execute(""" -DELETE FROM subscription_instance_values WHERE subscription_instance_values.resource_type_id IN (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('iptrunk_sideB_fqdn', 'iptrunk_speed', 'iptrunk_sideB_ae_iface', 'iptrunk_sideB_ae_geant_a_sid', 'iptrunk_type', 'iptrunk_sideA_ae_geant_a_sid', 'iptrunk_ipv4_network', 'geant_s_sid', 'iptrunk_ipv6_network', 'iptrunk_sideA_ae_iface', 'iptrunk_sideA_fqdn', 'iptrunk_minimum_links', 'iptrunk_sideB_ae_members', 'iptrunk_sideA_ae_members')) +DELETE FROM product_block_resource_types WHERE product_block_resource_types.product_block_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('IptrunkBlock')) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('iptrunk_sideB_ae_members_description')) + """) + conn.execute(""" +DELETE FROM subscription_instance_values USING product_block_resource_types WHERE subscription_instance_values.subscription_instance_id IN (SELECT subscription_instances.subscription_instance_id FROM subscription_instances WHERE subscription_instances.subscription_instance_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('IptrunkBlock'))) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('iptrunk_sideB_ae_members_description')) + """) + conn.execute(""" +DELETE FROM subscription_instance_values WHERE subscription_instance_values.resource_type_id IN (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('iptrunk_sideB_ae_iface', 'iptrunk_ipv4_network', 'iptrunk_sideA_ae_members', 'iptrunk_sideA_ae_iface', 'iptrunk_sideB_ae_members', 'iptrunk_sideA_ae_geant_a_sid', 'geant_s_sid', 'iptrunk_description', 'iptrunk_sideA_fqdn', 'iptrunk_sideB_ae_geant_a_sid', 'iptrunk_speed', 'iptrunk_ipv6_network', 'iptrunk_minimum_links', 'iptrunk_sideB_fqdn', 'iptrunk_sideB_ae_members_description', 'iptrunk_sideA_ae_members_description', 'iptrunk_type')) """) conn.execute(""" -DELETE FROM resource_types WHERE resource_types.resource_type IN ('iptrunk_sideB_fqdn', 'iptrunk_speed', 'iptrunk_sideB_ae_iface', 'iptrunk_sideB_ae_geant_a_sid', 'iptrunk_type', 'iptrunk_sideA_ae_geant_a_sid', 'iptrunk_ipv4_network', 'geant_s_sid', 'iptrunk_ipv6_network', 'iptrunk_sideA_ae_iface', 'iptrunk_sideA_fqdn', 'iptrunk_minimum_links', 'iptrunk_sideB_ae_members', 'iptrunk_sideA_ae_members') +DELETE FROM resource_types WHERE resource_types.resource_type IN ('iptrunk_sideB_ae_iface', 'iptrunk_ipv4_network', 'iptrunk_sideA_ae_members', 'iptrunk_sideA_ae_iface', 'iptrunk_sideB_ae_members', 'iptrunk_sideA_ae_geant_a_sid', 'geant_s_sid', 'iptrunk_description', 'iptrunk_sideA_fqdn', 'iptrunk_sideB_ae_geant_a_sid', 'iptrunk_speed', 'iptrunk_ipv6_network', 'iptrunk_minimum_links', 'iptrunk_sideB_fqdn', 'iptrunk_sideB_ae_members_description', 'iptrunk_sideA_ae_members_description', 'iptrunk_type') """) conn.execute(""" DELETE FROM product_product_blocks WHERE product_product_blocks.product_id IN (SELECT products.product_id FROM products WHERE products.name IN ('Iptrunk')) AND product_product_blocks.product_block_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('IptrunkBlock')) diff --git a/gso/migrations/versions/2023-04-24_37a3dcdcb110_add_iptrunk_create_workflows.py b/gso/migrations/versions/2023-04-28_95cd21cb2b05_add_iptrunk_create_workflows.py similarity index 82% rename from gso/migrations/versions/2023-04-24_37a3dcdcb110_add_iptrunk_create_workflows.py rename to gso/migrations/versions/2023-04-28_95cd21cb2b05_add_iptrunk_create_workflows.py index 681eb89d..8b007e17 100644 --- a/gso/migrations/versions/2023-04-24_37a3dcdcb110_add_iptrunk_create_workflows.py +++ b/gso/migrations/versions/2023-04-28_95cd21cb2b05_add_iptrunk_create_workflows.py @@ -1,16 +1,16 @@ """add IPtrunk create workflows. -Revision ID: 37a3dcdcb110 -Revises: e13448650548 -Create Date: 2023-04-24 13:19:58.545357 +Revision ID: 95cd21cb2b05 +Revises: 6b8483b46d06 +Create Date: 2023-04-28 12:37:36.801782 """ import sqlalchemy as sa from alembic import op # revision identifiers, used by Alembic. -revision = '37a3dcdcb110' -down_revision = 'e13448650548' +revision = '95cd21cb2b05' +down_revision = '6b8483b46d06' branch_labels = None depends_on = None diff --git a/gso/products/product_blocks/iptrunk.py b/gso/products/product_blocks/iptrunk.py index 1dd6f38c..47c927dc 100644 --- a/gso/products/product_blocks/iptrunk.py +++ b/gso/products/product_blocks/iptrunk.py @@ -38,6 +38,7 @@ class IptrunkBlockInactive(ProductBlockModel, lifecycle=[SubscriptionLifecycle.INITIAL], product_block_name="IptrunkBlock"): geant_s_sid: Optional[str] = None + iptrunk_description: Optional[str] = None iptrunk_type: Optional[IptrunkType] = None iptrunk_speed: Optional[str] = None iptrunk_minimum_links: Optional[int] = None @@ -48,16 +49,19 @@ class IptrunkBlockInactive(ProductBlockModel, iptrunk_sideA_ae_iface: Optional[str] = None iptrunk_sideA_ae_geant_a_sid: Optional[str] = None iptrunk_sideA_ae_members: Optional[list] = None + iptrunk_sideA_ae_members_description: Optional[list] = None # iptrunk_sideB_fqdn: Optional[str] = None iptrunk_sideB_ae_iface: Optional[str] = None iptrunk_sideB_ae_geant_a_sid: Optional[str] = None iptrunk_sideB_ae_members: Optional[list] = None + iptrunk_sideB_ae_members_description: Optional[list] = None class IptrunkBlockProvisioning(IptrunkBlockInactive, lifecycle=[SubscriptionLifecycle.PROVISIONING]): geant_s_sid: Optional[str] = None + iptrunk_description: Optional[str] = None iptrunk_type: Optional[IptrunkType] = None iptrunk_speed: Optional[str] = None iptrunk_minimum_links: Optional[int] = None @@ -68,16 +72,19 @@ class IptrunkBlockProvisioning(IptrunkBlockInactive, iptrunk_sideA_ae_iface: Optional[str] = None iptrunk_sideA_ae_geant_a_sid: Optional[str] = None iptrunk_sideA_ae_members: Optional[list] = None + iptrunk_sideA_ae_members_description: Optional[list] = None # iptrunk_sideB_fqdn: Optional[str] = None iptrunk_sideB_ae_iface: Optional[str] = None iptrunk_sideB_ae_geant_a_sid: Optional[str] = None iptrunk_sideB_ae_members: Optional[list] = None + iptrunk_sideB_ae_members_description: Optional[list] = None class IptrunkBlock(IptrunkBlockProvisioning, lifecycle=[SubscriptionLifecycle.ACTIVE]): geant_s_sid: str + iptrunk_description: str iptrunk_type: IptrunkType iptrunk_speed: str iptrunk_minimum_links: int @@ -87,9 +94,11 @@ class IptrunkBlock(IptrunkBlockProvisioning, iptrunk_sideA_fqdn: str iptrunk_sideA_ae_iface: str iptrunk_sideA_ae_geant_a_sid: str - iptrunk_sideA_ae_members: list + iptrunk_sideA_ae_members: list[str] + iptrunk_sideA_ae_members_description: list[str] # iptrunk_sideB_fqdn: str iptrunk_sideB_ae_iface: str iptrunk_sideB_ae_geant_a_sid: str - iptrunk_sideB_ae_members: list + iptrunk_sideB_ae_members: list[str] + iptrunk_sideB_ae_members_description: list[str] diff --git a/gso/products/product_types/iptrunk.py b/gso/products/product_types/iptrunk.py index dbffb835..45fa2e18 100644 --- a/gso/products/product_types/iptrunk.py +++ b/gso/products/product_types/iptrunk.py @@ -8,6 +8,8 @@ from gso.products.product_blocks.iptrunk \ class IptrunkInactive(SubscriptionModel, is_base=True): iptrunk: IptrunkBlockInactive + sideA: DeviceActive + sideB: DeviceActive class IptrunkProvisioning(IptrunkInactive, diff --git a/gso/workflows/iptrunk/create_iptrunk.py b/gso/workflows/iptrunk/create_iptrunk.py index fcd7cb25..66fa2e19 100644 --- a/gso/workflows/iptrunk/create_iptrunk.py +++ b/gso/workflows/iptrunk/create_iptrunk.py @@ -12,6 +12,8 @@ from orchestrator.workflows.steps import resync, set_status from orchestrator.workflows.steps import store_process_subscription from orchestrator.workflows.utils import wrap_create_initial_input_form from gso.products.product_types import iptrunk +from gso.products.product_blocks import iptrunk as iptrunk_pb +from gso.products.product_types import device from gso.services import ipam, provisioning_proxy from gso.products.product_types import device @@ -46,6 +48,8 @@ def initial_input_form_generator(product_name: str) -> FormGenerator: title = product_name geant_s_sid: str + iptrunk_description: str + iptrunk_type: iptrunk_pb.IptrunkType iptrunk_speed: str # This should be an enum: 1/10/100/400 iptrunk_minimum_links: int @@ -53,16 +57,17 @@ def initial_input_form_generator(product_name: str) -> FormGenerator: iptrunk_sideA_ae_iface: str iptrunk_sideA_ae_geant_a_sid: str iptrunk_sideA_ae_members: list[str] + iptrunk_sideA_ae_members_descriptions: list[str] iptrunk_sideB_fqdn: device_selector(choice_value='DeviceEnumB') iptrunk_sideB_ae_iface: str iptrunk_sideB_ae_geant_a_sid: str iptrunk_sideB_ae_members: list[str] + iptrunk_sideB_ae_members_descriptions: list[str] # TODO: we need additional validation: # sideA fqdn must be different from sideB fqdn # the lenght of iptrunk_sideA_ae_members should be the same as iptrunk_sideA_ae_members # interface names must be validated - # We also need additional fields like a "name" or a description for trunk itself and for all the members user_input = yield CreateIptrunkForm @@ -93,34 +98,41 @@ def get_info_from_ipam(subscription: iptrunk.IptrunkInactive) -> State: def initialize_subscription( subscription: iptrunk.IptrunkInactive, geant_s_sid: str, + iptrunk_type: iptrunk_pb.IptrunkType, + iptrunk_description: str, iptrunk_speed: str, iptrunk_minimum_links: int, iptrunk_sideA_fqdn: str, iptrunk_sideA_ae_iface: str, iptrunk_sideA_ae_geant_a_sid: str, iptrunk_sideA_ae_members: list[str], + iptrunk_sideA_ae_members_descriptions: list[str], iptrunk_sideB_fqdn: str, iptrunk_sideB_ae_iface: str, iptrunk_sideB_ae_geant_a_sid: str, - iptrunk_sideB_ae_members: list[str] + iptrunk_sideB_ae_members: list[str], + iptrunk_sideB_ae_members_descriptions: list[str] ) -> State: - # subscription.iptrunk_type = iptrunk_type - subscription.iptrunk.geant_s_sid = geant_s_sid + subscription.iptrunk.iptrunk_description = iptrunk_description + subscription.iptrunk.iptrunk_type = iptrunk_type subscription.iptrunk.iptrunk_speed = iptrunk_speed subscription.iptrunk.iptrunk_minimum_links = iptrunk_minimum_links - subscription.iptrunk.iptrunk_sideA_fqdn = iptrunk_sideA_fqdn + subscription.iptrunk.iptrunk_sideA_fqdn = device.from_subscription(iptrunk_sideA_fqdn[0]).fqdn subscription.iptrunk.iptrunk_sideA_ae_iface = iptrunk_sideA_ae_iface subscription.iptrunk.iptrunk_sideA_ae_geant_a_sid = iptrunk_sideA_ae_geant_a_sid subscription.iptrunk.iptrunk_sideA_ae_members = iptrunk_sideA_ae_members + subscription.iptrunk.iptrunk_sideA_ae_members_description = iptrunk_sideA_ae_members_descriptions - subscription.iptrunk.iptrunk_sideB_fqdn = iptrunk_sideB_fqdn + subscription.iptrunk.iptrunk_sideB_fqdn = iptrunk_sideB_fqdn[0] subscription.iptrunk.iptrunk_sideB_ae_iface = iptrunk_sideB_ae_iface subscription.iptrunk.iptrunk_sideB_ae_geant_a_sid = iptrunk_sideB_ae_geant_a_sid subscription.iptrunk.iptrunk_sideB_ae_members = iptrunk_sideB_ae_members + subscription.iptrunk.iptrunk_sideB_ae_members_description = iptrunk_sideB_ae_members_descriptions + subscription.description = f"Iptrunk {geant_s_sid}: \ - ({subscription.iptrunk_type})" + (blablabla)" subscription = iptrunk.IptrunkProvisioning.from_other_lifecycle( subscription, SubscriptionLifecycle.PROVISIONING ) @@ -223,12 +235,11 @@ def create_iptrunk(): init >> create_subscription >> store_process_subscription(Target.CREATE) - #>> get_info_from_ipam - #>> get_snmp_info - #>> initialize_subscription - #>> provision_iptrunk_dry - #>> confirm_step - #>> provision_iptrunk_real + >> get_info_from_ipam + >> initialize_subscription + >> provision_iptrunk_dry + >> confirm_step + >> provision_iptrunk_real >> set_status(SubscriptionLifecycle.ACTIVE) >> resync >> done -- GitLab