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

Add policer_burst_rate field to the creation and modification WF.

parent b4ab4186
No related branches found
No related tags found
1 merge request!307Feature/l2circuits
......@@ -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)
......
......@@ -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
......
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