Skip to content
Snippets Groups Projects
Commit 84c8516d authored by Neda Moeini's avatar Neda Moeini
Browse files

Add custom_service_name to EdgePort, L2Circuit and AccessPort blocks.

parent 02b7a5cb
No related branches found
No related tags found
1 merge request!340Feature/nat 930 add service name field
Pipeline #91251 failed
"""Add custom service name to EdgePort, L2Circuit and L3CoreService..
Revision ID: db6e86c6d4e1
Revises: 8a65d0ed588e
Create Date: 2025-01-13 11:13:05.149307
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = 'db6e86c6d4e1'
down_revision = '8a65d0ed588e'
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 ('custom_service_name', 'Custom Service Name mainly used by IMS') 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 ('AccessPort')), (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('custom_service_name'))), ((SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('Layer2CircuitBlock')), (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('custom_service_name'))), ((SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('EdgePortBlock')), (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('custom_service_name')))
"""))
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 ('AccessPort', 'Layer2CircuitBlock', 'EdgePortBlock')) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('custom_service_name'))
"""))
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 ('AccessPort', 'Layer2CircuitBlock', 'EdgePortBlock'))) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('custom_service_name'))
"""))
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 ('custom_service_name'))
"""))
conn.execute(sa.text("""
DELETE FROM resource_types WHERE resource_types.resource_type IN ('custom_service_name')
"""))
...@@ -72,6 +72,7 @@ class EdgePortBlockInactive( ...@@ -72,6 +72,7 @@ class EdgePortBlockInactive(
ignore_if_down: bool = False ignore_if_down: bool = False
ga_id: str | None = None ga_id: str | None = None
edge_port_ae_members: LAGMemberList[EdgePortAEMemberBlockInactive] edge_port_ae_members: LAGMemberList[EdgePortAEMemberBlockInactive]
custom_service_name: str | None = None
class EdgePortBlockProvisioning(EdgePortBlockInactive, lifecycle=[SubscriptionLifecycle.PROVISIONING]): class EdgePortBlockProvisioning(EdgePortBlockInactive, lifecycle=[SubscriptionLifecycle.PROVISIONING]):
...@@ -89,6 +90,7 @@ class EdgePortBlockProvisioning(EdgePortBlockInactive, lifecycle=[SubscriptionLi ...@@ -89,6 +90,7 @@ class EdgePortBlockProvisioning(EdgePortBlockInactive, lifecycle=[SubscriptionLi
ignore_if_down: bool = False ignore_if_down: bool = False
ga_id: str | None = None ga_id: str | None = None
edge_port_ae_members: LAGMemberList[EdgePortAEMemberBlockProvisioning] # type: ignore[assignment] edge_port_ae_members: LAGMemberList[EdgePortAEMemberBlockProvisioning] # type: ignore[assignment]
custom_service_name: str | None = None
class EdgePortBlock(EdgePortBlockProvisioning, lifecycle=[SubscriptionLifecycle.ACTIVE]): class EdgePortBlock(EdgePortBlockProvisioning, lifecycle=[SubscriptionLifecycle.ACTIVE]):
...@@ -107,6 +109,7 @@ class EdgePortBlock(EdgePortBlockProvisioning, lifecycle=[SubscriptionLifecycle. ...@@ -107,6 +109,7 @@ class EdgePortBlock(EdgePortBlockProvisioning, lifecycle=[SubscriptionLifecycle.
ignore_if_down: If set to True, the edge port will be ignored if it is down. ignore_if_down: If set to True, the edge port will be ignored if it is down.
ga_id: The GEANT GA ID associated with this edge port, if any. ga_id: The GEANT GA ID associated with this edge port, if any.
edge_port_ae_members: A list of LAG members associated with this edge port. edge_port_ae_members: A list of LAG members associated with this edge port.
custom_service_name: The name of the custom service, if any.
""" """
node: RouterBlock node: RouterBlock
...@@ -121,3 +124,4 @@ class EdgePortBlock(EdgePortBlockProvisioning, lifecycle=[SubscriptionLifecycle. ...@@ -121,3 +124,4 @@ class EdgePortBlock(EdgePortBlockProvisioning, lifecycle=[SubscriptionLifecycle.
ignore_if_down: bool = False ignore_if_down: bool = False
ga_id: str | None = None ga_id: str | None = None
edge_port_ae_members: LAGMemberList[EdgePortAEMemberBlock] # type: ignore[assignment] edge_port_ae_members: LAGMemberList[EdgePortAEMemberBlock] # type: ignore[assignment]
custom_service_name: str | None = None
...@@ -17,6 +17,7 @@ class AccessPortInactive(ProductBlockModel, lifecycle=[SubscriptionLifecycle.INI ...@@ -17,6 +17,7 @@ class AccessPortInactive(ProductBlockModel, lifecycle=[SubscriptionLifecycle.INI
ap_type: APType | None = None ap_type: APType | None = None
sbp: ServiceBindingPortInactive sbp: ServiceBindingPortInactive
custom_service_name: str | None = None
class AccessPortProvisioning(AccessPortInactive, lifecycle=[SubscriptionLifecycle.PROVISIONING]): class AccessPortProvisioning(AccessPortInactive, lifecycle=[SubscriptionLifecycle.PROVISIONING]):
...@@ -24,6 +25,7 @@ class AccessPortProvisioning(AccessPortInactive, lifecycle=[SubscriptionLifecycl ...@@ -24,6 +25,7 @@ class AccessPortProvisioning(AccessPortInactive, lifecycle=[SubscriptionLifecycl
ap_type: APType ap_type: APType
sbp: ServiceBindingPortProvisioning sbp: ServiceBindingPortProvisioning
custom_service_name: str | None = None
class AccessPort(AccessPortProvisioning, lifecycle=[SubscriptionLifecycle.ACTIVE]): class AccessPort(AccessPortProvisioning, lifecycle=[SubscriptionLifecycle.ACTIVE]):
...@@ -32,10 +34,12 @@ class AccessPort(AccessPortProvisioning, lifecycle=[SubscriptionLifecycle.ACTIVE ...@@ -32,10 +34,12 @@ class AccessPort(AccessPortProvisioning, lifecycle=[SubscriptionLifecycle.ACTIVE
Attributes: Attributes:
ap_type: The type of Access Port ap_type: The type of Access Port
sbp: The corresponding SBP of this Access Port. sbp: The corresponding SBP of this Access Port.
custom_service_name: The name of the custom service, if any.
""" """
ap_type: APType ap_type: APType
sbp: ServiceBindingPort sbp: ServiceBindingPort
custom_service_name: str | None = None
class L3CoreServiceBlockInactive( class L3CoreServiceBlockInactive(
......
...@@ -79,6 +79,7 @@ class Layer2CircuitBlockInactive( ...@@ -79,6 +79,7 @@ class Layer2CircuitBlockInactive(
policer_enabled: bool | None = None policer_enabled: bool | None = None
policer_burst_rate: BandwidthString | None = None policer_burst_rate: BandwidthString | None = None
bandwidth: BandwidthString | None = None bandwidth: BandwidthString | None = None
custom_service_name: str | None = None
class Layer2CircuitBlockProvisioning(Layer2CircuitBlockInactive, lifecycle=[SubscriptionLifecycle.PROVISIONING]): class Layer2CircuitBlockProvisioning(Layer2CircuitBlockInactive, lifecycle=[SubscriptionLifecycle.PROVISIONING]):
...@@ -92,6 +93,7 @@ class Layer2CircuitBlockProvisioning(Layer2CircuitBlockInactive, lifecycle=[Subs ...@@ -92,6 +93,7 @@ class Layer2CircuitBlockProvisioning(Layer2CircuitBlockInactive, lifecycle=[Subs
policer_enabled: bool policer_enabled: bool
policer_burst_rate: BandwidthString | None policer_burst_rate: BandwidthString | None
bandwidth: BandwidthString | None bandwidth: BandwidthString | None
custom_service_name: str | None = None
class Layer2CircuitBlock(Layer2CircuitBlockProvisioning, lifecycle=[SubscriptionLifecycle.ACTIVE]): class Layer2CircuitBlock(Layer2CircuitBlockProvisioning, lifecycle=[SubscriptionLifecycle.ACTIVE]):
...@@ -106,6 +108,7 @@ class Layer2CircuitBlock(Layer2CircuitBlockProvisioning, lifecycle=[Subscription ...@@ -106,6 +108,7 @@ class Layer2CircuitBlock(Layer2CircuitBlockProvisioning, lifecycle=[Subscription
policer_enabled: Whether this Layer 2 Circuit is policed. policer_enabled: Whether this Layer 2 Circuit is policed.
policer_burst_rate: If policed, the burst rate of the policer. policer_burst_rate: If policed, the burst rate of the policer.
bandwidth: If policed, the bandwidth of the policer is stored. bandwidth: If policed, the bandwidth of the policer is stored.
custom_service_name: The name of the service which is used in IMS.
""" """
layer_2_circuit_sides: Layer2CircuitSides[Layer2CircuitSideBlock] layer_2_circuit_sides: Layer2CircuitSides[Layer2CircuitSideBlock]
...@@ -116,3 +119,5 @@ class Layer2CircuitBlock(Layer2CircuitBlockProvisioning, lifecycle=[Subscription ...@@ -116,3 +119,5 @@ class Layer2CircuitBlock(Layer2CircuitBlockProvisioning, lifecycle=[Subscription
policer_enabled: bool policer_enabled: bool
policer_burst_rate: BandwidthString | None policer_burst_rate: BandwidthString | None
bandwidth: BandwidthString | None bandwidth: BandwidthString | None
custom_service_name: str | None = None
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