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
96c56efd
Commit
96c56efd
authored
1 year ago
by
JORGE SASIAIN
Browse files
Options
Downloads
Patches
Plain Diff
NAT-356: fix tox issues
parent
a45c877f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!112
Address SonarQube code smells
Pipeline
#84711
passed
1 year ago
Stage: tox
Stage: documentation
Stage: sonarqube
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
gso/api/v1/imports.py
+2
-4
2 additions, 4 deletions
gso/api/v1/imports.py
gso/workflows/site/base_site_model.py
+17
-5
17 additions, 5 deletions
gso/workflows/site/base_site_model.py
gso/workflows/site/create_site.py
+2
-2
2 additions, 2 deletions
gso/workflows/site/create_site.py
with
21 additions
and
11 deletions
gso/api/v1/imports.py
+
2
−
4
View file @
96c56efd
...
...
@@ -9,16 +9,14 @@ from fastapi.routing import APIRouter
from
orchestrator.security
import
opa_security_default
from
orchestrator.services
import
processes
from
pydantic
import
BaseModel
,
root_validator
,
validator
from
pydantic.fields
import
ModelField
from
gso.products.product_blocks.iptrunk
import
IptrunkType
,
PhyPortCapacity
from
gso.products.product_blocks.router
import
RouterRole
,
RouterVendor
from
gso.products.product_blocks.site
import
SiteTier
from
gso.services
import
subscriptions
from
gso.services.crm
import
CustomerNotFoundError
,
get_customer_by_name
from
gso.workflows.site.base_site_model
import
BaseSiteModel
from
gso.utils.helpers
import
LAGMember
from
gso.workflows.site.base_site_model
import
BaseSiteValidatorModel
router
=
APIRouter
(
prefix
=
"
/imports
"
,
tags
=
[
"
Imports
"
],
dependencies
=
[
Depends
(
opa_security_default
)])
...
...
@@ -30,7 +28,7 @@ class ImportResponseModel(BaseModel):
detail
:
str
class
SiteImportModel
(
BaseSiteModel
):
class
SiteImportModel
(
BaseSite
Validator
Model
):
"""
The required input for importing an existing :class:`gso.products.product_types.site`.
"""
site_name
:
str
...
...
This diff is collapsed.
Click to expand it.
gso/workflows/site/base_site_model.py
+
17
−
5
View file @
96c56efd
"""
A base site validator model extended by create site and by import site.
"""
from
pydantic
import
BaseModel
,
validator
from
pydantic.fields
import
ModelField
from
gso.products.product_blocks.site
import
SiteTier
from
gso.utils.helpers
import
(
validate_site_fields_is_unique
,
validate_ipv4_or_ipv6
,
validate_country_code
,
validate_ipv4_or_ipv6
,
validate_site_fields_is_unique
,
validate_site_name
,
)
class
BaseSiteModel
(
BaseModel
):
class
BaseSiteValidatorModel
(
BaseModel
):
"""
A base site validator model extended by create site and by import site.
"""
site_bgp_community_id
:
int
site_internal_id
:
int
site_tier
:
SiteTier
...
...
@@ -27,7 +32,14 @@ class BaseSiteModel(BaseModel):
validate_country_code
(
country_code
)
return
country_code
@validator
(
"
site_ts_address
"
,
"
site_internal_id
"
,
"
site_bgp_community_id
"
,
"
site_name
"
,
check_fields
=
False
,
allow_reuse
=
True
)
@validator
(
"
site_ts_address
"
,
"
site_internal_id
"
,
"
site_bgp_community_id
"
,
"
site_name
"
,
check_fields
=
False
,
allow_reuse
=
True
,
)
def
validate_unique_fields
(
cls
,
value
:
str
,
field
:
ModelField
)
->
str
|
int
:
"""
Validate that the internal and :term:`BGP` community IDs are unique.
"""
return
validate_site_fields_is_unique
(
field
.
name
,
value
)
...
...
@@ -39,4 +51,4 @@ class BaseSiteModel(BaseModel):
The site name must consist of three uppercase letters, followed by an optional single digit.
"""
validate_site_name
(
site_name
)
return
site_name
\ No newline at end of file
return
site_name
This diff is collapsed.
Click to expand it.
gso/workflows/site/create_site.py
+
2
−
2
View file @
96c56efd
...
...
@@ -11,13 +11,13 @@ from gso.products.product_blocks import site as site_pb
from
gso.products.product_blocks.site
import
LatitudeCoordinate
,
LongitudeCoordinate
from
gso.products.product_types
import
site
from
gso.services.crm
import
customer_selector
from
gso.workflows.site.base_site_model
import
BaseSiteModel
from
gso.workflows.site.base_site_model
import
BaseSite
Validator
Model
def
initial_input_form_generator
(
product_name
:
str
)
->
FormGenerator
:
"""
Get input from the operator about the new site subscription.
"""
class
CreateSiteForm
(
FormPage
,
BaseSiteModel
):
class
CreateSiteForm
(
FormPage
,
BaseSite
Validator
Model
):
class
Config
:
title
=
product_name
...
...
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