Skip to content
Snippets Groups Projects
Verified Commit 8bfc7658 authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

Update domain model for BGP session

parent 3c5499a3
No related branches found
No related tags found
1 merge request!286Add Edge Port, GÉANT IP and IAS products
This commit is part of merge request !286. Comments created here will be created in the context of that merge request.
"""Add passive boolean to BGP session model.
Revision ID: c3e98d657b36
Revises: f900cbaa47d7
Create Date: 2024-09-25 14:05:57.072597
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = 'c3e98d657b36'
down_revision = 'f900cbaa47d7'
branch_labels = None
depends_on = None
def upgrade() -> None:
conn = op.get_bind()
conn.execute(sa.text("""
INSERT INTO resource_types (resource_type, description) VALUES ('is_passive', 'This BGP session is passive') RETURNING resource_types.resource_type_id
"""))
conn.execute(sa.text("""
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 ('BGPSession')), (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('is_passive')))
"""))
def downgrade() -> None:
conn = op.get_bind()
conn.execute(sa.text("""
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 ('BGPSession')) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('is_passive'))
"""))
conn.execute(sa.text("""
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 ('is_passive'))
"""))
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 ('is_passive'))
"""))
conn.execute(sa.text("""
DELETE FROM resource_types WHERE resource_types.resource_type IN ('is_passive')
"""))
......@@ -32,6 +32,7 @@ class BGPSessionInactive(ProductBlockModel, lifecycle=[SubscriptionLifecycle.INI
multipath_enabled: bool | None = None
send_default_route: bool | None = None
is_multi_hop: bool = False
is_passive: bool = False
class BGPSessionProvisioning(BGPSessionInactive, lifecycle=[SubscriptionLifecycle.PROVISIONING]):
......@@ -47,6 +48,7 @@ class BGPSessionProvisioning(BGPSessionInactive, lifecycle=[SubscriptionLifecycl
multipath_enabled: bool
send_default_route: bool
is_multi_hop: bool
is_passive: bool
class BGPSession(BGPSessionProvisioning, lifecycle=[SubscriptionLifecycle.ACTIVE]):
......@@ -72,3 +74,5 @@ class BGPSession(BGPSessionProvisioning, lifecycle=[SubscriptionLifecycle.ACTIVE
send_default_route: bool
#: Whether this session is multi-hop or not. Defaults to no.
is_multi_hop: bool
#: Whether this is a passive session.
is_passive: bool
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment