diff --git a/gso/workflows/l2_circuit/create_layer_2_circuit.py b/gso/workflows/l2_circuit/create_layer_2_circuit.py index a3199bc1ad2ea56f6ed62a66f075216fa0e99881..a74858973e6db2ed3635684891b6992be08ead9e 100644 --- a/gso/workflows/l2_circuit/create_layer_2_circuit.py +++ b/gso/workflows/l2_circuit/create_layer_2_circuit.py @@ -52,6 +52,10 @@ def initial_input_generator(product_name: str) -> FormGenerator: """Return the appropriate field type based on whether the circuit is tagged.""" return VLAN_ID if is_tagged else ReadOnlyField(None, default_type=int) + def _policer_field(*, policer_enabled: bool) -> BandwidthString: + """Return the appropriate field type based on whether the policer is enabled.""" + return BandwidthString if policer_enabled else ReadOnlyField(None, default_type=str) + class Layer2CircuitServiceSidesPage(FormPage): model_config = ConfigDict(title=f"{product_name} - Configure Edge Ports") @@ -63,9 +67,8 @@ def initial_input_generator(product_name: str) -> FormGenerator: is_tagged=initial_user_input.layer_2_circuit_type == Layer2CircuitType.TAGGED ) vlan_divider: Divider = Field(None, exclude=True) - policer_bandwidth: ( # type: ignore[valid-type] - BandwidthString if initial_user_input.policer_enabled else ReadOnlyField(None, default_type=str) - ) + policer_bandwidth: _policer_field(policer_enabled=initial_user_input.policer_enabled) # type: ignore[valid-type] + policer_burst_rate: _policer_field(policer_enabled=initial_user_input.policer_enabled) # type: ignore[valid-type] geant_sid: str layer_2_circuit_side_a: Layer2CircuitSideSelection @@ -102,6 +105,7 @@ def initialize_subscription( vlan_range_upper_bound: VLAN_ID | None, policer_enabled: bool, # noqa: FBT001 policer_bandwidth: BandwidthString | None, + policed_burst_rate: BandwidthString | None, geant_sid: str, ) -> State: """Build a subscription object from all user input.""" @@ -125,6 +129,7 @@ def initialize_subscription( subscription.layer_2_circuit.vlan_range_upper_bound = vlan_range_upper_bound subscription.layer_2_circuit.policer_enabled = policer_enabled subscription.layer_2_circuit.bandwidth = policer_bandwidth + subscription.layer_2_circuit.policer_burst_rate = policed_burst_rate subscription.description = f"{subscription.product.name} - {subscription.layer_2_circuit.virtual_circuit_id}" subscription = Layer2Circuit.from_other_lifecycle(subscription, SubscriptionLifecycle.PROVISIONING) diff --git a/gso/workflows/l2_circuit/modify_layer_2_circuit.py b/gso/workflows/l2_circuit/modify_layer_2_circuit.py index 7a3366b5ad2bdb80570e8962df267f15d19454fd..0ac2d3919763596fdb34c6f9223c2efccc5694de 100644 --- a/gso/workflows/l2_circuit/modify_layer_2_circuit.py +++ b/gso/workflows/l2_circuit/modify_layer_2_circuit.py @@ -49,8 +49,10 @@ def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator: vlan_divider: Divider = Field(None, exclude=True) if layer_2_circuit_input.policer_enabled: policer_bandwidth: BandwidthString = subscription.layer_2_circuit.bandwidth # type: ignore[assignment] + policer_burst_rate: BandwidthString = subscription.layer_2_circuit.policer_burst_rate # type: ignore[assignment] else: policer_bandwidth: ReadOnlyField(None, default_type=str) # type: ignore[no-redef, valid-type] + policer_burst_rate: ReadOnlyField(None, default_type=str) # type: ignore[no-redef, valid-type] policer_divider: Divider = Field(None, exclude=True) layer_2_circuit_side_a: ReadOnlyField( # type: ignore[valid-type] @@ -80,6 +82,7 @@ def modify_layer_2_circuit_subscription( vlan_range_upper_bound: VLAN_ID | None, policer_enabled: bool, # noqa: FBT001 policer_bandwidth: BandwidthString | None, + policer_burst_rate: BandwidthString | None, ) -> dict: """Update the Layer 2 Circuit subscription with the new values.""" subscription.layer_2_circuit.layer_2_circuit_type = layer_2_circuit_type @@ -87,6 +90,7 @@ def modify_layer_2_circuit_subscription( subscription.layer_2_circuit.vlan_range_upper_bound = vlan_range_upper_bound subscription.layer_2_circuit.policer_enabled = policer_enabled subscription.layer_2_circuit.bandwidth = policer_bandwidth + subscription.layer_2_circuit.policer_burst_rate = policer_burst_rate for layer_2_circuit_side in subscription.layer_2_circuit.layer_2_circuit_sides: layer_2_circuit_side.sbp.is_tagged = layer_2_circuit_type == Layer2CircuitType.TAGGED