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
Merge requests
!184
Implement API endpoint for retrieving FQDNs of monitored dashboard devices
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Implement API endpoint for retrieving FQDNs of monitored dashboard devices
feature/NAT-482-replace-dashboard-devices-list
into
develop
Overview
1
Commits
1
Pipelines
2
Changes
14
Merged
Mohammad Torkashvand
requested to merge
feature/NAT-482-replace-dashboard-devices-list
into
develop
1 year ago
Overview
1
Commits
1
Pipelines
2
Changes
14
Expand
0
0
Merge request reports
Compare
develop
version 1
4c2ad886
1 year ago
develop (base)
and
latest version
latest version
78f86145
1 commit,
1 year ago
version 1
4c2ad886
1 commit,
1 year ago
14 files
+
285
−
51
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
14
Search (e.g. *.vue) (Ctrl+P)
gso/api/v1/subscriptions.py
+
39
−
4
Options
@@ -2,14 +2,16 @@
from
typing
import
Any
from
fastapi
import
Depends
,
status
from
fastapi
import
Depends
,
Response
,
status
from
fastapi.routing
import
APIRouter
from
orchestrator.domain
import
SubscriptionModel
from
orchestrator.schemas
import
SubscriptionDomainModelSchema
from
orchestrator.services.subscriptions
import
build_extended_domain_model
from
orchestrator.types
import
SubscriptionLifecycle
from
gso.auth.api_key_auth
import
get_api_key
from
gso.services.subscriptions
import
get_active_router_subscriptions
from
gso.products
import
ProductType
from
gso.services.subscriptions
import
get_router_subscriptions
,
get_subscriptions
router
=
APIRouter
(
prefix
=
"
/subscriptions
"
,
@@ -24,11 +26,44 @@ router = APIRouter(
response_model
=
list
[
SubscriptionDomainModelSchema
],
)
def
subscription_routers
()
->
list
[
dict
[
str
,
Any
]]:
"""
Retrieve all active router subscriptions.
"""
"""
Retrieve all active
or provisioning
router subscriptions.
"""
subscriptions
=
[]
for
r
in
get_active_router_subscriptions
():
routers
=
get_router_subscriptions
(
lifecycles
=
[
SubscriptionLifecycle
.
ACTIVE
,
SubscriptionLifecycle
.
PROVISIONING
])
for
r
in
routers
:
subscription
=
SubscriptionModel
.
from_subscription
(
r
[
"
subscription_id
"
])
extended_model
=
build_extended_domain_model
(
subscription
)
subscriptions
.
append
(
extended_model
)
return
subscriptions
@router.get
(
"
/dashboard_devices
"
,
status_code
=
status
.
HTTP_200_OK
,
response_class
=
Response
,
responses
=
{
200
:
{
"
content
"
:
{
"
text/plain
"
:
{}},
"
description
"
:
"
Return a flat file of FQDNs.
"
,
}
},
)
def
subscription_dashboard_devices
()
->
Response
:
"""
Retrieve FQDN for all dashboard devices that are monitored.
"""
fqdns
=
[]
dashboard_devices
=
get_subscriptions
(
product_types
=
[
ProductType
.
ROUTER
,
ProductType
.
SUPER_POP_SWITCH
,
ProductType
.
OFFICE_ROUTER
],
lifecycles
=
[
SubscriptionLifecycle
.
ACTIVE
,
SubscriptionLifecycle
.
PROVISIONING
],
)
for
device
in
dashboard_devices
:
subscription
=
SubscriptionModel
.
from_subscription
(
device
[
"
subscription_id
"
])
extended_model
=
build_extended_domain_model
(
subscription
)
if
extended_model
[
"
product
"
][
"
product_type
"
]
==
ProductType
.
ROUTER
:
fqdns
.
append
(
extended_model
[
"
router
"
][
"
router_fqdn
"
])
elif
extended_model
[
"
product
"
][
"
product_type
"
]
==
ProductType
.
SUPER_POP_SWITCH
:
fqdns
.
append
(
extended_model
[
"
super_pop_switch
"
][
"
super_pop_switch_fqdn
"
])
elif
extended_model
[
"
product
"
][
"
product_type
"
]
==
ProductType
.
OFFICE_ROUTER
:
fqdns
.
append
(
extended_model
[
"
office_router
"
][
"
office_router_fqdn
"
])
fqdn_flat_file
=
"
\n
"
.
join
(
fqdns
)
return
Response
(
content
=
fqdn_flat_file
,
media_type
=
"
text/plain
"
)
Loading