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

Add validation to modify VRF router list to avoid having duplicate routers in the VRF router list.

parent fa7ca0d2
No related branches found
No related tags found
No related merge requests found
Pipeline #90625 passed
......@@ -8,7 +8,7 @@ from orchestrator.types import FormGenerator, State, UUIDstr
from orchestrator.workflow import StepList, begin, done, step, workflow
from orchestrator.workflows.steps import resync, store_process_subscription, unsync
from orchestrator.workflows.utils import wrap_modify_initial_input_form
from pydantic import BaseModel, ConfigDict, Field
from pydantic import BaseModel, ConfigDict, Field, field_validator
from gso.products.product_types.router import Router
from gso.products.product_types.vrf import VRF
......@@ -35,6 +35,14 @@ def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator:
RouterSelection(router_id=str(router.owner_subscription_id)) for router in subscription.vrf.vrf_router_list
]
@field_validator("router_list")
def router_list_must_not_have_duplicates(cls, router_list: list[RouterSelection]) -> list[RouterSelection]:
router_ids = [router.router_id for router in router_list]
if len(router_ids) != len(set(router_ids)):
msg = "Duplicate router IDs found in the list."
raise ValueError(msg)
return router_list
user_input = yield ModifyVRFRouterListForm
return user_input.model_dump()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment