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
b7e23a9e
Commit
b7e23a9e
authored
2 years ago
by
Sam Roberts
Browse files
Options
Downloads
Patches
Plain Diff
documentation updated
parent
8dc0ce4e
No related branches found
No related tags found
1 merge request
!1
Feature/reporting 297 msr mdvpn endpoint
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
inventory_provider/routes/msr.py
+96
-0
96 additions, 0 deletions
inventory_provider/routes/msr.py
with
96 additions
and
0 deletions
inventory_provider/routes/msr.py
+
96
−
0
View file @
b7e23a9e
...
@@ -59,6 +59,11 @@ These endpoints are intended for use by MSR.
...
@@ -59,6 +59,11 @@ These endpoints are intended for use by MSR.
.. autofunction:: inventory_provider.routes.msr.bgp_all_peerings
.. autofunction:: inventory_provider.routes.msr.bgp_all_peerings
/msr/mdpvn
--------------------------------------------
.. autofunction:: inventory_provider.routes.msr.mdvpn
/msr/services
/msr/services
--------------------------------------------
--------------------------------------------
...
@@ -256,6 +261,66 @@ SYSTEM_CORRELATION_SERVICES_LIST_SCHEMA = {
...
@@ -256,6 +261,66 @@ SYSTEM_CORRELATION_SERVICES_LIST_SCHEMA = {
'
minItems
'
:
1
# otherwise the route should return 404
'
minItems
'
:
1
# otherwise the route should return 404
}
}
MDVPN_LIST_SCHEMA
=
{
'
$schema
'
:
'
http://json-schema.org/draft-07/schema#
'
,
'
definitions
'
:
{
'
mdvpn_group
'
:
{
'
type
'
:
'
object
'
,
'
properties
'
:
{
'
asn
'
:
{
'
type
'
:
'
integer
'
},
'
AP
'
:
{
'
$ref
'
:
'
#/definitions/ap_peerings
'
},
'
VRR
'
:
{
'
$ref
'
:
'
#/definitions/vrr_peerings
'
}
},
'
required
'
:
[
'
asn
'
,
'
AP
'
,
'
VRR
'
],
'
additionalProperties
'
:
False
},
'
ap_peerings
'
:
{
'
type
'
:
'
array
'
,
'
items
'
:
{
'
$ref
'
:
'
#/definitions/bgplu_peering
'
}
},
'
bgplu_peering
'
:
{
'
type
'
:
'
object
'
,
'
properties
'
:
{
'
name
'
:
{
'
type
'
:
'
string
'
},
'
v4
'
:
{
'
type
'
:
'
string
'
},
'
v6
'
:
{
'
type
'
:
'
string
'
},
'
hostname
'
:
{
'
type
'
:
'
string
'
}
},
'
required
'
:
[
'
name
'
,
'
v4
'
,
'
v6
'
,
'
hostname
'
],
'
additionalProperties
'
:
False
},
'
vrr_peerings
'
:
{
'
type
'
:
'
array
'
,
'
items
'
:
{
'
$ref
'
:
'
#/definitions/vpn_peering
'
}
},
'
vpn_peering
'
:
{
'
type
'
:
'
object
'
,
'
properties
'
:
{
'
description
'
:
{
'
type
'
:
'
string
'
},
'
v4
'
:
{
'
type
'
:
'
string
'
},
'
hostname
'
:
{
'
type
'
:
'
array
'
,
'
items
'
:
{
'
type
'
:
'
string
'
},
'
minItems
'
:
1
}
},
'
additionalProperties
'
:
False
}
},
'
type
'
:
'
array
'
,
'
items
'
:
{
'
$ref
'
:
'
#/definitions/mdvpn_group
'
}
}
@routes.after_request
@routes.after_request
def
after_request
(
resp
):
def
after_request
(
resp
):
...
@@ -880,6 +945,20 @@ def bgp_all_peerings():
...
@@ -880,6 +945,20 @@ def bgp_all_peerings():
@routes.route
(
'
/mdvpn
'
,
methods
=
[
'
GET
'
,
'
POST
'
])
@routes.route
(
'
/mdvpn
'
,
methods
=
[
'
GET
'
,
'
POST
'
])
@common.require_accepts_json
@common.require_accepts_json
def
mdvpn
():
def
mdvpn
():
"""
Handler for `/mdvpn`
This method returns a list of all BGP-LU peerings, and the VR peerings
for both Paris & Ljubljana.
The response will be formatted according to the following schema:
.. asjson::
inventory_provider.routes.msr.MDVPN_LIST_SCHEMA
:return:
"""
def
_get_consistent_description
(
description
):
def
_get_consistent_description
(
description
):
"""
"""
The same interface in VRR peerings can have multiple names.
The same interface in VRR peerings can have multiple names.
...
@@ -889,6 +968,7 @@ def mdvpn():
...
@@ -889,6 +968,7 @@ def mdvpn():
IPv4 address, this serves as a quick and dirty way of merging these
IPv4 address, this serves as a quick and dirty way of merging these
multiple descriptions into one an external user can use to identify
multiple descriptions into one an external user can use to identify
the peering reliably.
the peering reliably.
:param description: The raw description for a VRR peering
:param description: The raw description for a VRR peering
:return: The same description with location prefix removed
:return: The same description with location prefix removed
"""
"""
...
@@ -902,7 +982,23 @@ def mdvpn():
...
@@ -902,7 +982,23 @@ def mdvpn():
return
description
.
replace
(
prefix
,
''
)
return
description
.
replace
(
prefix
,
''
)
return
description
return
description
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# REVIEW COMMENT ONLY, DO NOT MERGE:
# _make_group_index is extremely, extremely generic,
# but is it worth extracting, will anything else use it?
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
def
_make_group_index
(
group
,
index_key
):
def
_make_group_index
(
group
,
index_key
):
"""
Utility function to take a list and make it a dict based off a given
key, for fast lookup of a specific key field.
:param group: A list of dicts which should all have `index_key` as a
field
:param index_key: Name of the key to index on
:return: Dict with `index_key` as the key field and a list of all
matching dicts as the value
"""
index
=
{}
index
=
{}
for
peering
in
group
:
for
peering
in
group
:
key
=
peering
.
get
(
index_key
)
key
=
peering
.
get
(
index_key
)
...
...
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