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
c4cc14ce
Commit
c4cc14ce
authored
2 years ago
by
Sam Roberts
Browse files
Options
Downloads
Patches
Plain Diff
functionally complete, needs tests & docs
parent
a1fdcd4f
No related branches found
No related tags found
1 merge request
!2
Feature/reporting 307 msr vpn proxy endpoint
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
inventory_provider/routes/msr.py
+69
-3
69 additions, 3 deletions
inventory_provider/routes/msr.py
with
69 additions
and
3 deletions
inventory_provider/routes/msr.py
+
69
−
3
View file @
c4cc14ce
...
...
@@ -321,6 +321,31 @@ MDVPN_LIST_SCHEMA = {
'
items
'
:
{
'
$ref
'
:
'
#/definitions/mdvpn_group
'
}
}
VPN_PROXY_LIST_SCHEMA
=
{
'
$schema
'
:
'
http://json-schema.org/draft-07/schema#
'
,
'
definitions
'
:
{
'
vpn_proxy_peering
'
:
{
'
type
'
:
'
object
'
,
'
properties
'
:
{
# TODO: THIS
},
'
additionalProperties
'
:
False
}
},
'
type
'
:
'
array
'
,
'
items
'
:
{
'
$ref
'
:
'
#/definitions/vpn_proxy_peering
'
}
}
DOMAIN_TO_POP_MAPPING
=
{
"
mad.es
"
:
"
Madrid
"
,
"
bra.sk
"
:
"
Bratislava
"
,
"
vie.at
"
:
"
Vienna
"
,
"
gen.ch
"
:
"
Geneva
"
,
"
fra.de
"
:
"
Frankfurt
"
,
"
pra.cz
"
:
"
Prague
"
,
"
ams.nl
"
:
"
Amsterdam
"
}
@routes.after_request
def
after_request
(
resp
):
...
...
@@ -1068,8 +1093,49 @@ def vpn_proxy():
return
False
return
"
L3VPN
"
in
desc
def
_look_up_city_from_hostname
(
hostname
):
for
snippet
in
DOMAIN_TO_POP_MAPPING
:
if
snippet
in
hostname
:
return
DOMAIN_TO_POP_MAPPING
[
snippet
]
def
_extract_nren_from_description
(
desc
,
group
):
"""
Retrieve the relevant NREN from the peering description and group.
This approach is, by its nature, very fragile to any changes to
descriptions, and should be revisited when that happens.
:param desc: description of a VPN-Proxy peering
:param group: group of the same VPN-Proxy peering
:return: name of the NREN
"""
if
group
==
"
PRACE
"
:
# common trait: the NREN is the first word in the description
return
desc
.
split
(
'
'
)[
0
]
else
:
# only other group is XiFi, and only CESNet is relevant
return
'
CESNet
'
def
_format_peerings
(
vpnproxy
):
for
peering
in
vpnproxy
:
if
_is_relevant
(
peering
):
desc
=
peering
[
"
description
"
]
group
=
peering
[
"
group
"
]
hostname
=
peering
[
"
hostname
"
]
formatted_peering
=
{
"
pop
"
:
_look_up_city_from_hostname
(
hostname
),
"
nren
"
:
_extract_nren_from_description
(
desc
,
group
),
"
group
"
:
group
,
"
v4
"
:
peering
.
get
(
"
address
"
)
}
yield
formatted_peering
else
:
yield
False
r
=
common
.
get_current_redis
()
vpnproxy
=
json
.
loads
(
r
.
get
(
'
juniper-peerings:logical-system:VPN-PROXY
'
).
decode
(
'
utf-8
'
))
test
=
[
item
for
item
in
vpnproxy
if
_is_relevant
(
item
)]
response
=
json
.
dumps
(
test
)
cache_key
=
'
classifier-cache:msr:vpn-proxy
'
response
=
_ignore_cache_or_retrieve
(
request
,
cache_key
,
r
)
if
not
response
:
vpnproxy
=
json
.
loads
(
r
.
get
(
'
juniper-peerings:logical-system:VPN-PROXY
'
).
decode
(
'
utf-8
'
))
peerings
=
list
(
filter
(
None
,
_format_peerings
(
vpnproxy
)))
response
=
json
.
dumps
(
peerings
)
return
Response
(
response
,
mimetype
=
'
application/json
'
)
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