diff --git a/migrations/versions/schema/2023-03-08_431ca061b2ad_add_products_for_trunk_service.py b/migrations/versions/schema/2023-03-08_431ca061b2ad_add_products_for_trunk_service.py new file mode 100644 index 0000000000000000000000000000000000000000..1e8465f881d21ebe166c8012a2f00789543cdc57 --- /dev/null +++ b/migrations/versions/schema/2023-03-08_431ca061b2ad_add_products_for_trunk_service.py @@ -0,0 +1,302 @@ +"""Add products for trunk service. + +Revision ID: 431ca061b2ad +Revises: +Create Date: 2023-03-08 19:21:13.139851 + +""" +import sqlalchemy as sa +from alembic import op + +# revision identifiers, used by Alembic. +revision = '431ca061b2ad' +down_revision = None +branch_labels = ('data',) +depends_on = 'bed6bc0b197a' + + +def upgrade() -> None: + conn = op.get_bind() + conn.execute(""" +INSERT INTO products (name, description, product_type, tag, status) VALUES ('Trunk', 'A representation of a core link (IP-TRUNK) between two Geant Routers', 'Trunk', 'TRUNK', 'active') RETURNING products.product_id + """) + conn.execute(""" +INSERT INTO products (name, description, product_type, tag, status) VALUES ('Trunk Config', 'The configuration attributes for the trunk', 'TrunkConfig', 'TRUNK_C', 'active') RETURNING products.product_id + """) + conn.execute(""" +INSERT INTO products (name, description, product_type, tag, status) VALUES ('Trunk Config Common', 'The configuration attributes common between A side and B side', 'TrunkConfigCommon', 'TRUNK_CC', 'active') RETURNING products.product_id + """) + conn.execute(""" +INSERT INTO products (name, description, product_type, tag, status) VALUES ('Trunk Config Side', 'The configuration attributes necessary for a side', 'TrunkConfigSide', 'TRUNK_CS', 'active') RETURNING products.product_id + """) + conn.execute(""" +INSERT INTO product_blocks (name, description, tag, status) VALUES ('Trunk Block', 'trunk block', 'TRUNK_B', 'active') RETURNING product_blocks.product_block_id + """) + conn.execute(""" +INSERT INTO product_blocks (name, description, tag, status) VALUES ('Trunk Config Block', 'trunk config block', 'TRUNK_CB', 'active') RETURNING product_blocks.product_block_id + """) + conn.execute(""" +INSERT INTO product_blocks (name, description, tag, status) VALUES ('Trunk Config Common Block', 'trunk config common block', 'TRUNK_CCB', 'active') RETURNING product_blocks.product_block_id + """) + conn.execute(""" +INSERT INTO product_blocks (name, description, tag, status) VALUES ('Trunk Config Side Block', 'trunk config side block', 'TRUNK_CSB', 'active') RETURNING product_blocks.product_block_id + """) + conn.execute(""" +INSERT INTO resource_types (resource_type, description) VALUES ('members', 'The list of members of the AE') RETURNING resource_types.resource_type_id + """) + conn.execute(""" +INSERT INTO resource_types (resource_type, description) VALUES ('speed', 'The speed of the members') RETURNING resource_types.resource_type_id + """) + conn.execute(""" +INSERT INTO resource_types (resource_type, description) VALUES ('trunk_id', 'The identifier of the trunk') RETURNING resource_types.resource_type_id + """) + conn.execute(""" +INSERT INTO resource_types (resource_type, description) VALUES ('geant_a_sid', 'The Geant Access Port service ID') RETURNING resource_types.resource_type_id + """) + conn.execute(""" +INSERT INTO resource_types (resource_type, description) VALUES ('fqdn', 'The FQDN of the router') RETURNING resource_types.resource_type_id + """) + conn.execute(""" +INSERT INTO resource_types (resource_type, description) VALUES ('ae_name', 'The name of the Aggregated Ethernet') RETURNING resource_types.resource_type_id + """) + conn.execute(""" +INSERT INTO resource_types (resource_type, description) VALUES ('ipv6_address', 'The IPv6 address of the interface') RETURNING resource_types.resource_type_id + """) + conn.execute(""" +INSERT INTO resource_types (resource_type, description) VALUES ('trunk_config_common_id', 'ID of the object that contains the configuration attributes common between A side and B side') RETURNING resource_types.resource_type_id + """) + conn.execute(""" +INSERT INTO resource_types (resource_type, description) VALUES ('isis_metric', 'The ISIS metric of the link') RETURNING resource_types.resource_type_id + """) + conn.execute(""" +INSERT INTO resource_types (resource_type, description) VALUES ('is_leased_line', 'A switch to identify if the link is on leased capacity') RETURNING resource_types.resource_type_id + """) + conn.execute(""" +INSERT INTO resource_types (resource_type, description) VALUES ('minimum_links', 'The minimum links number for the LAG') RETURNING resource_types.resource_type_id + """) + conn.execute(""" +INSERT INTO resource_types (resource_type, description) VALUES ('geant_s_sid', 'The Geant Service Identifier for the trunk') RETURNING resource_types.resource_type_id + """) + conn.execute(""" +INSERT INTO resource_types (resource_type, description) VALUES ('trunk_config_side_id', 'ID of the object that contains the configuration attributes necessary for a side') RETURNING resource_types.resource_type_id + """) + conn.execute(""" +INSERT INTO resource_types (resource_type, description) VALUES ('ipv4_address', 'The IPv4 address of the interface') RETURNING resource_types.resource_type_id + """) + conn.execute(""" +INSERT INTO resource_types (resource_type, description) VALUES ('trunk_name', 'The name of the trunk') RETURNING resource_types.resource_type_id + """) + conn.execute(""" +INSERT INTO resource_types (resource_type, description) VALUES ('trunk_config_id', 'ID of the object that contains the configuration attributes for the trunk') 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 ('Trunk')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('Trunk Block'))) + """) + conn.execute(""" +INSERT INTO product_product_blocks (product_id, product_block_id) VALUES ((SELECT products.product_id FROM products WHERE products.name IN ('Trunk Config')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('Trunk Config Block'))) + """) + conn.execute(""" +INSERT INTO product_product_blocks (product_id, product_block_id) VALUES ((SELECT products.product_id FROM products WHERE products.name IN ('Trunk Config Common')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('Trunk Config Common Block'))) + """) + conn.execute(""" +INSERT INTO product_product_blocks (product_id, product_block_id) VALUES ((SELECT products.product_id FROM products WHERE products.name IN ('Trunk Config Side')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('Trunk Config Side Block'))) + """) + conn.execute(""" +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 ('Trunk Config Block')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('Trunk Block'))) + """) + conn.execute(""" +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 ('Trunk Config Side Block')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('Trunk Config Block'))), ((SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('Trunk Config Common Block')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('Trunk Config Block'))) + """) + 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 ('Trunk Block')), (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('trunk_id'))) + """) + 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 ('Trunk Block')), (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 ('Trunk Block')), (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('trunk_name'))) + """) + 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 ('Trunk Config Block')), (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('trunk_config_id'))) + """) + 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 ('Trunk Config Common Block')), (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('trunk_config_common_id'))) + """) + 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 ('Trunk Config Common Block')), (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('speed'))) + """) + 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 ('Trunk Config Common Block')), (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('is_leased_line'))) + """) + 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 ('Trunk Config Common Block')), (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('isis_metric'))) + """) + 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 ('Trunk Config Common Block')), (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('minimum_links'))) + """) + 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 ('Trunk Config Side Block')), (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('trunk_config_side_id'))) + """) + 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 ('Trunk Config Side Block')), (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('fqdn'))) + """) + 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 ('Trunk Config Side Block')), (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('ae_name'))) + """) + 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 ('Trunk Config Side Block')), (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('geant_a_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 ('Trunk Config Side Block')), (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('ipv4_address'))) + """) + 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 ('Trunk Config Side Block')), (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('ipv6_address'))) + """) + 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 ('Trunk Config Side Block')), (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('members'))) + """) + + +def downgrade() -> None: + conn = op.get_bind() + 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 ('Trunk Block')) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('trunk_id')) + """) + 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 ('Trunk Block'))) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('trunk_id')) + """) + 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 ('Trunk Block')) 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 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 ('Trunk Block'))) 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 ('Trunk Block')) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('trunk_name')) + """) + 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 ('Trunk Block'))) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('trunk_name')) + """) + 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 ('Trunk Config Block')) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('trunk_config_id')) + """) + 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 ('Trunk Config Block'))) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('trunk_config_id')) + """) + 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 ('Trunk Config Common Block')) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('trunk_config_common_id')) + """) + 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 ('Trunk Config Common Block'))) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('trunk_config_common_id')) + """) + 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 ('Trunk Config Common Block')) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('speed')) + """) + 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 ('Trunk Config Common Block'))) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('speed')) + """) + 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 ('Trunk Config Common Block')) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('is_leased_line')) + """) + 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 ('Trunk Config Common Block'))) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('is_leased_line')) + """) + 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 ('Trunk Config Common Block')) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('isis_metric')) + """) + 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 ('Trunk Config Common Block'))) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('isis_metric')) + """) + 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 ('Trunk Config Common Block')) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('minimum_links')) + """) + 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 ('Trunk Config Common Block'))) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('minimum_links')) + """) + 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 ('Trunk Config Side Block')) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('trunk_config_side_id')) + """) + 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 ('Trunk Config Side Block'))) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('trunk_config_side_id')) + """) + 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 ('Trunk Config Side Block')) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('fqdn')) + """) + 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 ('Trunk Config Side Block'))) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('fqdn')) + """) + 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 ('Trunk Config Side Block')) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('ae_name')) + """) + 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 ('Trunk Config Side Block'))) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('ae_name')) + """) + 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 ('Trunk Config Side Block')) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('geant_a_sid')) + """) + 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 ('Trunk Config Side Block'))) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('geant_a_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 ('Trunk Config Side Block')) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('ipv4_address')) + """) + 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 ('Trunk Config Side Block'))) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('ipv4_address')) + """) + 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 ('Trunk Config Side Block')) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('ipv6_address')) + """) + 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 ('Trunk Config Side Block'))) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('ipv6_address')) + """) + 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 ('Trunk Config Side Block')) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('members')) + """) + 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 ('Trunk Config Side Block'))) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('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 ('members', 'speed', 'trunk_id', 'geant_a_sid', 'fqdn', 'ae_name', 'ipv6_address', 'trunk_config_common_id', 'isis_metric', 'is_leased_line', 'minimum_links', 'geant_s_sid', 'trunk_config_side_id', 'ipv4_address', 'trunk_name', 'trunk_config_id')) + """) + conn.execute(""" +DELETE FROM resource_types WHERE resource_types.resource_type IN ('members', 'speed', 'trunk_id', 'geant_a_sid', 'fqdn', 'ae_name', 'ipv6_address', 'trunk_config_common_id', 'isis_metric', 'is_leased_line', 'minimum_links', 'geant_s_sid', 'trunk_config_side_id', 'ipv4_address', 'trunk_name', 'trunk_config_id') + """) + conn.execute(""" +DELETE FROM product_product_blocks WHERE product_product_blocks.product_id IN (SELECT products.product_id FROM products WHERE products.name IN ('Trunk')) AND product_product_blocks.product_block_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('Trunk Block')) + """) + conn.execute(""" +DELETE FROM product_product_blocks WHERE product_product_blocks.product_id IN (SELECT products.product_id FROM products WHERE products.name IN ('Trunk Config')) AND product_product_blocks.product_block_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('Trunk Config Block')) + """) + conn.execute(""" +DELETE FROM product_product_blocks WHERE product_product_blocks.product_id IN (SELECT products.product_id FROM products WHERE products.name IN ('Trunk Config Common')) AND product_product_blocks.product_block_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('Trunk Config Common Block')) + """) + conn.execute(""" +DELETE FROM product_product_blocks WHERE product_product_blocks.product_id IN (SELECT products.product_id FROM products WHERE products.name IN ('Trunk Config Side')) AND product_product_blocks.product_block_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('Trunk Config Side Block')) + """) + conn.execute(""" +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 ('Trunk Config Block')) AND product_block_relations.depends_on_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('Trunk Block')) + """) + conn.execute(""" +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 ('Trunk Config Side Block', 'Trunk Config Common Block')) AND product_block_relations.depends_on_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('Trunk Config Block')) + """) + conn.execute(""" +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 ('Trunk Config Block', 'Trunk Block', 'Trunk Config Side Block', 'Trunk Config Common Block')) + """) + conn.execute(""" +DELETE FROM product_blocks WHERE product_blocks.name IN ('Trunk Config Block', 'Trunk Block', 'Trunk Config Side Block', 'Trunk Config Common Block') + """) + conn.execute(""" +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 ('Trunk Config Common', 'Trunk', 'Trunk Config Side', 'Trunk Config')))) + """) + conn.execute(""" +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 ('Trunk Config Common', 'Trunk', 'Trunk Config Side', 'Trunk Config'))) + """) + conn.execute(""" +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 ('Trunk Config Common', 'Trunk', 'Trunk Config Side', 'Trunk Config'))) + """) + conn.execute(""" +DELETE FROM subscriptions WHERE subscriptions.product_id IN (SELECT products.product_id FROM products WHERE products.name IN ('Trunk Config Common', 'Trunk', 'Trunk Config Side', 'Trunk Config')) + """) + conn.execute(""" +DELETE FROM products WHERE products.name IN ('Trunk Config Common', 'Trunk', 'Trunk Config Side', 'Trunk Config') + """)