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
25e71caf
Commit
25e71caf
authored
3 years ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
add .geant.net to hostnames, if necessary
parent
9c9e6edd
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
inventory_provider/routes/lg.py
+15
-1
15 additions, 1 deletion
inventory_provider/routes/lg.py
test/test_lg_routes.py
+4
-0
4 additions, 0 deletions
test/test_lg_routes.py
with
19 additions
and
1 deletion
inventory_provider/routes/lg.py
+
15
−
1
View file @
25e71caf
...
...
@@ -12,6 +12,7 @@ These endpoints are intended for use by LG.
"""
import
json
import
logging
import
re
from
flask
import
Blueprint
,
jsonify
,
Response
,
request
...
...
@@ -93,6 +94,10 @@ def routers(access):
.. asjson::
inventory_provider.routes.lg.LG_ROUTERS_SCHEMA
"
equipment name
"
will be the IMS node name, but if this
doesn
'
t end in
"
.geant.org
"
or
"
.geant.net
"
, will be appended
with
"
geant.net
"
:param access: one of `public` or `all`
:return:
"""
...
...
@@ -113,7 +118,16 @@ def routers(access):
def
_routers
():
for
k
in
redis
.
scan_iter
(
'
ims:lg:*
'
,
count
=
1000
):
rtr
=
redis
.
get
(
k
.
decode
(
'
utf-8
'
)).
decode
(
'
utf-8
'
)
yield
json
.
loads
(
rtr
)
rtr
=
json
.
loads
(
rtr
)
hostname
=
rtr
[
'
equipment name
'
].
lower
()
if
'
'
in
hostname
:
logger
.
warning
(
'
skipping LG router with ws in hostname: {hostname}
'
)
continue
if
not
re
.
match
(
r
'
.*\.geant\.(net|org)$
'
,
hostname
):
hostname
=
f
'
{
hostname
}
.geant.net
'
rtr
[
'
equipment name
'
]
=
hostname
yield
rtr
cache_key
=
f
'
classifier-cache:ims-lg:
{
access
}
'
...
...
This diff is collapsed.
Click to expand it.
test/test_lg_routes.py
+
4
−
0
View file @
25e71caf
import
json
import
re
import
jsonschema
import
pytest
from
inventory_provider.routes.lg
import
LG_ROUTERS_SCHEMA
...
...
@@ -21,6 +23,8 @@ def test_public_routers(client):
assert
response_data
# test data is non-empty
# no internal routers should be present
assert
all
(
r
[
'
type
'
]
==
'
CORE
'
for
r
in
response_data
)
assert
all
(
re
.
match
(
r
'
^\S+\.geant\.(net|org)$
'
,
r
[
'
equipment name
'
])
for
r
in
response_data
)
def
test_with_cache
(
client
):
...
...
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