diff --git a/gso/migrations/versions/2024-10-08_bf05800fe9fc_add_edge_port_and_nren_l3_workflows.py b/gso/migrations/versions/2024-10-17_7412c5b7ebe4_add_import_edgeport_and_l3_core_service_.py similarity index 82% rename from gso/migrations/versions/2024-10-08_bf05800fe9fc_add_edge_port_and_nren_l3_workflows.py rename to gso/migrations/versions/2024-10-17_7412c5b7ebe4_add_import_edgeport_and_l3_core_service_.py index 770e6c31f71a5e6704f600c6a948c0b8bc4e8997..6f6b40e99aaa6d1b1146839369fb24be12e8347d 100644 --- a/gso/migrations/versions/2024-10-08_bf05800fe9fc_add_edge_port_and_nren_l3_workflows.py +++ b/gso/migrations/versions/2024-10-17_7412c5b7ebe4_add_import_edgeport_and_l3_core_service_.py @@ -1,16 +1,16 @@ -"""Add Edge Port and NREN L3 Core Service workflows. +"""Add Import EdgePort and L3 Core Service workflows.. -Revision ID: bf05800fe9fc -Revises: a08bf228f112 -Create Date: 2024-10-08 11:22:00.038925 +Revision ID: 7412c5b7ebe4 +Revises: e1659d366925 +Create Date: 2024-10-17 13:10:38.551706 """ import sqlalchemy as sa from alembic import op # revision identifiers, used by Alembic. -revision = 'bf05800fe9fc' -down_revision = '2d224884c80b' +revision = '7412c5b7ebe4' +down_revision = 'e1659d366925' branch_labels = None depends_on = None @@ -57,32 +57,32 @@ new_workflows = [ { "name": "create_nren_l3_core_service", "target": "CREATE", - "description": "Create NREN L3 Core Service", + "description": "Create G\u00c9ANT IP", "product_type": "NRENL3CoreService" }, { "name": "modify_nren_l3_core_service", "target": "MODIFY", - "description": "Modify NREN L3 Core Service", - "product_type": "NRENL3CoreService" - }, - { - "name": "migrate_nren_l3_core_service", - "target": "MODIFY", - "description": "Migrate NREN L3 Core Service", + "description": "Modify G\u00c9ANT IP", "product_type": "NRENL3CoreService" }, { "name": "create_imported_nren_l3_core_service", "target": "CREATE", - "description": "Import NREN L3 Core Service", + "description": "Import G\u00c9ANT IP", "product_type": "ImportedNRENL3CoreService" }, { "name": "import_nren_l3_core_service", "target": "MODIFY", - "description": "Import NREN L3 Core Service", + "description": "Import G\u00c9ANT IP", "product_type": "ImportedNRENL3CoreService" + }, + { + "name": "migrate_nren_l3_core_service", + "target": "MODIFY", + "description": "Migrate G\u00c9ANT IP", + "product_type": "NRENL3CoreService" } ] diff --git a/gso/migrations/versions/2024-10-16_2d224884c80b_add_edge_port_and_nren_l3_core_service_.py b/gso/migrations/versions/2024-10-17_e1659d366925_add_edge_port_and_l3_core_service_.py similarity index 93% rename from gso/migrations/versions/2024-10-16_2d224884c80b_add_edge_port_and_nren_l3_core_service_.py rename to gso/migrations/versions/2024-10-17_e1659d366925_add_edge_port_and_l3_core_service_.py index 89d08a47284a3d11b6571adcee23a8cd942d6cf6..7e027aa7c2579ad33e61d9957733741ce968117b 100644 --- a/gso/migrations/versions/2024-10-16_2d224884c80b_add_edge_port_and_nren_l3_core_service_.py +++ b/gso/migrations/versions/2024-10-17_e1659d366925_add_edge_port_and_l3_core_service_.py @@ -1,15 +1,15 @@ -"""Add Edge Port and NREN L3 Core Service products. +"""Add Edge Port and L3 Core Service domain models. -Revision ID: 2d224884c80b +Revision ID: e1659d366925 Revises: 51c819b28101 -Create Date: 2024-10-16 14:39:40.236160 +Create Date: 2024-10-17 11:33:38.103939 """ import sqlalchemy as sa from alembic import op # revision identifiers, used by Alembic. -revision = '2d224884c80b' +revision = 'e1659d366925' down_revision = '51c819b28101' branch_labels = None depends_on = None @@ -27,7 +27,7 @@ INSERT INTO products (name, description, product_type, tag, status) VALUES ('Imp INSERT INTO products (name, description, product_type, tag, status) VALUES ('GÉANT IP', 'A GÉANT IP subscription for R&E access', 'NRENL3CoreService', 'G_IP', 'active') RETURNING products.product_id """)) conn.execute(sa.text(""" -INSERT INTO products (name, description, product_type, tag, status) VALUES ('Imported GÉANT IP', 'A Gpre-existing GÉANT IP subscription that is imported into the service database', 'ImportedNRENL3CoreService', 'IMP_G_IP', 'active') RETURNING products.product_id +INSERT INTO products (name, description, product_type, tag, status) VALUES ('Imported GÉANT IP', 'A pre-existing GÉANT IP subscription that is imported into the service database', 'ImportedNRENL3CoreService', 'IMP_G_IP', 'active') RETURNING products.product_id """)) conn.execute(sa.text(""" INSERT INTO products (name, description, product_type, tag, status) VALUES ('IAS', 'An Internet Access Service for general internet access', 'NRENL3CoreService', 'IAS', 'active') RETURNING products.product_id @@ -36,7 +36,7 @@ INSERT INTO products (name, description, product_type, tag, status) VALUES ('IAS INSERT INTO products (name, description, product_type, tag, status) VALUES ('Imported IAS', 'A pre-existing Internet Access Service that is imported into the service database', 'ImportedNRENL3CoreService', 'IMP_IAS', 'active') RETURNING products.product_id """)) conn.execute(sa.text(""" -INSERT INTO fixed_inputs (name, value, product_id) VALUES ('nren_l3_core_service_type', 'IMPORTED_IAS', (SELECT products.product_id FROM products WHERE products.name IN ('Imported IAS'))), ('nren_l3_core_service_type', 'IMPORTED_GEANT_IP', (SELECT products.product_id FROM products WHERE products.name IN ('Imported GÉANT IP'))), ('nren_l3_core_service_type', 'IAS', (SELECT products.product_id FROM products WHERE products.name IN ('IAS'))), ('nren_l3_core_service_type', 'GGEANT_IP', (SELECT products.product_id FROM products WHERE products.name IN ('GÉANT IP'))) +INSERT INTO fixed_inputs (name, value, product_id) VALUES ('nren_l3_core_service_type', 'IAS', (SELECT products.product_id FROM products WHERE products.name IN ('IAS'))), ('nren_l3_core_service_type', 'IMPORTED_IAS', (SELECT products.product_id FROM products WHERE products.name IN ('Imported IAS'))), ('nren_l3_core_service_type', 'GEANT_IP', (SELECT products.product_id FROM products WHERE products.name IN ('GÉANT IP'))), ('nren_l3_core_service_type', 'IMPORTED_GEANT_IP', (SELECT products.product_id FROM products WHERE products.name IN ('Imported GÉANT IP'))) """)) conn.execute(sa.text(""" INSERT INTO product_blocks (name, description, tag, status) VALUES ('EdgePortBlock', 'The product block with all attributes of an Edge Port', 'EP_BLOCK', 'active') RETURNING product_blocks.product_block_id @@ -57,100 +57,100 @@ INSERT INTO product_blocks (name, description, tag, status) VALUES ('ServiceBind INSERT INTO product_blocks (name, description, tag, status) VALUES ('BGPSession', 'A BGP session', 'BGP_BLOCK', 'active') RETURNING product_blocks.product_block_id """)) conn.execute(sa.text(""" -INSERT INTO resource_types (resource_type, description) VALUES ('ignore_if_down', 'Ignore if this interface goes down') RETURNING resource_types.resource_type_id - """)) - conn.execute(sa.text(""" -INSERT INTO resource_types (resource_type, description) VALUES ('multipath_enabled', 'Does this have multipath enabled') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('send_default_route', 'This product sends a default route') RETURNING resource_types.resource_type_id """)) conn.execute(sa.text(""" -INSERT INTO resource_types (resource_type, description) VALUES ('geant_ga_id', 'GÉANT GA service ID') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('has_custom_policies', 'This has custom policies enabled') RETURNING resource_types.resource_type_id """)) conn.execute(sa.text(""" -INSERT INTO resource_types (resource_type, description) VALUES ('has_custom_policies', 'This has custom policies enabled') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('is_passive', 'This product is passive') RETURNING resource_types.resource_type_id """)) conn.execute(sa.text(""" -INSERT INTO resource_types (resource_type, description) VALUES ('families', 'IP families, can be v4 v6 and UNICAST or MULTICAST') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('bfd_enabled', 'This product has BFD enabled') RETURNING resource_types.resource_type_id """)) conn.execute(sa.text(""" -INSERT INTO resource_types (resource_type, description) VALUES ('edge_port_name', 'Edge Port interface name') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('enable_lacp', 'This product has LACP enabled') RETURNING resource_types.resource_type_id """)) conn.execute(sa.text(""" INSERT INTO resource_types (resource_type, description) VALUES ('edge_port_type', 'Type of Edge Port') RETURNING resource_types.resource_type_id """)) conn.execute(sa.text(""" -INSERT INTO resource_types (resource_type, description) VALUES ('custom_firewall_filters', 'This product has custom firewall filters enabled') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('geant_ga_id', 'GÉANT GA service ID') RETURNING resource_types.resource_type_id """)) conn.execute(sa.text(""" -INSERT INTO resource_types (resource_type, description) VALUES ('peer_address', 'A Peer address') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('bfd_multiplier', 'BFD multiplier') RETURNING resource_types.resource_type_id """)) conn.execute(sa.text(""" INSERT INTO resource_types (resource_type, description) VALUES ('ipv6_address', 'IPv6 Address') RETURNING resource_types.resource_type_id """)) conn.execute(sa.text(""" -INSERT INTO resource_types (resource_type, description) VALUES ('edge_port_description', 'Description of an Edge Port') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('edge_port_name', 'The Edge Port name') RETURNING resource_types.resource_type_id """)) conn.execute(sa.text(""" -INSERT INTO resource_types (resource_type, description) VALUES ('authentication_key', 'Authentication key') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('encapsulation', 'Encapsulation method') RETURNING resource_types.resource_type_id """)) conn.execute(sa.text(""" -INSERT INTO resource_types (resource_type, description) VALUES ('bfd_multiplier', 'BFD multiplier') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('ignore_if_down', 'Ignore if this interface goes down') RETURNING resource_types.resource_type_id """)) conn.execute(sa.text(""" -INSERT INTO resource_types (resource_type, description) VALUES ('is_tagged', 'This product is tagged') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('bfd_interval', 'BFD interval') RETURNING resource_types.resource_type_id """)) conn.execute(sa.text(""" INSERT INTO resource_types (resource_type, description) VALUES ('rtbh_enabled', 'This product has RTBH enabled') RETURNING resource_types.resource_type_id """)) conn.execute(sa.text(""" -INSERT INTO resource_types (resource_type, description) VALUES ('mac_address', 'A MAC address') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('custom_firewall_filters', 'This product has custom firewall filters enabled') RETURNING resource_types.resource_type_id """)) conn.execute(sa.text(""" -INSERT INTO resource_types (resource_type, description) VALUES ('bfd_interval', 'BFD interval') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('ap_type', 'Access Port type') RETURNING resource_types.resource_type_id """)) conn.execute(sa.text(""" INSERT INTO resource_types (resource_type, description) VALUES ('is_multi_hop', 'This product is multi-hop') RETURNING resource_types.resource_type_id """)) conn.execute(sa.text(""" -INSERT INTO resource_types (resource_type, description) VALUES ('member_speed', 'The capacity of a member interface') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('edge_port_description', 'Description of an Edge Port') RETURNING resource_types.resource_type_id """)) conn.execute(sa.text(""" -INSERT INTO resource_types (resource_type, description) VALUES ('ipv4_mask', 'IPv4 netmask') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('is_tagged', 'This product is tagged') RETURNING resource_types.resource_type_id """)) conn.execute(sa.text(""" -INSERT INTO resource_types (resource_type, description) VALUES ('geant_sid', 'G´ÉANT service ID') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('mac_address', 'A MAC address') RETURNING resource_types.resource_type_id """)) conn.execute(sa.text(""" -INSERT INTO resource_types (resource_type, description) VALUES ('encapsulation', 'Encapsulation method') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('geant_sid', 'GEANT SID') RETURNING resource_types.resource_type_id """)) conn.execute(sa.text(""" -INSERT INTO resource_types (resource_type, description) VALUES ('ipv4_address', 'IPv4 Address') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('ipv4_address', 'IPV4 Address') RETURNING resource_types.resource_type_id """)) conn.execute(sa.text(""" -INSERT INTO resource_types (resource_type, description) VALUES ('ipv6_mask', 'IPv6 netmask') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('peer_address', 'Peer address') RETURNING resource_types.resource_type_id """)) conn.execute(sa.text(""" -INSERT INTO resource_types (resource_type, description) VALUES ('bfd_enabled', 'This product has BFD enabled') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('sbp_type', 'Type of Service Binding Port') RETURNING resource_types.resource_type_id """)) conn.execute(sa.text(""" -INSERT INTO resource_types (resource_type, description) VALUES ('ap_type', 'Access Port type') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('ipv6_mask', 'IPV6 subnet mask') RETURNING resource_types.resource_type_id """)) conn.execute(sa.text(""" -INSERT INTO resource_types (resource_type, description) VALUES ('send_default_route', 'This product sends a default route') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('authentication_key', 'Authentication key') RETURNING resource_types.resource_type_id """)) conn.execute(sa.text(""" -INSERT INTO resource_types (resource_type, description) VALUES ('is_passive', 'This product is passive') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('multipath_enabled', 'Does this have multipath enabled') RETURNING resource_types.resource_type_id """)) conn.execute(sa.text(""" -INSERT INTO resource_types (resource_type, description) VALUES ('sbp_type', 'Type of Service Binding Port') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('ipv4_mask', 'IPV4 netmask') RETURNING resource_types.resource_type_id """)) conn.execute(sa.text(""" -INSERT INTO resource_types (resource_type, description) VALUES ('enable_lacp', 'This product has LACP enabled') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('families', 'IP families, can be v4 v6 and UNICAST or MULTICAST') RETURNING resource_types.resource_type_id + """)) + conn.execute(sa.text(""" +INSERT INTO resource_types (resource_type, description) VALUES ('member_speed', 'The member speed') RETURNING resource_types.resource_type_id """)) conn.execute(sa.text(""" -INSERT INTO product_product_blocks (product_id, product_block_id) VALUES ((SELECT products.product_id FROM products WHERE products.name IN ('Imported Edge Port')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('EdgePortBlock'))), ((SELECT products.product_id FROM products WHERE products.name IN ('Edge Port')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('EdgePortBlock'))) +INSERT INTO product_product_blocks (product_id, product_block_id) VALUES ((SELECT products.product_id FROM products WHERE products.name IN ('Edge Port')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('EdgePortBlock'))), ((SELECT products.product_id FROM products WHERE products.name IN ('Imported Edge Port')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('EdgePortBlock'))) """)) conn.execute(sa.text(""" -INSERT INTO product_product_blocks (product_id, product_block_id) VALUES ((SELECT products.product_id FROM products WHERE products.name IN ('Imported IAS')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('NRENL3CoreServiceBlock'))), ((SELECT products.product_id FROM products WHERE products.name IN ('Imported GÉANT IP')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('NRENL3CoreServiceBlock'))), ((SELECT products.product_id FROM products WHERE products.name IN ('IAS')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('NRENL3CoreServiceBlock'))), ((SELECT products.product_id FROM products WHERE products.name IN ('GÉANT IP')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('NRENL3CoreServiceBlock'))) +INSERT INTO product_product_blocks (product_id, product_block_id) VALUES ((SELECT products.product_id FROM products WHERE products.name IN ('IAS')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('NRENL3CoreServiceBlock'))), ((SELECT products.product_id FROM products WHERE products.name IN ('Imported IAS')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('NRENL3CoreServiceBlock'))), ((SELECT products.product_id FROM products WHERE products.name IN ('GÉANT IP')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('NRENL3CoreServiceBlock'))), ((SELECT products.product_id FROM products WHERE products.name IN ('Imported GÉANT IP')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('NRENL3CoreServiceBlock'))) """)) 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 ('EdgePortBlock')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('RouterBlock'))) @@ -481,16 +481,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 ('BGPSession'))) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('rtbh_enabled')) """)) conn.execute(sa.text(""" -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 ('ignore_if_down', 'multipath_enabled', 'geant_ga_id', 'has_custom_policies', 'families', 'edge_port_name', 'edge_port_type', 'custom_firewall_filters', 'peer_address', 'ipv6_address', 'edge_port_description', 'authentication_key', 'bfd_multiplier', 'is_tagged', 'rtbh_enabled', 'mac_address', 'bfd_interval', 'is_multi_hop', 'member_speed', 'ipv4_mask', 'geant_sid', 'encapsulation', 'ipv4_address', 'ipv6_mask', 'bfd_enabled', 'ap_type', 'send_default_route', 'is_passive', 'sbp_type', 'enable_lacp')) +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 ('send_default_route', 'has_custom_policies', 'is_passive', 'bfd_enabled', 'enable_lacp', 'edge_port_type', 'geant_ga_id', 'bfd_multiplier', 'ipv6_address', 'edge_port_name', 'encapsulation', 'ignore_if_down', 'bfd_interval', 'rtbh_enabled', 'custom_firewall_filters', 'ap_type', 'is_multi_hop', 'edge_port_description', 'is_tagged', 'mac_address', 'geant_sid', 'ipv4_address', 'peer_address', 'sbp_type', 'ipv6_mask', 'authentication_key', 'multipath_enabled', 'ipv4_mask', 'families', 'member_speed')) """)) conn.execute(sa.text(""" -DELETE FROM resource_types WHERE resource_types.resource_type IN ('ignore_if_down', 'multipath_enabled', 'geant_ga_id', 'has_custom_policies', 'families', 'edge_port_name', 'edge_port_type', 'custom_firewall_filters', 'peer_address', 'ipv6_address', 'edge_port_description', 'authentication_key', 'bfd_multiplier', 'is_tagged', 'rtbh_enabled', 'mac_address', 'bfd_interval', 'is_multi_hop', 'member_speed', 'ipv4_mask', 'geant_sid', 'encapsulation', 'ipv4_address', 'ipv6_mask', 'bfd_enabled', 'ap_type', 'send_default_route', 'is_passive', 'sbp_type', 'enable_lacp') +DELETE FROM resource_types WHERE resource_types.resource_type IN ('send_default_route', 'has_custom_policies', 'is_passive', 'bfd_enabled', 'enable_lacp', 'edge_port_type', 'geant_ga_id', 'bfd_multiplier', 'ipv6_address', 'edge_port_name', 'encapsulation', 'ignore_if_down', 'bfd_interval', 'rtbh_enabled', 'custom_firewall_filters', 'ap_type', 'is_multi_hop', 'edge_port_description', 'is_tagged', 'mac_address', 'geant_sid', 'ipv4_address', 'peer_address', 'sbp_type', 'ipv6_mask', 'authentication_key', 'multipath_enabled', 'ipv4_mask', 'families', 'member_speed') """)) conn.execute(sa.text(""" -DELETE FROM product_product_blocks WHERE product_product_blocks.product_id IN (SELECT products.product_id FROM products WHERE products.name IN ('Imported Edge Port', 'Edge Port')) AND product_product_blocks.product_block_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('EdgePortBlock')) +DELETE FROM product_product_blocks WHERE product_product_blocks.product_id IN (SELECT products.product_id FROM products WHERE products.name IN ('Edge Port', 'Imported Edge Port')) AND product_product_blocks.product_block_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('EdgePortBlock')) """)) conn.execute(sa.text(""" -DELETE FROM product_product_blocks WHERE product_product_blocks.product_id IN (SELECT products.product_id FROM products WHERE products.name IN ('Imported IAS', 'Imported GÉANT IP', 'IAS', 'GÉANT IP')) AND product_product_blocks.product_block_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('NRENL3CoreServiceBlock')) +DELETE FROM product_product_blocks WHERE product_product_blocks.product_id IN (SELECT products.product_id FROM products WHERE products.name IN ('IAS', 'Imported IAS', 'GÉANT IP', 'Imported GÉANT IP')) AND product_product_blocks.product_block_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('NRENL3CoreServiceBlock')) """)) 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 ('RouterBlock')) @@ -511,26 +511,26 @@ DELETE FROM product_block_relations WHERE product_block_relations.in_use_by_id I 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 fixed_inputs WHERE fixed_inputs.product_id IN (SELECT products.product_id FROM products WHERE products.name IN ('Imported IAS', 'Imported GÉANT IP', 'IAS', 'GÉANT IP')) AND fixed_inputs.name = 'nren_l3_core_service_type' +DELETE FROM fixed_inputs WHERE fixed_inputs.product_id IN (SELECT products.product_id FROM products WHERE products.name IN ('IAS', 'Imported IAS', 'GÉANT IP', 'Imported GÉANT IP')) AND fixed_inputs.name = 'nren_l3_core_service_type' """)) conn.execute(sa.text(""" -DELETE FROM subscription_instances WHERE subscription_instances.product_block_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('BGPSession', 'ServiceBindingPort', 'NRENAccessPort', 'EdgePortAEMemberBlock', 'NRENL3CoreServiceBlock', 'EdgePortBlock')) +DELETE FROM subscription_instances WHERE subscription_instances.product_block_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('EdgePortAEMemberBlock', 'EdgePortBlock', 'NRENL3CoreServiceBlock', 'ServiceBindingPort', 'BGPSession', 'NRENAccessPort')) """)) conn.execute(sa.text(""" -DELETE FROM product_blocks WHERE product_blocks.name IN ('BGPSession', 'ServiceBindingPort', 'NRENAccessPort', 'EdgePortAEMemberBlock', 'NRENL3CoreServiceBlock', 'EdgePortBlock') +DELETE FROM product_blocks WHERE product_blocks.name IN ('EdgePortAEMemberBlock', 'EdgePortBlock', 'NRENL3CoreServiceBlock', 'ServiceBindingPort', 'BGPSession', 'NRENAccessPort') """)) conn.execute(sa.text(""" -DELETE FROM processes WHERE processes.pid IN (SELECT processes_subscriptions.pid FROM processes_subscriptions WHERE processes_subscriptions.subscription_id IN (SELECT subscriptions.subscription_id FROM subscriptions WHERE subscriptions.product_id IN (SELECT products.product_id FROM products WHERE products.name IN ('Imported IAS', 'Imported GÉANT IP', 'Imported Edge Port', 'Edge Port', 'IAS', 'GÉANT IP')))) +DELETE FROM processes WHERE processes.pid IN (SELECT processes_subscriptions.pid FROM processes_subscriptions WHERE processes_subscriptions.subscription_id IN (SELECT subscriptions.subscription_id FROM subscriptions WHERE subscriptions.product_id IN (SELECT products.product_id FROM products WHERE products.name IN ('IAS', 'GÉANT IP', 'Imported GÉANT IP', 'Edge Port', 'Imported IAS', 'Imported Edge Port')))) """)) conn.execute(sa.text(""" -DELETE FROM processes_subscriptions WHERE processes_subscriptions.subscription_id IN (SELECT subscriptions.subscription_id FROM subscriptions WHERE subscriptions.product_id IN (SELECT products.product_id FROM products WHERE products.name IN ('Imported IAS', 'Imported GÉANT IP', 'Imported Edge Port', 'Edge Port', 'IAS', 'GÉANT IP'))) +DELETE FROM processes_subscriptions WHERE processes_subscriptions.subscription_id IN (SELECT subscriptions.subscription_id FROM subscriptions WHERE subscriptions.product_id IN (SELECT products.product_id FROM products WHERE products.name IN ('IAS', 'GÉANT IP', 'Imported GÉANT IP', 'Edge Port', 'Imported IAS', 'Imported Edge Port'))) """)) conn.execute(sa.text(""" -DELETE FROM subscription_instances WHERE subscription_instances.subscription_id IN (SELECT subscriptions.subscription_id FROM subscriptions WHERE subscriptions.product_id IN (SELECT products.product_id FROM products WHERE products.name IN ('Imported IAS', 'Imported GÉANT IP', 'Imported Edge Port', 'Edge Port', 'IAS', 'GÉANT IP'))) +DELETE FROM subscription_instances WHERE subscription_instances.subscription_id IN (SELECT subscriptions.subscription_id FROM subscriptions WHERE subscriptions.product_id IN (SELECT products.product_id FROM products WHERE products.name IN ('IAS', 'GÉANT IP', 'Imported GÉANT IP', 'Edge Port', 'Imported IAS', 'Imported Edge Port'))) """)) conn.execute(sa.text(""" -DELETE FROM subscriptions WHERE subscriptions.product_id IN (SELECT products.product_id FROM products WHERE products.name IN ('Imported IAS', 'Imported GÉANT IP', 'Imported Edge Port', 'Edge Port', 'IAS', 'GÉANT IP')) +DELETE FROM subscriptions WHERE subscriptions.product_id IN (SELECT products.product_id FROM products WHERE products.name IN ('IAS', 'GÉANT IP', 'Imported GÉANT IP', 'Edge Port', 'Imported IAS', 'Imported Edge Port')) """)) conn.execute(sa.text(""" -DELETE FROM products WHERE products.name IN ('Imported IAS', 'Imported GÉANT IP', 'Imported Edge Port', 'Edge Port', 'IAS', 'GÉANT IP') +DELETE FROM products WHERE products.name IN ('IAS', 'GÉANT IP', 'Imported GÉANT IP', 'Edge Port', 'Imported IAS', 'Imported Edge Port') """)) diff --git a/gso/products/product_types/edge_port.py b/gso/products/product_types/edge_port.py index 417b6047a8d787d852057b43d52692a38569bc32..372e15045b9d2d953cbba06e0e0d01db071f1cb5 100644 --- a/gso/products/product_types/edge_port.py +++ b/gso/products/product_types/edge_port.py @@ -40,3 +40,4 @@ class ImportedEdgePort( """An imported Edge Port that is currently active.""" edge_port: EdgePortBlock + diff --git a/gso/products/product_types/nren_l3_core_service.py b/gso/products/product_types/nren_l3_core_service.py index a00cdf571da9e2208c091ce8c9a9c41ea3e5e46e..8717acfebaff3a1d967fbdd1a6265f57cfc1759e 100644 --- a/gso/products/product_types/nren_l3_core_service.py +++ b/gso/products/product_types/nren_l3_core_service.py @@ -17,7 +17,7 @@ class NRENL3CoreServiceType(strEnum): The core services offered include GÉANT IP for R&E access, and the Internet Access Service. """ - GEANT_IP = "GÉANT IP" + GEANT_IP = "GEANT_IP" IAS = "IAS" diff --git a/gso/workflows/nren_l3_core_service/create_imported_nren_l3_core_service.py b/gso/workflows/nren_l3_core_service/create_imported_nren_l3_core_service.py index 4ad7adedcd05a6018a3dd01b8e5a633988084110..81dc3f0b5db25da3a4dfb890a366ef23533892c9 100644 --- a/gso/workflows/nren_l3_core_service/create_imported_nren_l3_core_service.py +++ b/gso/workflows/nren_l3_core_service/create_imported_nren_l3_core_service.py @@ -16,7 +16,7 @@ from gso.products.product_blocks.bgp_session import BGPSession, IPFamily from gso.products.product_blocks.nren_l3_core_service import NRENAccessPortInactive 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.nren_l3_core_service import ImportedGeantIPInactive +from gso.products.product_types.nren_l3_core_service import ImportedNRENL3CoreServiceInactive from gso.services.partners import get_partner_by_name from gso.services.subscriptions import get_product_id_by_name from gso.utils.shared_enums import SBPType @@ -70,12 +70,12 @@ def create_subscription(partner: str) -> dict: """Create a new subscription object in the database.""" partner_id = get_partner_by_name(partner)["partner_id"] product_id = get_product_id_by_name(ProductName.IMPORTED_GEANT_IP) - subscription = ImportedGeantIPInactive.from_product_id(product_id, partner_id) + subscription = ImportedNRENL3CoreServiceInactive.from_product_id(product_id, partner_id) return {"subscription": subscription, "subscription_id": subscription.subscription_id} @step("Initialize subscription") -def initialize_subscription(subscription: ImportedGeantIPInactive, service_binding_ports: list) -> dict: +def initialize_subscription(subscription: ImportedNRENL3CoreServiceInactive, service_binding_ports: list) -> dict: """Initialize the subscription with the user input.""" for service_binding_port in service_binding_ports: edge_port_subscription = EdgePort.from_subscription(service_binding_port.pop("edge_port")) @@ -106,7 +106,7 @@ def initialize_subscription(subscription: ImportedGeantIPInactive, service_bindi initial_input_form=initial_input_form_generator, target=Target.CREATE, ) -def create_imported_geant_ip() -> StepList: +def create_imported_nren_l3_core_service() -> StepList: """Import a GÉANT IP without provisioning it.""" return ( begin 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 bba6a51efa350f9870b5e4a7c12f937fb516e1aa..2ac1708d525591a0aa0d9a19b68b5ef89ef9a064 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 @@ -1,4 +1,4 @@ -"""Create a new GÉANT IP subscription.""" +"""Create a new NREN L3 Core Service subscription including GÉANT IP and IAS.""" from typing import Annotated, Any from uuid import uuid4 @@ -17,7 +17,7 @@ from gso.products.product_blocks.bgp_session import BGPSession, IPFamily from gso.products.product_blocks.nren_l3_core_service import NRENAccessPortInactive 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.nren_l3_core_service import GeantIPInactive +from gso.products.product_types.nren_l3_core_service import NRENL3CoreService, NRENL3CoreServiceInactive from gso.services.lso_client import LSOState, lso_interaction from gso.utils.helpers import ( active_edge_port_selector, @@ -31,13 +31,13 @@ from gso.utils.types.tt_number import TTNumber def initial_input_form_generator(product_name: str) -> FormGenerator: """Gather input from the operator to build a new subscription object.""" - class CreateGeantIPForm(FormPage): - model_config = ConfigDict(title="GÉANT IP - Select partner") + class CreateNRENCoreServiceForm(FormPage): + model_config = ConfigDict(title=f"{product_name} - Select partner") tt_number: TTNumber partner: partner_choice() # type: ignore[valid-type] - initial_user_input = yield CreateGeantIPForm + initial_user_input = yield CreateNRENCoreServiceForm class EdgePortSelection(BaseModel): edge_port: active_edge_port_selector(partner_id=initial_user_input.partner) # type: ignore[valid-type] @@ -52,9 +52,9 @@ def initial_input_form_generator(product_name: str) -> FormGenerator: return edge_ports class EdgePortSelectionForm(FormPage): - model_config = ConfigDict(title="GÉANT IP - Select Edge Ports") + model_config = ConfigDict(title=f"{product_name} - Select Edge Ports") info_label: Label = Field( - "Please select the Edge Ports where this GÉANT IP service will terminate", exclude=True + f"Please select the Edge Ports where this {product_name} service will terminate", exclude=True ) edge_ports: Annotated[list[EdgePortSelection], AfterValidator(validate_edge_ports_are_unique)] @@ -94,7 +94,7 @@ def initial_input_form_generator(product_name: str) -> FormGenerator: for ep_index, edge_port in enumerate(ep_list): class BindingPortsInputForm(FormPage): - model_config = ConfigDict(title=f"GÉANT IP - Configure Edge Ports ({ep_index + 1}/{len(ep_list)})") + model_config = ConfigDict(title=f"{product_name} - Configure Edge Ports ({ep_index + 1}/{len(ep_list)})") info_label: Label = Field("Please configure the Service Binding Ports for each Edge Port.", exclude=True) current_ep_label: Label = Field( f"Currently configuring on {EdgePort.from_subscription(edge_port.edge_port).description} " @@ -135,14 +135,14 @@ def initial_input_form_generator(product_name: str) -> FormGenerator: @step("Create subscription") def create_subscription(product: UUIDstr, partner: str) -> State: """Create a new subscription object in the database.""" - subscription = GeantIPInactive.from_product_id(product, partner) + subscription = NRENL3CoreServiceInactive.from_product_id(product, partner) return {"subscription": subscription, "subscription_id": subscription.subscription_id} @step("Initialize subscription") def initialize_subscription( - subscription: GeantIPInactive, edge_ports: list[dict], binding_port_inputs: list[dict] + subscription: NRENL3CoreServiceInactive, edge_ports: list[dict], binding_port_inputs: list[dict], product_name: str ) -> State: """Take all user inputs and use them to populate the subscription model.""" edge_port_fqdn_list = [] @@ -155,20 +155,20 @@ def initialize_subscription( service_binding_port = ServiceBindingPortInactive.new( subscription_id=uuid4(), **sbp_input, - sbp_bgp_session_list=sbp_bgp_session_list, + bgp_session_list=sbp_bgp_session_list, sbp_type=SBPType.L3, edge_port=edge_port_subscription.edge_port, ) - subscription.geant_ip.geant_ip_ap_list.append( + subscription.nren_l3_core_service.nren_ap_list.append( NRENAccessPortInactive.new( subscription_id=uuid4(), - nren_ap_type=edge_port_input["ap_type"], - geant_ip_sbp=service_binding_port, + ap_type=edge_port_input["ap_type"], + sbp=service_binding_port, ) ) edge_port_fqdn_list.append(edge_port_subscription.edge_port.node.router_fqdn) - subscription.description = "GEANT IP service" + subscription.description = f"{product_name} service" return {"subscription": subscription, "edge_port_fqdn_list": edge_port_fqdn_list} @@ -278,19 +278,19 @@ def check_bgp_peers(subscription: dict[str, Any], edge_port_fqdn_list: list[str] @step("Update Infoblox") -def update_dns_records(subscription: GeantIPInactive) -> State: +def update_dns_records(subscription: NRENL3CoreService) -> State: """Update :term:`DNS` records in Infoblox.""" # TODO: implement return {"subscription": subscription} @workflow( - "Create GÉANT IP", + "Create NREN L3 Core Service", initial_input_form=wrap_create_initial_input_form(initial_input_form_generator), target=Target.CREATE, ) -def create_geant_ip() -> StepList: - """Create a new GÉANT IP subscription. +def create_nren_l3_core_service() -> StepList: + """Create a new :term:`NREN` L3 Core Service subscription including GÉANT IP and IAS. * Create subscription object in the service database * Deploy service binding ports diff --git a/gso/workflows/nren_l3_core_service/import_nren_l3_core_service.py b/gso/workflows/nren_l3_core_service/import_nren_l3_core_service.py index fa7413edceae7b58454aa5b1340a0c20b35cf278..af458e54baa51499b15a5b97df66f6f7ec4a50ad 100644 --- a/gso/workflows/nren_l3_core_service/import_nren_l3_core_service.py +++ b/gso/workflows/nren_l3_core_service/import_nren_l3_core_service.py @@ -7,21 +7,21 @@ from orchestrator.workflows.steps import resync, store_process_subscription, uns from orchestrator.workflows.utils import wrap_modify_initial_input_form from gso.products import ProductName -from gso.products.product_types.nren_l3_core_service import GeantIP, ImportedGeantIP +from gso.products.product_types.nren_l3_core_service import NRENL3CoreService, ImportedNRENL3CoreService from gso.services.subscriptions import get_product_id_by_name @step("Create new IP trunk subscription") 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) + old_geant_ip = ImportedNRENL3CoreService.from_subscription(subscription_id) 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] + new_subscription = NRENL3CoreService.from_other_product(old_geant_ip, new_subscription_id) # type: ignore[arg-type] return {"subscription": new_subscription} @workflow("Import GÉANT IP", target=Target.MODIFY, initial_input_form=wrap_modify_initial_input_form(None)) -def import_geant_ip() -> StepList: +def import_nren_l3_core_service() -> StepList: """Modify an ImportedGeantIP subscription into an GeantIP subscription to complete the import.""" return init >> store_process_subscription(Target.MODIFY) >> unsync >> import_geant_ip_subscription >> resync >> done diff --git a/gso/workflows/nren_l3_core_service/migrate_nren_l3_core_service.py b/gso/workflows/nren_l3_core_service/migrate_nren_l3_core_service.py index 55e0bff1eea689579465928bcd90a77668500737..0ab0f28d70efd7a898a6b3311be177a4dab94c8a 100644 --- a/gso/workflows/nren_l3_core_service/migrate_nren_l3_core_service.py +++ b/gso/workflows/nren_l3_core_service/migrate_nren_l3_core_service.py @@ -14,14 +14,14 @@ from pydantic_forms.types import FormGenerator, State, UUIDstr from pydantic_forms.validators import Choice, Divider from gso.products.product_types.edge_port import EdgePort -from gso.products.product_types.nren_l3_core_service import GeantIP +from gso.products.product_types.nren_l3_core_service import NRENL3CoreService from gso.services.subscriptions import get_active_edge_port_subscriptions from gso.utils.types.tt_number import TTNumber def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator: """Gather input from the operator on what new Edge Ports this GÉANT IP should migrate to.""" - subscription = GeantIP.from_subscription(subscription_id) + subscription = NRENL3CoreService.from_subscription(subscription_id) partner_id = subscription.customer_id edge_port_count = len(subscription.geant_ip.geant_ip_ap_list) @@ -54,7 +54,7 @@ def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator: raise ValueError(msg) return edge_ports - class GeantIPEdgePortSelectionForm(FormPage): + class NRENL3CoreServiceEdgePortSelectionForm(FormPage): model_config = ConfigDict(title="Migrating GÉANT IP to a new set of Edge Ports") tt_number: TTNumber @@ -73,13 +73,13 @@ def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator: for ap in subscription.geant_ip.geant_ip_ap_list ] - ep_user_input = yield GeantIPEdgePortSelectionForm + ep_user_input = yield NRENL3CoreServiceEdgePortSelectionForm return {"subscription_id": subscription_id, "subscription": subscription} | ep_user_input.model_dump() @step("Update subscription model") -def update_subscription_model(subscription: GeantIP, edge_port_selection: list[dict]) -> State: +def update_subscription_model(subscription: NRENL3CoreService, edge_port_selection: list[dict]) -> State: """Update the subscription model with the new list of Access Ports.""" for index, selected_port in enumerate(edge_port_selection): subscription.geant_ip.geant_ip_ap_list[index].geant_ip_sbp.edge_port = EdgePort.from_subscription( @@ -94,6 +94,6 @@ def update_subscription_model(subscription: GeantIP, edge_port_selection: list[d initial_input_form=wrap_modify_initial_input_form(initial_input_form_generator), target=Target.MODIFY, ) -def migrate_geant_ip() -> StepList: +def migrate_nren_l3_core_service() -> StepList: """Migrate a GÉANT IP to a new set of Edge Ports.""" return begin >> store_process_subscription(Target.MODIFY) >> unsync >> update_subscription_model >> resync >> done 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 7dad39da3b65ddf91169043d41603d358c373a54..97f538205f215ada2d4259f748f729b8f4964399 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 @@ -1,4 +1,4 @@ -"""A modification workflow for a GÉANT IP subscription.""" +"""A modification workflow for a :term:`NREN` L3 Core Service subscription.""" from typing import Annotated, Any from uuid import uuid4 @@ -18,7 +18,7 @@ from gso.products.product_blocks.bgp_session import BGPSession, IPFamily from gso.products.product_blocks.nren_l3_core_service import NRENAccessPort from gso.products.product_blocks.service_binding_port import VLAN_ID, ServiceBindingPort from gso.products.product_types.edge_port import EdgePort -from gso.products.product_types.nren_l3_core_service import GeantIP +from gso.products.product_types.nren_l3_core_service import NRENL3CoreService from gso.utils.helpers import active_edge_port_selector from gso.utils.shared_enums import APType, SBPType from gso.utils.types.ip_address import IPv4AddressType, IPV4Netmask, IPv6AddressType, IPV6Netmask @@ -26,35 +26,36 @@ from gso.utils.types.ip_address import IPv4AddressType, IPV4Netmask, IPv6Address def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator: """Get input about added, removed, and modified Access Ports.""" - subscription = GeantIP.from_subscription(subscription_id) + subscription = NRENL3CoreService.from_subscription(subscription_id) + product_name = subscription.product.name class AccessPortSelection(BaseModel): - geant_ip_ep: active_edge_port_selector(partner_id=subscription.customer_id) | str # type: ignore[valid-type] - nren_ap_type: APType + edge_port: active_edge_port_selector(partner_id=subscription.customer_id) | str # type: ignore[valid-type] + ap_type: APType def validate_edge_ports_are_unique(access_ports: list[AccessPortSelection]) -> list[AccessPortSelection]: """Verify if interfaces are unique.""" - edge_ports = [str(port.geant_ip_ep) for port in access_ports] + edge_ports = [str(port.edge_port) for port in access_ports] if len(edge_ports) != len(set(edge_ports)): msg = "Edge Ports must be unique." raise ValueError(msg) return access_ports - class ModifyGeantIPAccessPortsForm(FormPage): - model_config = ConfigDict(title="Modify GÉANT IP") + class ModifyAccessPortsForm(FormPage): + model_config = ConfigDict(title=f"Modify {product_name}") access_ports: Annotated[list[AccessPortSelection], AfterValidator(validate_edge_ports_are_unique)] = [ # noqa: RUF012 AccessPortSelection( - geant_ip_ep=str(access_port.geant_ip_sbp.edge_port.owner_subscription_id), - nren_ap_type=access_port.nren_ap_type, + edge_port=str(access_port.sbp.edge_port.owner_subscription_id), + ap_type=access_port.ap_type, ) - for access_port in subscription.geant_ip.geant_ip_ap_list + for access_port in subscription.nren_l3_core_service.nren_ap_list ] - access_port_input = yield ModifyGeantIPAccessPortsForm + access_port_input = yield ModifyAccessPortsForm input_ap_list = access_port_input.access_ports - input_ep_list = [str(ap.geant_ip_ep) for ap in input_ap_list] + input_ep_list = [str(ap.edge_port) for ap in input_ap_list] existing_ep_list = [ - str(ap.geant_ip_sbp.edge_port.owner_subscription_id) for ap in subscription.geant_ip.geant_ip_ap_list + str(ap.sbp.edge_port.owner_subscription_id) for ap in subscription.nren_l3_core_service.nren_ap_list ] class BaseBGPPeer(BaseModel): @@ -89,26 +90,26 @@ def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator: # modified. removed_ap_list = [ access_port.subscription_instance_id - for access_port in subscription.geant_ip.geant_ip_ap_list - if str(access_port.geant_ip_sbp.edge_port.owner_subscription_id) not in input_ep_list + for access_port in subscription.nren_l3_core_service.nren_ap_list + if str(access_port.sbp.edge_port.owner_subscription_id) not in input_ep_list ] modified_ap_list = [ ( access_port, next( ( - ap.nren_ap_type + ap.ap_type for ap in input_ap_list - if str(ap.geant_ip_ep) == str(access_port.geant_ip_sbp.edge_port.owner_subscription_id) + if str(ap.edge_port) == str(access_port.sbp.edge_port.owner_subscription_id) ), None, ), ) - for access_port in subscription.geant_ip.geant_ip_ap_list - if str(access_port.geant_ip_sbp.edge_port.owner_subscription_id) in input_ep_list + for access_port in subscription.nren_l3_core_service.nren_ap_list + if str(access_port.sbp.edge_port.owner_subscription_id) in input_ep_list ] added_ap_list = [ - (ep, next(ap.nren_ap_type for ap in input_ap_list if str(ap.geant_ip_ep) == ep)) + (ep, next(ap.ap_type for ap in input_ap_list if str(ap.edge_port) == ep)) for ep in input_ep_list if ep not in existing_ep_list ] @@ -117,24 +118,25 @@ def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator: sbp_inputs = [] for access_port_index, ap_entry in enumerate(modified_ap_list): access_port, new_ap_type = ap_entry - current_sbp = access_port.geant_ip_sbp - v4_peer = next(peer for peer in current_sbp.sbp_bgp_session_list if IPFamily.V4UNICAST in peer.families) - v6_peer = next(peer for peer in current_sbp.sbp_bgp_session_list if IPFamily.V6UNICAST in peer.families) + current_sbp = access_port.sbp + v4_peer = next(peer for peer in current_sbp.bgp_session_list if IPFamily.V4UNICAST in peer.families) + v6_peer = next(peer for peer in current_sbp.bgp_session_list if IPFamily.V6UNICAST in peer.families) class BindingPortModificationForm(FormPage): model_config = ConfigDict( - title=f"GÉANT IP - Modify Edge Port configuration ({access_port_index + 1}/{len(input_ap_list)})" + title=f"{product_name} - Modify Edge Port configuration " + f"({access_port_index + 1}/{len(input_ap_list)})" ) current_ep_label: Label = Field( - f"Currently configuring on {access_port.geant_ip_sbp.edge_port.description} " - f"(Access Port type: {access_port.nren_ap_type})", + f"Currently configuring on {access_port.sbp.edge_port.edge_port_description} " + f"(Access Port type: {access_port.ap_type})", exclude=True, ) geant_sid: str = current_sbp.geant_sid is_tagged: bool = current_sbp.is_tagged - # The SBP model doesn't require these three fields, but in the case of GÉANT IP this will never occur since - # it's a layer 3 service. The ignore statements are there to put our type checker at ease. + # The SBP model doesn't require these three fields, but in the case of GÉANT IP OR IAS this will never + # occur since it's a layer 3 service. The ignore statements are there to put our type checker at ease. vlan_id: VLAN_ID = current_sbp.vlan_id # type: ignore[assignment] ipv4_address: IPv4AddressType = current_sbp.ipv4_address # type: ignore[assignment] ipv4_mask: IPV4Netmask = current_sbp.ipv4_mask # type: ignore[assignment] @@ -167,7 +169,7 @@ def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator: class BindingPortInputForm(FormPage): model_config = ConfigDict( - title=f"GÉANT IP - Configure new Edge Port " + title=f"{product_name} - Configure new Edge Port " f"({len(modified_ap_list) + ap_index + 1}/{len(input_ap_list)})" ) info_label: Label = Field( @@ -210,11 +212,11 @@ def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator: @step("Clean up removed Edge Ports") -def remove_old_sbp_blocks(subscription: GeantIP, removed_access_ports: list[UUIDstr]) -> State: +def remove_old_sbp_blocks(subscription: NRENL3CoreService, removed_access_ports: list[UUIDstr]) -> State: """Remove old :term:`SBP` product blocks from the GÉANT IP subscription.""" - subscription.geant_ip.geant_ip_ap_list = [ + subscription.nren_l3_core_service.nren_ap_list = [ ap - for ap in subscription.geant_ip.geant_ip_ap_list + for ap in subscription.nren_l3_core_service.nren_ap_list if str(ap.subscription_instance_id) not in removed_access_ports ] @@ -222,55 +224,55 @@ def remove_old_sbp_blocks(subscription: GeantIP, removed_access_ports: list[UUID @step("Modify existing Service Binding Ports") -def modify_existing_sbp_blocks(subscription: GeantIP, modified_sbp_list: list[dict[str, Any]]) -> State: +def modify_existing_sbp_blocks(subscription: NRENL3CoreService, modified_sbp_list: list[dict[str, Any]]) -> State: """Update the subscription model.""" - for access_port in subscription.geant_ip.geant_ip_ap_list: - current_sbp = access_port.geant_ip_sbp + for access_port in subscription.nren_l3_core_service.nren_ap_list: + current_sbp = access_port.sbp modified_sbp_data = next( sbp for sbp in modified_sbp_list if sbp["current_sbp_id"] == str(current_sbp.subscription_instance_id) ) - v4_peer = next(peer for peer in current_sbp.sbp_bgp_session_list if IPFamily.V4UNICAST in peer.families) + v4_peer = next(peer for peer in current_sbp.bgp_session_list if IPFamily.V4UNICAST in peer.families) for attribute in modified_sbp_data["v4_bgp_peer"]: setattr(v4_peer, attribute, modified_sbp_data["v4_bgp_peer"][attribute]) - v6_peer = next(peer for peer in current_sbp.sbp_bgp_session_list if IPFamily.V6UNICAST in peer.families) + v6_peer = next(peer for peer in current_sbp.bgp_session_list if IPFamily.V6UNICAST in peer.families) for attribute in modified_sbp_data["v6_bgp_peer"]: setattr(v6_peer, attribute, modified_sbp_data["v6_bgp_peer"][attribute]) - current_sbp.sbp_bgp_session_list = [v4_peer, v6_peer] + current_sbp.bgp_session_list = [v4_peer, v6_peer] current_sbp.vlan_id = modified_sbp_data["vlan_id"] current_sbp.geant_sid = modified_sbp_data["geant_sid"] current_sbp.is_tagged = modified_sbp_data["is_tagged"] current_sbp.ipv4_address = modified_sbp_data["ipv4_address"] current_sbp.ipv6_address = modified_sbp_data["ipv6_address"] current_sbp.custom_firewall_filters = modified_sbp_data["custom_firewall_filters"] - access_port.nren_ap_type = modified_sbp_data["new_ap_type"] + access_port.ap_type = modified_sbp_data["new_ap_type"] return {"subscription": subscription} @step("Instantiate new Service Binding Ports") -def create_new_sbp_blocks(subscription: GeantIP, added_service_binding_ports: list[dict[str, Any]]) -> State: - """Add new :term:`SBP`s to the GÉANT IP subscription.""" +def create_new_sbp_blocks(subscription: NRENL3CoreService, added_service_binding_ports: list[dict[str, Any]]) -> State: + """Add new :term:`SBP`s to the :term:`NREN` L3 Core Service subscription.""" for sbp_input in added_service_binding_ports: edge_port = EdgePort.from_subscription(sbp_input["edge_port_id"]) - sbp_bgp_session_list = [ + bgp_session_list = [ 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( subscription_id=uuid4(), **sbp_input, - sbp_bgp_session_list=sbp_bgp_session_list, + bgp_session_list=bgp_session_list, sbp_type=SBPType.L3, edge_port=edge_port.edge_port, ) - subscription.geant_ip.geant_ip_ap_list.append( + subscription.nren_l3_core_service.nren_ap_list.append( NRENAccessPort.new( subscription_id=uuid4(), - nren_ap_type=sbp_input["ap_type"], - geant_ip_sbp=service_binding_port, + ap_type=sbp_input["ap_type"], + sbp=service_binding_port, ) ) @@ -278,12 +280,12 @@ def create_new_sbp_blocks(subscription: GeantIP, added_service_binding_ports: li @workflow( - "Modify GÉANT IP", + "Modify :term:`NREN` L3 Core Service", initial_input_form=wrap_modify_initial_input_form(initial_input_form_generator), target=Target.MODIFY, ) -def modify_geant_ip() -> StepList: - """Modify a GÉANT IP subscription.""" +def modify_nren_l3_core_service() -> StepList: + """Modify a NRN L3 Core Service subscription.""" access_ports_are_removed = conditional(lambda state: bool(len(state["removed_access_ports"]) > 0)) access_ports_are_modified = conditional(lambda state: bool(len(state["modified_sbp_list"]) > 0)) access_ports_are_added = conditional(lambda state: bool(len(state["added_service_binding_ports"]) > 0)) diff --git a/test/workflows/geant_ip/test_create_geant_ip.py b/test/workflows/geant_ip/test_create_geant_ip.py index 95d51d9d31aa4fd42550ec5cddac760d33e70b3d..e158b46ea8a51eb75fe4efa8b98a6e4489a10c0a 100644 --- a/test/workflows/geant_ip/test_create_geant_ip.py +++ b/test/workflows/geant_ip/test_create_geant_ip.py @@ -4,7 +4,7 @@ import pytest from orchestrator.types import SubscriptionLifecycle from gso.products import ProductName -from gso.products.product_types.nren_l3_core_service import GeantIP +from gso.products.product_types.nren_l3_core_service import NRENL3CoreService from gso.services.subscriptions import get_product_id_by_name from gso.utils.shared_enums import APType from test.workflows import assert_complete, assert_lso_interaction_success, extract_state, run_workflow @@ -69,7 +69,7 @@ def test_create_geant_ip_success( assert_complete(result) state = extract_state(result) - subscription = GeantIP.from_subscription(state["subscription_id"]) + subscription = NRENL3CoreService.from_subscription(state["subscription_id"]) assert mock_lso_client.call_count == lso_interaction_count assert subscription.status == SubscriptionLifecycle.ACTIVE assert len(subscription.geant_ip.geant_ip_ap_list) == 1 diff --git a/test/workflows/geant_ip/test_create_imported_geant_ip.py b/test/workflows/geant_ip/test_create_imported_geant_ip.py index 87487bc750828b2f0aabe66efc0b9b7d1f4f10c7..ada6b7ddcd0a3144b18155a8a07f6b0d6d977d11 100644 --- a/test/workflows/geant_ip/test_create_imported_geant_ip.py +++ b/test/workflows/geant_ip/test_create_imported_geant_ip.py @@ -1,7 +1,7 @@ import pytest from orchestrator.types import SubscriptionLifecycle -from gso.products import ImportedGeantIP +from gso.products import ImportedNRENL3CoreService from gso.products.product_blocks.bgp_session import IPFamily from gso.utils.shared_enums import SBPType from test.workflows import assert_complete, extract_state, run_workflow @@ -62,6 +62,6 @@ def imported_geant_ip_creation_input_form_data(edge_port_subscription_factory, p def test_create_imported_geant_ip_success(faker, imported_geant_ip_creation_input_form_data): result, _, _ = run_workflow("create_imported_geant_ip", [imported_geant_ip_creation_input_form_data]) state = extract_state(result) - subscription = ImportedGeantIP.from_subscription(state["subscription_id"]) + subscription = ImportedNRENL3CoreService.from_subscription(state["subscription_id"]) assert_complete(result) assert subscription.status == SubscriptionLifecycle.ACTIVE diff --git a/test/workflows/geant_ip/test_import_geant_ip.py b/test/workflows/geant_ip/test_import_geant_ip.py index cac68c2fdc08f06c51d2376e6e58956183eb3c2a..55ce0cce1b5bb31dba7dec48e0fdeab9b8e25bf2 100644 --- a/test/workflows/geant_ip/test_import_geant_ip.py +++ b/test/workflows/geant_ip/test_import_geant_ip.py @@ -1,7 +1,7 @@ import pytest from orchestrator.types import SubscriptionLifecycle -from gso.products import GeantIP, ProductName +from gso.products import NRENL3CoreService, ProductName from test.workflows import assert_complete, run_workflow @@ -9,7 +9,7 @@ from test.workflows import assert_complete, run_workflow def test_import_edge_port_success(geant_ip_subscription_factory): imported_geant_ip = geant_ip_subscription_factory(is_imported=False) result, _, _ = run_workflow("import_geant_ip", [{"subscription_id": imported_geant_ip}]) - subscription = GeantIP.from_subscription(imported_geant_ip) + subscription = NRENL3CoreService.from_subscription(imported_geant_ip) assert_complete(result) assert subscription.product.name == ProductName.GEANT_IP diff --git a/test/workflows/geant_ip/test_migrate_geant_ip.py b/test/workflows/geant_ip/test_migrate_geant_ip.py index 95eaf15a5d0109fb3f6a12e50119d3cc8fea26a5..949082a235353676b5b8f7c9bd6dc01ed76ad0ec 100644 --- a/test/workflows/geant_ip/test_migrate_geant_ip.py +++ b/test/workflows/geant_ip/test_migrate_geant_ip.py @@ -1,6 +1,6 @@ import pytest -from gso.products.product_types.nren_l3_core_service import GeantIP +from gso.products.product_types.nren_l3_core_service import NRENL3CoreService from test.workflows import assert_complete, extract_state, run_workflow @@ -12,7 +12,7 @@ def test_migrate_geant_ip_success( subscription_id = geant_ip_subscription_factory(partner=partner) new_edge_port_1 = edge_port_subscription_factory(partner=partner) new_edge_port_2 = edge_port_subscription_factory(partner=partner) - subscription = GeantIP.from_subscription(subscription_id) + subscription = NRENL3CoreService.from_subscription(subscription_id) form_input_data = [ {"subscription_id": subscription_id}, @@ -35,7 +35,7 @@ def test_migrate_geant_ip_success( assert_complete(result) state = extract_state(result) - subscription = GeantIP.from_subscription(state["subscription_id"]) + subscription = NRENL3CoreService.from_subscription(state["subscription_id"]) assert subscription.insync assert len(subscription.geant_ip.geant_ip_ap_list) == 2 assert ( diff --git a/test/workflows/geant_ip/test_modify_geant_ip.py b/test/workflows/geant_ip/test_modify_geant_ip.py index 99a9f30cf99bbf84908d25316428756d65dc75cb..0cd7f24a3cd83dc3ce9c36e3cbbeec86d3d4ebdc 100644 --- a/test/workflows/geant_ip/test_modify_geant_ip.py +++ b/test/workflows/geant_ip/test_modify_geant_ip.py @@ -1,7 +1,7 @@ import pytest from gso.products.product_blocks.bgp_session import IPFamily -from gso.products.product_types.nren_l3_core_service import GeantIP +from gso.products.product_types.nren_l3_core_service import NRENL3CoreService from gso.utils.shared_enums import APType from test.workflows import extract_state, run_workflow @@ -9,7 +9,7 @@ from test.workflows import extract_state, run_workflow @pytest.mark.workflow() def test_modify_geant_ip_remove_edge_port_success(geant_ip_subscription_factory): subscription_id = geant_ip_subscription_factory() - subscription = GeantIP.from_subscription(subscription_id) + subscription = NRENL3CoreService.from_subscription(subscription_id) access_port = subscription.geant_ip.geant_ip_ap_list[0] input_form_data = [ {"subscription_id": subscription_id}, @@ -27,7 +27,7 @@ def test_modify_geant_ip_remove_edge_port_success(geant_ip_subscription_factory) result, _, _ = run_workflow("modify_geant_ip", input_form_data) state = extract_state(result) - subscription = GeantIP.from_subscription(state["subscription_id"]) + subscription = NRENL3CoreService.from_subscription(state["subscription_id"]) assert len(subscription.geant_ip.geant_ip_ap_list) == 1 assert subscription.geant_ip.geant_ip_ap_list[0].nren_ap_type == APType.LOAD_BALANCED @@ -39,7 +39,7 @@ def test_modify_geant_ip_add_new_edge_port_success( partner = partner_factory() new_edge_port = edge_port_subscription_factory(partner=partner) subscription_id = geant_ip_subscription_factory(partner=partner) - subscription = GeantIP.from_subscription(subscription_id) + subscription = NRENL3CoreService.from_subscription(subscription_id) input_form_data = [ {"subscription_id": subscription_id}, { @@ -78,14 +78,14 @@ def test_modify_geant_ip_add_new_edge_port_success( result, _, _ = run_workflow("modify_geant_ip", input_form_data) state = extract_state(result) - subscription = GeantIP.from_subscription(state["subscription_id"]) + subscription = NRENL3CoreService.from_subscription(state["subscription_id"]) assert len(subscription.geant_ip.geant_ip_ap_list) == 3 @pytest.mark.workflow() def test_modify_geant_ip_modify_edge_port_success(faker, geant_ip_subscription_factory): subscription_id = geant_ip_subscription_factory() - subscription = GeantIP.from_subscription(subscription_id) + subscription = NRENL3CoreService.from_subscription(subscription_id) new_sbp_data = [ { "geant_sid": faker.geant_sid(), @@ -171,7 +171,7 @@ def test_modify_geant_ip_modify_edge_port_success(faker, geant_ip_subscription_f result, _, _ = run_workflow("modify_geant_ip", input_form_data) state = extract_state(result) - subscription = GeantIP.from_subscription(state["subscription_id"]) + subscription = NRENL3CoreService.from_subscription(state["subscription_id"]) assert len(subscription.geant_ip.geant_ip_ap_list) == 2 for i in range(2):