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
c0cd6c85
Commit
c0cd6c85
authored
1 year ago
by
Neda Moeini
Browse files
Options
Downloads
Patches
Plain Diff
Updated import site endpoint.
parent
531a3b96
No related branches found
No related tags found
1 merge request
!60
Feature/nat 217 import sites
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gso/api/api_v1/endpoints/import_site.py
+17
-5
17 additions, 5 deletions
gso/api/api_v1/endpoints/import_site.py
gso/workflows/tasks/import_site.py
+1
-0
1 addition, 0 deletions
gso/workflows/tasks/import_site.py
with
18 additions
and
5 deletions
gso/api/api_v1/endpoints/import_site.py
+
17
−
5
View file @
c0cd6c85
from
typing
import
Dict
,
Any
from
fastapi
import
HTTPException
from
fastapi
import
HTTPException
,
status
from
fastapi.routing
import
APIRouter
from
orchestrator.services
import
processes
from
orchestrator.services
import
processes
,
subscriptions
from
pydantic
import
BaseModel
from
gso.products.product_blocks.site
import
SiteTier
...
...
@@ -20,19 +20,31 @@ class SiteImport(BaseModel):
site_bgp_community_id
:
int
site_internal_id
:
int
site_tier
:
SiteTier
site_ts_address
:
str
@router.post
(
"
/
"
,
tags
=
[
"
Import
"
])
@router.post
(
"
/
"
,
status_code
=
status
.
HTTP_201_CREATED
,
tags
=
[
"
Import
"
])
def
import_site
(
site
:
SiteImport
)
->
Dict
[
str
,
Any
]:
"""
Import site by running the import_site workflow.
response:
- pid: The process id of the started process.
Raises:
HTTPException: If the site already exists or if there
'
s an error in the process.
"""
subscription
=
subscriptions
.
retrieve_subscription_by_subscription_instance_value
(
resource_type
=
"
site_name
"
,
value
=
site
.
site_name
,
sub_status
=
(
"
provisioning
"
,
"
active
"
))
if
subscription
:
raise
HTTPException
(
status_code
=
status
.
HTTP_409_CONFLICT
,
detail
=
"
Site already exists.
"
)
pid
=
processes
.
start_process
(
"
import_site
"
,
[
site
.
dict
()])
if
pid
is
None
:
raise
HTTPException
(
status_code
=
500
,
detail
=
"
Failed to start the process.
"
)
raise
HTTPException
(
status_code
=
status
.
HTTP_500_INTERNAL_SERVER_ERROR
,
detail
=
"
Failed to start the process.
"
)
process
=
processes
.
_get_process
(
pid
)
# pylint: disable=protected-access
if
process
.
last_status
==
"
failed
"
:
raise
HTTPException
(
status_code
=
500
,
detail
=
f
"
Process
{
pid
}
failed because of an internal error.
"
)
status_code
=
status
.
HTTP_500_INTERNAL_SERVER_ERROR
,
detail
=
f
"
Process
{
pid
}
failed because of an internal error.
"
)
return
{
"
pid
"
:
str
(
pid
)}
This diff is collapsed.
Click to expand it.
gso/workflows/tasks/import_site.py
+
1
−
0
View file @
c0cd6c85
...
...
@@ -38,6 +38,7 @@ def generate_initial_input_form() -> FormGenerator:
site_bgp_community_id
:
int
site_internal_id
:
int
site_tier
:
SiteTier
site_ts_address
:
str
user_input
=
yield
ImportSite
return
user_input
.
dict
()
...
...
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