Skip to content
Snippets Groups Projects
Commit fcce4fd8 authored by Simone Spinelli's avatar Simone Spinelli
Browse files

New Iptrunk model

parent 1c5c3646
No related branches found
No related tags found
1 merge request!8Feature/iptrunks prototype
"""add Iptrunk create workflow.
"""add IPtrunk create workflows.
Revision ID: d3616a686094
Revises: 42d52099c7da
Create Date: 2023-04-21 12:22:18.243625
Revision ID: 37a3dcdcb110
Revises: e13448650548
Create Date: 2023-04-24 13:19:58.545357
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = 'd3616a686094'
down_revision = '42d52099c7da'
revision = '37a3dcdcb110'
down_revision = 'e13448650548'
branch_labels = None
depends_on = None
......
"""Add Iptrunk product.
Revision ID: 42d52099c7da
Revision ID: e13448650548
Revises: 857225661207
Create Date: 2023-04-21 12:04:20.186345
Create Date: 2023-04-24 13:16:38.724103
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = '42d52099c7da'
revision = 'e13448650548'
down_revision = '857225661207'
branch_labels = None
depends_on = None
......@@ -21,49 +21,49 @@ def upgrade() -> None:
INSERT INTO products (name, description, product_type, tag, status) VALUES ('Iptrunk', 'A core link', 'Iptrunk', 'IPTRUNK', 'active') RETURNING products.product_id
""")
conn.execute("""
INSERT INTO fixed_inputs (name, value, product_id) VALUES ('iptrunk_type', 'Leased line vs dark fiber', (SELECT products.product_id FROM products WHERE products.name IN ('Iptrunk')))
INSERT INTO product_blocks (name, description, tag, status) VALUES ('IptrunkBlock', 'IP trunk block', 'IPTRUNK', 'active') RETURNING product_blocks.product_block_id
""")
conn.execute("""
INSERT INTO product_blocks (name, description, tag, status) VALUES ('IptrunkBlock', 'An IPtrunk', 'IPTRUNK', 'active') RETURNING product_blocks.product_block_id
INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_sideB_fqdn', 'FQDN side B') RETURNING resource_types.resource_type_id
""")
conn.execute("""
INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_ipv4_network', 'The IPv4 network to be used on the trunk') RETURNING resource_types.resource_type_id
INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_speed', 'Speed of trunk members') RETURNING resource_types.resource_type_id
""")
conn.execute("""
INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_sideB_ae_iface', 'AE interface name on B side') RETURNING resource_types.resource_type_id
INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_sideB_ae_iface', 'AE side B') RETURNING resource_types.resource_type_id
""")
conn.execute("""
INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_sideB_ae_members', 'Members of AE interface on B side') RETURNING resource_types.resource_type_id
INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_sideB_ae_geant_a_sid', 'GA-SID side B') RETURNING resource_types.resource_type_id
""")
conn.execute("""
INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_sideA_fqdn', 'Name of the router on A side') RETURNING resource_types.resource_type_id
INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_type', 'leased vs darkfiber') RETURNING resource_types.resource_type_id
""")
conn.execute("""
INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_minimum_links', 'Minimum links of the trunk') RETURNING resource_types.resource_type_id
INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_sideA_ae_geant_a_sid', 'GA-SID side A') RETURNING resource_types.resource_type_id
""")
conn.execute("""
INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_sideB_fqdn', 'Name of the router on B side') RETURNING resource_types.resource_type_id
INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_ipv4_network', 'IPv4 network for the trunk') RETURNING resource_types.resource_type_id
""")
conn.execute("""
INSERT INTO resource_types (resource_type, description) VALUES ('geant_s_sid', 'Geant Service ID') RETURNING resource_types.resource_type_id
INSERT INTO resource_types (resource_type, description) VALUES ('geant_s_sid', 'GS SID for trunk') RETURNING resource_types.resource_type_id
""")
conn.execute("""
INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_sideA_ae_geant_a_sid', 'Geant Access port ID on A side') RETURNING resource_types.resource_type_id
INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_ipv6_network', 'IPv6 network for the trunk') RETURNING resource_types.resource_type_id
""")
conn.execute("""
INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_speed', 'Speed of the members of the trunk') RETURNING resource_types.resource_type_id
INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_sideA_ae_iface', 'AE side A') RETURNING resource_types.resource_type_id
""")
conn.execute("""
INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_ipv6_network', 'The IPv6 network to be used on the trunk') RETURNING resource_types.resource_type_id
INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_sideA_fqdn', 'FQDN side A') RETURNING resource_types.resource_type_id
""")
conn.execute("""
INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_sideB_ae_geant_a_sid', 'Geant Access port ID on B side') RETURNING resource_types.resource_type_id
INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_minimum_links', 'minimum links') RETURNING resource_types.resource_type_id
""")
conn.execute("""
INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_sideA_ae_iface', 'AE interface name on A side') RETURNING resource_types.resource_type_id
INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_sideB_ae_members', 'side B members') RETURNING resource_types.resource_type_id
""")
conn.execute("""
INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_sideA_ae_members', 'Members of AE interface on A side') RETURNING resource_types.resource_type_id
INSERT INTO resource_types (resource_type, description) VALUES ('iptrunk_sideA_ae_members', 'side A members') RETURNING resource_types.resource_type_id
""")
conn.execute("""
INSERT INTO product_product_blocks (product_id, product_block_id) VALUES ((SELECT products.product_id FROM products WHERE products.name IN ('Iptrunk')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('IptrunkBlock')))
......@@ -72,6 +72,9 @@ INSERT INTO product_product_blocks (product_id, product_block_id) VALUES ((SELEC
INSERT INTO product_block_resource_types (product_block_id, resource_type_id) VALUES ((SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('IptrunkBlock')), (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('geant_s_sid')))
""")
conn.execute("""
INSERT INTO product_block_resource_types (product_block_id, resource_type_id) VALUES ((SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('IptrunkBlock')), (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('iptrunk_type')))
""")
conn.execute("""
INSERT INTO product_block_resource_types (product_block_id, resource_type_id) VALUES ((SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('IptrunkBlock')), (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('iptrunk_speed')))
""")
conn.execute("""
......@@ -118,6 +121,12 @@ DELETE FROM product_block_resource_types WHERE product_block_resource_types.prod
DELETE FROM subscription_instance_values USING product_block_resource_types WHERE subscription_instance_values.subscription_instance_id IN (SELECT subscription_instances.subscription_instance_id FROM subscription_instances WHERE subscription_instances.subscription_instance_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('IptrunkBlock'))) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('geant_s_sid'))
""")
conn.execute("""
DELETE FROM product_block_resource_types WHERE product_block_resource_types.product_block_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('IptrunkBlock')) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('iptrunk_type'))
""")
conn.execute("""
DELETE FROM subscription_instance_values USING product_block_resource_types WHERE subscription_instance_values.subscription_instance_id IN (SELECT subscription_instances.subscription_instance_id FROM subscription_instances WHERE subscription_instances.subscription_instance_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('IptrunkBlock'))) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('iptrunk_type'))
""")
conn.execute("""
DELETE FROM product_block_resource_types WHERE product_block_resource_types.product_block_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('IptrunkBlock')) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('iptrunk_speed'))
""")
conn.execute("""
......@@ -190,18 +199,15 @@ DELETE FROM product_block_resource_types WHERE product_block_resource_types.prod
DELETE FROM subscription_instance_values USING product_block_resource_types WHERE subscription_instance_values.subscription_instance_id IN (SELECT subscription_instances.subscription_instance_id FROM subscription_instances WHERE subscription_instances.subscription_instance_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('IptrunkBlock'))) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('iptrunk_sideB_ae_members'))
""")
conn.execute("""
DELETE FROM subscription_instance_values WHERE subscription_instance_values.resource_type_id IN (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('iptrunk_ipv4_network', 'iptrunk_sideB_ae_iface', 'iptrunk_sideB_ae_members', 'iptrunk_sideA_fqdn', 'iptrunk_minimum_links', 'iptrunk_sideB_fqdn', 'geant_s_sid', 'iptrunk_sideA_ae_geant_a_sid', 'iptrunk_speed', 'iptrunk_ipv6_network', 'iptrunk_sideB_ae_geant_a_sid', 'iptrunk_sideA_ae_iface', 'iptrunk_sideA_ae_members'))
DELETE FROM subscription_instance_values WHERE subscription_instance_values.resource_type_id IN (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('iptrunk_sideB_fqdn', 'iptrunk_speed', 'iptrunk_sideB_ae_iface', 'iptrunk_sideB_ae_geant_a_sid', 'iptrunk_type', 'iptrunk_sideA_ae_geant_a_sid', 'iptrunk_ipv4_network', 'geant_s_sid', 'iptrunk_ipv6_network', 'iptrunk_sideA_ae_iface', 'iptrunk_sideA_fqdn', 'iptrunk_minimum_links', 'iptrunk_sideB_ae_members', 'iptrunk_sideA_ae_members'))
""")
conn.execute("""
DELETE FROM resource_types WHERE resource_types.resource_type IN ('iptrunk_ipv4_network', 'iptrunk_sideB_ae_iface', 'iptrunk_sideB_ae_members', 'iptrunk_sideA_fqdn', 'iptrunk_minimum_links', 'iptrunk_sideB_fqdn', 'geant_s_sid', 'iptrunk_sideA_ae_geant_a_sid', 'iptrunk_speed', 'iptrunk_ipv6_network', 'iptrunk_sideB_ae_geant_a_sid', 'iptrunk_sideA_ae_iface', 'iptrunk_sideA_ae_members')
DELETE FROM resource_types WHERE resource_types.resource_type IN ('iptrunk_sideB_fqdn', 'iptrunk_speed', 'iptrunk_sideB_ae_iface', 'iptrunk_sideB_ae_geant_a_sid', 'iptrunk_type', 'iptrunk_sideA_ae_geant_a_sid', 'iptrunk_ipv4_network', 'geant_s_sid', 'iptrunk_ipv6_network', 'iptrunk_sideA_ae_iface', 'iptrunk_sideA_fqdn', 'iptrunk_minimum_links', 'iptrunk_sideB_ae_members', 'iptrunk_sideA_ae_members')
""")
conn.execute("""
DELETE FROM product_product_blocks WHERE product_product_blocks.product_id IN (SELECT products.product_id FROM products WHERE products.name IN ('Iptrunk')) AND product_product_blocks.product_block_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('IptrunkBlock'))
""")
conn.execute("""
DELETE FROM fixed_inputs WHERE fixed_inputs.product_id IN (SELECT products.product_id FROM products WHERE products.name IN ('Iptrunk')) AND fixed_inputs.name = 'iptrunk_type'
""")
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 ('IptrunkBlock'))
""")
conn.execute("""
......
from typing import Optional
from orchestrator.domain.base import ProductBlockModel
from orchestrator.types import SubscriptionLifecycle
from orchestrator.types import SubscriptionLifecycle, strEnum
import ipaddress
# - id: GS-00012
......@@ -30,10 +30,15 @@ import ipaddress
# port_id: GA-01834
class IptrunkType(strEnum):
Dark_fiber = "Dark_fiber"
Leased = "Leased"
class IptrunkBlockInactive(ProductBlockModel,
lifecycle=[SubscriptionLifecycle.INITIAL],
product_block_name="IptrunkBlock"):
geant_s_sid: Optional[str] = None
iptrunk_type: Optional[IptrunkType] = None
iptrunk_speed: Optional[str] = None
iptrunk_minimum_links: Optional[int] = None
iptrunk_ipv4_network: Optional[ipaddress.IPv4Network] = None
......@@ -53,6 +58,7 @@ class IptrunkBlockInactive(ProductBlockModel,
class IptrunkBlockProvisioning(IptrunkBlockInactive,
lifecycle=[SubscriptionLifecycle.PROVISIONING]):
geant_s_sid: Optional[str] = None
iptrunk_type: Optional[IptrunkType] = None
iptrunk_speed: Optional[str] = None
iptrunk_minimum_links: Optional[int] = None
iptrunk_ipv4_network: Optional[ipaddress.IPv4Network] = None
......@@ -72,6 +78,7 @@ class IptrunkBlockProvisioning(IptrunkBlockInactive,
class IptrunkBlock(IptrunkBlockProvisioning,
lifecycle=[SubscriptionLifecycle.ACTIVE]):
geant_s_sid: str
iptrunk_type: IptrunkType
iptrunk_speed: str
iptrunk_minimum_links: int
iptrunk_ipv4_network: ipaddress.IPv4Network
......
......@@ -5,22 +5,15 @@ from gso.products.product_blocks.iptrunk \
import IptrunkBlock, IptrunkBlockInactive, IptrunkBlockProvisioning
class IptrunkType(strEnum):
Dark_fiber = "Dark_fiber"
Leased = "Leased"
class IptrunkInactive(SubscriptionModel, is_base=True):
iptrunk_type: IptrunkType
iptrunk: IptrunkBlockInactive
class IptrunkProvisioning(IptrunkInactive,
lifecycle=[SubscriptionLifecycle.PROVISIONING]):
iptrunk_type: IptrunkType
iptrunk: IptrunkBlockProvisioning
class Iptrunk(IptrunkProvisioning, lifecycle=[SubscriptionLifecycle.ACTIVE]):
iptrunk_type: IptrunkType
iptrunk: IptrunkBlock
......@@ -46,7 +46,6 @@ def initial_input_form_generator(product_name: str) -> FormGenerator:
title = product_name
geant_s_sid: str
iptrunk_type: iptrunk.IptrunkType
iptrunk_speed: str # This should be an enum: 1/10/100/400
iptrunk_minimum_links: int
......@@ -94,7 +93,6 @@ def get_info_from_ipam(subscription: iptrunk.IptrunkInactive) -> State:
def initialize_subscription(
subscription: iptrunk.IptrunkInactive,
geant_s_sid: str,
iptrunk_type: iptrunk.IptrunkType,
iptrunk_speed: str,
iptrunk_minimum_links: int,
iptrunk_sideA_fqdn: str,
......@@ -106,7 +104,7 @@ def initialize_subscription(
iptrunk_sideB_ae_geant_a_sid: str,
iptrunk_sideB_ae_members: list[str]
) -> State:
subscription.iptrunk_type = iptrunk_type
# subscription.iptrunk_type = iptrunk_type
subscription.iptrunk.geant_s_sid = geant_s_sid
subscription.iptrunk.iptrunk_speed = iptrunk_speed
......@@ -224,7 +222,7 @@ def create_iptrunk():
return (
init
>> create_subscription
#>> store_process_subscription(Target.CREATE)
>> store_process_subscription(Target.CREATE)
#>> get_info_from_ipam
#>> get_snmp_info
#>> initialize_subscription
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment