diff --git a/gso/migrations/versions/2024-10-29_5132c463214d_add_layer_2_cricuits_services_domain_.py b/gso/migrations/versions/2024-10-29_5132c463214d_add_layer_2_cricuits_services_domain_.py index bd81d5ba5f8eb00f89e4219b3a855c6922f6c16a..42bc0a1eb83f6aa3b61ebada2bc64048c301d798 100644 --- a/gso/migrations/versions/2024-10-29_5132c463214d_add_layer_2_cricuits_services_domain_.py +++ b/gso/migrations/versions/2024-10-29_5132c463214d_add_layer_2_cricuits_services_domain_.py @@ -45,10 +45,10 @@ INSERT INTO resource_types (resource_type, description) VALUES ('policer_enabled INSERT INTO resource_types (resource_type, description) VALUES ('bandwidth', 'If policed, the bandwidth of the policer is stored.') RETURNING resource_types.resource_type_id """)) conn.execute(sa.text(""" -INSERT INTO resource_types (resource_type, description) VALUES ('vlan_range_upper_bound', 'VLAN upper boound range') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('vlan_range_upper_bound', 'VLAN upper bound range') RETURNING resource_types.resource_type_id """)) conn.execute(sa.text(""" -INSERT INTO resource_types (resource_type, description) VALUES ('vlan_range_lower_bound', 'VLAN lower boound range') RETURNING resource_types.resource_type_id +INSERT INTO resource_types (resource_type, description) VALUES ('vlan_range_lower_bound', 'VLAN lower bound range') RETURNING resource_types.resource_type_id """)) conn.execute(sa.text(""" INSERT INTO resource_types (resource_type, description) VALUES ('virtual_circuit_id', 'Virtual Circuit ID of this Layer 2 Circuit.') RETURNING resource_types.resource_type_id @@ -83,11 +83,29 @@ INSERT INTO product_block_resource_types (product_block_id, resource_type_id) VA 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 ('Layer2CircuitBlock')), (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('bandwidth'))) """)) + conn.execute(sa.text(""" +INSERT INTO resource_types (resource_type, description) VALUES ('policer_burst_rate', 'Max burst rate of a policer') 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 ('Layer2CircuitBlock')), (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('policer_burst_rate'))) + """)) 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 ('Layer2CircuitBlock')) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('policer_burst_rate')) + """)) + 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 ('Layer2CircuitBlock'))) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('policer_burst_rate')) + """)) + 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 ('policer_burst_rate')) + """)) + conn.execute(sa.text(""" +DELETE FROM resource_types WHERE resource_types.resource_type IN ('policer_burst_rate') + """)) + 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 ('Layer2CircuitBlock')) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('virtual_circuit_id')) """)) conn.execute(sa.text(""" diff --git a/gso/products/product_blocks/layer_2_circuit.py b/gso/products/product_blocks/layer_2_circuit.py index efa14953221f136806b12d3e18dec32cf6ce9459..261caa48669fd604c4182a5bb878a39b24647301 100644 --- a/gso/products/product_blocks/layer_2_circuit.py +++ b/gso/products/product_blocks/layer_2_circuit.py @@ -77,6 +77,7 @@ class Layer2CircuitBlockInactive( vlan_range_lower_bound: VLAN_ID | None = None vlan_range_upper_bound: VLAN_ID | None = None policer_enabled: bool | None = None + policer_burst_rate: BandwidthString | None = None bandwidth: BandwidthString | None = None @@ -86,10 +87,11 @@ class Layer2CircuitBlockProvisioning(Layer2CircuitBlockInactive, lifecycle=[Subs layer_2_circuit_sides: Layer2CircuitSides[Layer2CircuitSideBlockProvisioning] virtual_circuit_id: VC_ID layer_2_circuit_type: Layer2CircuitType - vlan_range_lower_bound: VLAN_ID | None = None - vlan_range_upper_bound: VLAN_ID | None = None + vlan_range_lower_bound: VLAN_ID | None + vlan_range_upper_bound: VLAN_ID | None policer_enabled: bool - bandwidth: BandwidthString | None = None + policer_burst_rate: BandwidthString | None + bandwidth: BandwidthString | None class Layer2CircuitBlock(Layer2CircuitBlockProvisioning, lifecycle=[SubscriptionLifecycle.ACTIVE]): @@ -102,10 +104,12 @@ class Layer2CircuitBlock(Layer2CircuitBlockProvisioning, lifecycle=[Subscription #: The type of circuit, can be tagged or untagged. layer_2_circuit_type: Layer2CircuitType #: If tagged, the lower and upper bounds will set the :term:`VLAN` range. - vlan_range_lower_bound: VLAN_ID | None = None + vlan_range_lower_bound: VLAN_ID | None #: Lower and Upper bounds are including. - vlan_range_upper_bound: VLAN_ID | None = None + vlan_range_upper_bound: VLAN_ID | None #: Whether this Layer 2 Circuit is policed. policer_enabled: bool + #: If policed, the burst rate of the policer + policer_burst_rate: BandwidthString | None #: If policed, the bandwidth of the policer is stored. - bandwidth: BandwidthString | None = None + bandwidth: BandwidthString | None