Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
GÉANT Service Orchestrator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GÉANT Orchestration and Automation Team
GAP
GÉANT Service Orchestrator
Commits
4e633b51
Commit
4e633b51
authored
5 months ago
by
Neda Moeini
Browse files
Options
Downloads
Patches
Plain Diff
Add validation to create VRF WF to check if the vrf name is unique in the entire DB
parent
3aa064f9
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!314
Feature/vrf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gso/services/subscriptions.py
+34
-9
34 additions, 9 deletions
gso/services/subscriptions.py
gso/workflows/vrf/create_vrf.py
+9
-1
9 additions, 1 deletion
gso/workflows/vrf/create_vrf.py
with
43 additions
and
10 deletions
gso/services/subscriptions.py
+
34
−
9
View file @
4e633b51
...
@@ -289,6 +289,26 @@ def get_all_active_sites() -> list[dict[str, Any]]:
...
@@ -289,6 +289,26 @@ def get_all_active_sites() -> list[dict[str, Any]]:
]
]
def
is_resource_type_value_unique
(
resource_type
:
str
,
value
:
str
)
->
bool
:
"""
Check if the given value for the specified resource type is unique in the database.
This function verifies if the specified value for the given resource type is not already in the core database.
:param resource_type: The resource type to check.
:type resource_type: str
:param value: The value to check.
:type value: str
:return: True if the value is unique (not found), False if it exists.
:rtype: bool
"""
exists
=
(
ResourceTypeTable
.
query
.
join
(
SubscriptionInstanceValueTable
)
.
filter
(
ResourceTypeTable
.
resource_type
==
resource_type
,
SubscriptionInstanceValueTable
.
value
==
value
)
.
scalar
()
)
return
exists
is
None
def
is_virtual_circuit_id_available
(
virtual_circuit_id
:
str
)
->
bool
:
def
is_virtual_circuit_id_available
(
virtual_circuit_id
:
str
)
->
bool
:
"""
Check if the given virtual circuit ID is unique in the database.
"""
Check if the given virtual circuit ID is unique in the database.
...
@@ -300,12 +320,17 @@ def is_virtual_circuit_id_available(virtual_circuit_id: str) -> bool:
...
@@ -300,12 +320,17 @@ def is_virtual_circuit_id_available(virtual_circuit_id: str) -> bool:
:return: True if the virtual circuit ID is unique (not found), False if it exists.
:return: True if the virtual circuit ID is unique (not found), False if it exists.
:rtype: bool
:rtype: bool
"""
"""
exists
=
(
return
is_resource_type_value_unique
(
"
virtual_circuit_id
"
,
virtual_circuit_id
)
ResourceTypeTable
.
query
.
join
(
SubscriptionInstanceValueTable
)
.
filter
(
ResourceTypeTable
.
resource_type
==
"
virtual_circuit_id
"
,
def
is_vrf_name_unique
(
vrf_name
:
str
)
->
bool
:
SubscriptionInstanceValueTable
.
value
==
virtual_circuit_id
,
"""
Check if the given VRF name is unique in the database.
)
.
scalar
()
This function verifies if the specified VRF name is not already present in the core database.
)
return
exists
is
None
:param vrf_name: The VRF name to check.
:type vrf_name: str
:return: True if the VRF name is unique (not found), False if it exists.
:rtype: bool
"""
return
is_resource_type_value_unique
(
"
vrf_name
"
,
vrf_name
)
This diff is collapsed.
Click to expand it.
gso/workflows/vrf/create_vrf.py
+
9
−
1
View file @
4e633b51
...
@@ -6,11 +6,12 @@ from orchestrator.types import FormGenerator, State, SubscriptionLifecycle, UUID
...
@@ -6,11 +6,12 @@ from orchestrator.types import FormGenerator, State, SubscriptionLifecycle, UUID
from
orchestrator.workflow
import
StepList
,
begin
,
done
,
step
,
workflow
from
orchestrator.workflow
import
StepList
,
begin
,
done
,
step
,
workflow
from
orchestrator.workflows.steps
import
resync
,
set_status
,
store_process_subscription
from
orchestrator.workflows.steps
import
resync
,
set_status
,
store_process_subscription
from
orchestrator.workflows.utils
import
wrap_create_initial_input_form
from
orchestrator.workflows.utils
import
wrap_create_initial_input_form
from
pydantic
import
ConfigDict
from
pydantic
import
ConfigDict
,
field_validator
from
pydantic_forms.validators
import
ReadOnlyField
from
pydantic_forms.validators
import
ReadOnlyField
from
gso.products.product_types.vrf
import
VRFInactive
from
gso.products.product_types.vrf
import
VRFInactive
from
gso.services.partners
import
get_partner_by_name
from
gso.services.partners
import
get_partner_by_name
from
gso.services.subscriptions
import
is_vrf_name_unique
from
gso.utils.types.tt_number
import
TTNumber
from
gso.utils.types.tt_number
import
TTNumber
from
gso.workflows.shared
import
create_summary_form
from
gso.workflows.shared
import
create_summary_form
...
@@ -28,6 +29,13 @@ def initial_input_form_generator(product_name: str) -> FormGenerator:
...
@@ -28,6 +29,13 @@ def initial_input_form_generator(product_name: str) -> FormGenerator:
route_target
:
str
route_target
:
str
vrf_as_number
:
int
vrf_as_number
:
int
@field_validator
(
"
vrf_name
"
)
def
vrf_name_must_be_unique
(
cls
,
vrf_name
:
str
)
->
str
:
if
not
is_vrf_name_unique
(
vrf_name
):
msg
=
"
VRF name must be unique.
"
raise
ValueError
(
msg
)
return
vrf_name
user_input
=
yield
CreateVRFForm
user_input
=
yield
CreateVRFForm
user_input
=
user_input
.
model_dump
()
user_input
=
user_input
.
model_dump
()
summary_fields
=
[
"
vrf_name
"
,
"
route_distinguisher
"
,
"
route_target
"
,
"
vrf_as_number
"
]
summary_fields
=
[
"
vrf_name
"
,
"
route_distinguisher
"
,
"
route_target
"
,
"
vrf_as_number
"
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment