Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inventory-provider
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
geant-swd
dashboardv3
inventory-provider
Commits
3fdc1c37
Commit
3fdc1c37
authored
5 years ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
added a prototype lg endpoint
parent
b0077d87
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
inventory_provider/__init__.py
+3
-0
3 additions, 0 deletions
inventory_provider/__init__.py
inventory_provider/db/opsdb.py
+58
-0
58 additions, 0 deletions
inventory_provider/db/opsdb.py
with
61 additions
and
0 deletions
inventory_provider/__init__.py
+
3
−
0
View file @
3fdc1c37
...
...
@@ -58,6 +58,9 @@ def create_app():
from
inventory_provider.routes
import
poller
app
.
register_blueprint
(
poller
.
routes
,
url_prefix
=
'
/poller
'
)
from
inventory_provider.routes
import
lg
app
.
register_blueprint
(
lg
.
routes
,
url_prefix
=
'
/lg
'
)
if
app
.
config
.
get
(
'
ENABLE_TESTING_ROUTES
'
,
False
):
from
inventory_provider.routes
import
testing
app
.
register_blueprint
(
testing
.
routes
,
url_prefix
=
'
/testing
'
)
...
...
This diff is collapsed.
Click to expand it.
inventory_provider/db/opsdb.py
+
58
−
0
View file @
3fdc1c37
...
...
@@ -297,6 +297,64 @@ ORDER BY FIELD(e.status, 'Operational', 'Installed')
return
list
([
_row2rsp
(
r
)
for
r
in
rows
])
def
lookup_lg_routers
(
connection
):
# this is literally the definition of the view vlg_routers
# (cf. https://jira.software.geant.org/projects/LGR/issues/LGR-73)
# but with the city added and filtering on names instead of absid's
# for readability
INTERNAL_POP_NAMES
=
{
'
Cambridge OC
'
,
'
DANTE Lab
'
,
'
Amsterdam GEANT Office
'
}
query
=
"""
SELECT
e.name AS router_name,
p.name AS pop_name,
p.city AS pop_city,
p.abbreviation AS pop_abbreviation,
g.latitude AS pop_latitude,
g.longitude AS pop_longitude,
p.country_code AS pop_country_code,
g.country AS pop_country,
g.city AS pop_city
FROM
opsdb.equipment e
LEFT JOIN opsdb.pop p ON p.absid = e.PTR_pop
LEFT JOIN opsdb.geocoding g ON g.absid = p.PTR_geocoding
LEFT JOIN opsdb.organisation o ON o.absid = e.PTR_owner
WHERE
e.model LIKE
'
mx%
'
AND e.status =
'
Operational
'
AND o.name =
'
DANTE / GEANT
'
AND NOT (e.name REGEXP
'
vpn-proxy|vrr|taas
'
)
"""
def
_row2rsp
(
row
):
print
(
row
)
return
{
'
equipment-name
'
:
row
[
'
router_name
'
],
'
type
'
:
'
INTERNAL
'
if
row
[
'
pop_name
'
]
in
INTERNAL_POP_NAMES
else
'
CORE
'
,
'
pop
'
:
{
'
name
'
:
row
[
'
pop_name
'
],
'
city
'
:
row
[
'
pop_city
'
],
'
country
'
:
row
[
'
pop_country
'
],
'
country code
'
:
row
[
'
pop_country_code
'
],
'
abbreviation
'
:
row
[
'
pop_abbreviation
'
],
'
longitude
'
:
row
[
'
pop_longitude
'
],
'
latitude
'
:
row
[
'
pop_latitude
'
],
}
}
with
db
.
cursor
(
connection
)
as
crs
:
crs
.
execute
(
query
)
rows
=
_convert_to_dict
(
crs
)
return
list
([
_row2rsp
(
r
)
for
r
in
rows
])
def
lookup_coriant_path
(
connection
,
equipment_name
,
card_id
,
port_number
):
base_query
=
"""
...
...
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