Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Resource Manager
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
GÉANT Orchestration and Automation Team
GAP
Resource Manager
Commits
8a0a79bc
Commit
8a0a79bc
authored
2 years ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
added list of routers api
parent
cdf21878
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
resource_management/routes/interfaces.py
+17
-0
17 additions, 0 deletions
resource_management/routes/interfaces.py
test/test_interfaces_routes.py
+16
-0
16 additions, 0 deletions
test/test_interfaces_routes.py
with
33 additions
and
0 deletions
resource_management/routes/interfaces.py
+
17
−
0
View file @
8a0a79bc
from
typing
import
List
from
fastapi
import
APIRouter
,
HTTPException
from
fastapi
import
APIRouter
,
HTTPException
import
pydantic
import
pydantic
...
@@ -35,6 +37,14 @@ class NextPhysicalInterface(pydantic.BaseModel):
...
@@ -35,6 +37,14 @@ class NextPhysicalInterface(pydantic.BaseModel):
name
:
str
name
:
str
class
RouterDetails
(
pydantic
.
BaseModel
):
fqdn
:
str
class
ListOfRouters
(
pydantic
.
BaseModel
):
routers
:
List
[
RouterDetails
]
@router.post
(
'
/initialize-router/{fqdn}
'
)
@router.post
(
'
/initialize-router/{fqdn}
'
)
async
def
load_new_router_interfaces
(
fqdn
:
str
)
->
InterfacesSummary
:
async
def
load_new_router_interfaces
(
fqdn
:
str
)
->
InterfacesSummary
:
...
@@ -74,6 +84,13 @@ async def reconcile_current_router_interfaces(fqdn: str):
...
@@ -74,6 +84,13 @@ async def reconcile_current_router_interfaces(fqdn: str):
detail
=
'
not implemented
'
)
detail
=
'
not implemented
'
)
@router.get
(
'
/routers
'
)
async
def
get_known_routers
()
->
ListOfRouters
:
with
db
.
session_scope
()
as
session
:
rows
=
session
.
query
(
model
.
Router
.
fqdn
).
all
()
return
{
'
routers
'
:
[{
'
fqdn
'
:
r
[
0
]}
for
r
in
rows
]}
@router.post
(
'
/next-lag/{fqdn}
'
)
@router.post
(
'
/next-lag/{fqdn}
'
)
async
def
reserve_next_lag
(
fqdn
:
str
)
->
NextLAG
:
async
def
reserve_next_lag
(
fqdn
:
str
)
->
NextLAG
:
"""
"""
...
...
This diff is collapsed.
Click to expand it.
test/test_interfaces_routes.py
+
16
−
0
View file @
8a0a79bc
...
@@ -76,3 +76,19 @@ def test_next_physical(client, resources_db, mocked_router, router_name):
...
@@ -76,3 +76,19 @@ def test_next_physical(client, resources_db, mocked_router, router_name):
join
(
model
.
LAG
).
\
join
(
model
.
LAG
).
\
filter_by
(
name
=
lag_name
).
one
()
filter_by
(
name
=
lag_name
).
one
()
assert
ifc_row
.
availability
==
model
.
AvalabilityStates
.
RESERVED
.
name
assert
ifc_row
.
availability
==
model
.
AvalabilityStates
.
RESERVED
.
name
def
test_next_physical
(
client
,
resources_db
):
with
db
.
session_scope
()
as
session
:
for
idx
in
range
(
10
):
row
=
db
.
model
.
Router
(
fqdn
=
f
'
router-
{
idx
}
.xyz.com
'
)
session
.
add
(
row
)
rv
=
client
.
get
(
f
'
/api/interfaces/routers
'
)
assert
rv
.
status_code
==
200
response
=
rv
.
json
()
jsonschema
.
validate
(
response
,
interfaces
.
ListOfRouters
.
schema
())
for
r
in
response
[
'
routers
'
]:
assert
r
[
'
fqdn
'
].
endswith
(
'
.xyz.com
'
)
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