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
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
28a66dea
Commit
28a66dea
authored
3 months ago
by
Neda Moeini
Committed by
Mohammad Torkashvand
3 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Make GA and GS unique ids functionality
parent
6f960127
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!324
Feature/manage sid and gids
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gso/services/subscriptions.py
+38
-0
38 additions, 0 deletions
gso/services/subscriptions.py
with
38 additions
and
0 deletions
gso/services/subscriptions.py
+
38
−
0
View file @
28a66dea
...
...
@@ -19,6 +19,8 @@ from orchestrator.db import (
from
orchestrator.domain
import
SubscriptionModel
from
orchestrator.services.subscriptions
import
query_in_use_by_subscriptions
from
orchestrator.types
import
SubscriptionLifecycle
,
UUIDstr
from
sqlalchemy
import
text
from
sqlalchemy.exc
import
SQLAlchemyError
from
gso.products
import
ProductName
,
ProductType
from
gso.products.product_types.site
import
Site
...
...
@@ -329,3 +331,39 @@ def is_virtual_circuit_id_available(virtual_circuit_id: str) -> bool:
True if the virtual circuit ID is unique (not found), False if it exists.
"""
return
is_resource_type_value_unique
(
"
virtual_circuit_id
"
,
virtual_circuit_id
)
def
make_unique_gs_id
()
->
str
:
"""
Generate a unique GS ID using the gs_id_seq database sequence.
Returns:
str: A unique GS ID in the format `GS-<number>`.
Raises:
ValueError: If there is an error generating the ID.
"""
try
:
new_id
=
db
.
session
.
execute
(
text
(
"
SELECT nextval(
'
gs_id_seq
'
)
"
)).
scalar_one
()
except
SQLAlchemyError
as
exc
:
error_message
=
f
"
Error generating GS ID:
{
exc
}
"
raise
ValueError
(
error_message
)
from
exc
else
:
return
f
"
GS-
{
new_id
}
"
def
make_unique_ga_id
()
->
str
:
"""
Generate a unique GA ID using the ga_id_seq database sequence.
Returns:
str: A unique GA ID in the format `GA<number>`.
Raises:
ValueError: If there is an error generating the ID.
"""
try
:
new_id
=
db
.
session
.
execute
(
text
(
"
SELECT nextval(
'
ga_id_seq
'
)
"
)).
scalar_one
()
except
SQLAlchemyError
as
exc
:
error_message
=
f
"
Error generating GA ID:
{
exc
}
"
raise
ValueError
(
error_message
)
from
exc
else
:
return
f
"
GA-
{
new_id
}
"
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