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
ea4e371c
Commit
ea4e371c
authored
3 years ago
by
Bjarke Madsen
Browse files
Options
Downloads
Patches
Plain Diff
add dashboard info to poller interfaces + test
parent
d95295d9
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/poller.py
+55
-2
55 additions, 2 deletions
inventory_provider/routes/poller.py
test/test_general_poller_routes.py
+61
-0
61 additions, 0 deletions
test/test_general_poller_routes.py
with
116 additions
and
2 deletions
inventory_provider/routes/poller.py
+
55
−
2
View file @
ea4e371c
...
@@ -75,6 +75,13 @@ routes = Blueprint('poller-support-routes', __name__)
...
@@ -75,6 +75,13 @@ routes = Blueprint('poller-support-routes', __name__)
Gb
=
1
<<
30
Gb
=
1
<<
30
class
INTERFACE_TYPES
(
Enum
):
UNKNOWN
=
auto
()
LOGICAL
=
auto
()
PHYSICAL
=
auto
()
AGGREGATE
=
auto
()
class
BRIAN_DASHBOARDS
(
Enum
):
class
BRIAN_DASHBOARDS
(
Enum
):
CLS
=
auto
()
CLS
=
auto
()
RE_PEER
=
auto
()
RE_PEER
=
auto
()
...
@@ -106,6 +113,8 @@ class BRIAN_DASHBOARDS(Enum):
...
@@ -106,6 +113,8 @@ class BRIAN_DASHBOARDS(Enum):
# only used in INTERFACE_LIST_SCHEMA and sphinx docs
# only used in INTERFACE_LIST_SCHEMA and sphinx docs
_DASHBOARD_IDS
=
[
d
.
name
for
d
in
list
(
BRIAN_DASHBOARDS
)]
_DASHBOARD_IDS
=
[
d
.
name
for
d
in
list
(
BRIAN_DASHBOARDS
)]
_INTERFACE_TYPES
=
[
i
.
name
for
i
in
list
(
INTERFACE_TYPES
)]
INTERFACE_LIST_SCHEMA
=
{
INTERFACE_LIST_SCHEMA
=
{
'
$schema
'
:
'
http://json-schema.org/draft-07/schema#
'
,
'
$schema
'
:
'
http://json-schema.org/draft-07/schema#
'
,
...
@@ -146,6 +155,13 @@ INTERFACE_LIST_SCHEMA = {
...
@@ -146,6 +155,13 @@ INTERFACE_LIST_SCHEMA = {
'
dashboards
'
:
{
'
dashboards
'
:
{
'
type
'
:
'
array
'
,
'
type
'
:
'
array
'
,
'
items
'
:
{
'
enum
'
:
_DASHBOARD_IDS
}
'
items
'
:
{
'
enum
'
:
_DASHBOARD_IDS
}
},
'
dashboard_info
'
:
{
'
type
'
:
'
object
'
,
'
properties
'
:
{
'
name
'
:
{
'
type
'
:
'
string
'
},
'
interface_type
'
:
{
'
enum
'
:
_INTERFACE_TYPES
}
}
}
}
},
},
'
required
'
:
[
'
required
'
:
[
...
@@ -374,7 +390,7 @@ def _get_dashboards(interface):
...
@@ -374,7 +390,7 @@ def _get_dashboards(interface):
yield
BRIAN_DASHBOARDS
.
IAS_UPSTREAM
yield
BRIAN_DASHBOARDS
.
IAS_UPSTREAM
if
'
SRV_GLOBAL RE_INTERCONNECT
'
in
description
:
if
'
SRV_GLOBAL RE_INTERCONNECT
'
in
description
:
yield
BRIAN_DASHBOARDS
.
RE_PEER
yield
BRIAN_DASHBOARDS
.
RE_PEER
if
re
.
match
(
'
(PHY|LAG|SRV_GLOBAL) CUSTOMER
'
,
description
):
if
re
.
match
(
r
'
(PHY|LAG|SRV_GLOBAL) CUSTOMER
'
,
description
):
yield
BRIAN_DASHBOARDS
.
RE_CUST
yield
BRIAN_DASHBOARDS
.
RE_CUST
if
re
.
match
(
'
^SRV_GCS
'
,
description
):
if
re
.
match
(
'
^SRV_GCS
'
,
description
):
yield
BRIAN_DASHBOARDS
.
GCS
yield
BRIAN_DASHBOARDS
.
GCS
...
@@ -405,6 +421,43 @@ def _get_dashboards(interface):
...
@@ -405,6 +421,43 @@ def _get_dashboards(interface):
yield
BRIAN_DASHBOARDS
.
NREN
yield
BRIAN_DASHBOARDS
.
NREN
def
_get_interface_type
(
interface
):
description
=
interface
.
get
(
'
description
'
,
''
).
strip
()
if
re
.
match
(
r
'
^PHY
'
,
description
):
return
INTERFACE_TYPES
.
PHYSICAL
if
re
.
match
(
r
'
^SRV_
'
,
description
):
return
INTERFACE_TYPES
.
LOGICAL
if
re
.
match
(
r
'
^LAG
'
,
description
):
return
INTERFACE_TYPES
.
AGGREGATE
return
INTERFACE_TYPES
.
UNKNOWN
def
_get_dashboard_data
(
ifc
):
interface_type
=
_get_interface_type
(
ifc
)
description
=
ifc
.
get
(
'
description
'
,
''
).
strip
()
dashboards
=
ifc
.
get
(
'
dashboards
'
,
[])
if
len
(
dashboards
)
==
0
:
return
ifc
if
BRIAN_DASHBOARDS
.
INFRASTRUCTURE_BACKBONE
.
name
in
dashboards
:
name
=
description
.
split
(
'
|
'
)
name
=
name
[
1
].
strip
()
name
=
name
.
replace
(
'
(
'
,
'
(
'
)
else
:
name
=
description
.
split
(
'
'
)[
2
].
upper
()
return
{
**
ifc
,
'
dashboard_info
'
:
{
'
name
'
:
name
,
'
interface_type
'
:
interface_type
.
name
}
}
def
_add_dashboards
(
interfaces
):
def
_add_dashboards
(
interfaces
):
"""
"""
generator that dashboards to each interfaces.
generator that dashboards to each interfaces.
...
@@ -416,7 +469,7 @@ def _add_dashboards(interfaces):
...
@@ -416,7 +469,7 @@ def _add_dashboards(interfaces):
for
ifc
in
interfaces
:
for
ifc
in
interfaces
:
dashboards
=
_get_dashboards
(
ifc
)
dashboards
=
_get_dashboards
(
ifc
)
ifc
[
'
dashboards
'
]
=
sorted
([
d
.
name
for
d
in
dashboards
])
ifc
[
'
dashboards
'
]
=
sorted
([
d
.
name
for
d
in
dashboards
])
yield
ifc
yield
_get_dashboard_data
(
ifc
)
def
_load_interface_bundles
(
hostname
=
None
):
def
_load_interface_bundles
(
hostname
=
None
):
...
...
This diff is collapsed.
Click to expand it.
test/test_general_poller_routes.py
+
61
−
0
View file @
ea4e371c
...
@@ -254,3 +254,64 @@ def test_interface_dashboard_mapping(description, expected_dashboards):
...
@@ -254,3 +254,64 @@ def test_interface_dashboard_mapping(description, expected_dashboards):
dashboards
=
poller
.
_get_dashboards
(
interface
)
dashboards
=
poller
.
_get_dashboards
(
interface
)
dashboards
=
[
d
.
name
for
d
in
dashboards
]
dashboards
=
[
d
.
name
for
d
in
dashboards
]
assert
set
(
list
(
dashboards
))
==
set
(
expected_dashboards
)
assert
set
(
list
(
dashboards
))
==
set
(
expected_dashboards
)
@pytest.mark.parametrize
(
'
interface,dashboard_info
'
,
[
({
'
description
'
:
'
SRV_IAS CUSTOMER JISC #JISC-AP1-IAS IASPS | ASN786
'
,
'
dashboards
'
:
[
'
IAS_CUSTOMER
'
,
'
NREN
'
]
},
{
'
name
'
:
'
JISC
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
({
'
description
'
:
'
SRV_L2CIRCUIT CUSTOMER JISC JISC #DUB-LON-NRENBBEXT-JANET-13015 | backup for niran
'
,
# noqa: E501
'
dashboards
'
:
[
'
L2_CIRCUIT
'
]
},
{
'
name
'
:
'
JISC
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
({
'
description
'
:
'
SRV_L3VPN CUSTOMER EENET #EENET-AP2-LHCONE | ASN3221
'
,
'
dashboards
'
:
[
'
LHCONE
'
,
'
LHCONE_CUST
'
,
'
NREN
'
]
},
{
'
name
'
:
'
EENET
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
({
'
description
'
:
'
SRV_IAS PRIVATE OPTIMA-TELEKOM #HR-EduZone | For Eduzone
'
,
# noqa: E501
'
dashboards
'
:
[
'
IAS_PEERS
'
,
'
IAS_PRIVATE
'
]
},
{
'
name
'
:
'
OPTIMA-TELEKOM
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
({
'
description
'
:
'
SRV_CLS PRIVATE AWS #AT-AWS-CLS|ASN16509 |
'
,
'
dashboards
'
:
[
'
CLS
'
,
'
CLS_PEERS
'
]
},
{
'
name
'
:
'
AWS
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
({
'
description
'
:
'
SRV_IAS PUBLIC MIX #IX_Peerings_in_MIX |
'
,
'
dashboards
'
:
[
'
IAS_PEERS
'
,
'
IAS_PUBLIC
'
]
},
{
'
name
'
:
'
MIX
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
({
'
description
'
:
'
LAG INFRASTRUCTURE BACKBONE SRF0000001 | bil-por
'
,
'
dashboards
'
:
[
'
INFRASTRUCTURE_BACKBONE
'
]
},
{
'
name
'
:
'
bil-por
'
,
'
interface_type
'
:
'
AGGREGATE
'
}),
({
'
description
'
:
'
SRV_GCS CUSTOMER FCCN MICROSOFT #FCCN_NoveSBE_ExpressRoute_Vlan1945 | UNIT CONFIGURATION HAS BEEN SYSTEM GENERATED
'
,
# noqa: E501
'
dashboards
'
:
[
'
GCS
'
]
},
{
'
name
'
:
'
FCCN
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
({
'
description
'
:
'
PHY UPSTREAM TELIA SRF9940473 | Telia ID: IC-326863
'
,
'
dashboards
'
:
[
'
GWS_PHY_UPSTREAM
'
]
},
{
'
name
'
:
'
TELIA
'
,
'
interface_type
'
:
'
PHYSICAL
'
}),
({
'
description
'
:
'
SRV_IAS UPSTREAM COGENT #COGENT_GWS_VIE | ASN174
'
,
'
dashboards
'
:
[
'
IAS_UPSTREAM
'
]
},
{
'
name
'
:
'
COGENT
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
({
'
description
'
:
'
SRV_L3VPN RE_INTERCONNECT CLARA #REDCLARA-LIS-LHCONE | ASN27750
'
,
# noqa: E501
'
dashboards
'
:
[
'
LHCONE
'
,
'
LHCONE_PEER
'
]
},
{
'
name
'
:
'
CLARA
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
({
'
description
'
:
'
SRV_MDVPN CUSTOMER REDIRIS #RedIRIS_AP1_BGP_LU_CoC_1 | MD VPN CoC-REDIRIS -
'
,
# noqa: E501
'
dashboards
'
:
[
'
MDVPN_CUSTOMERS
'
,
'
NREN
'
]
},
{
'
name
'
:
'
REDIRIS
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
({
'
description
'
:
'
SRV_L2CIRCUIT CUSTOMER TENET PSNC #lon-lon-GEANTOPEN-PSNC-TENET-18067 |
'
,
# noqa: E501
'
dashboards
'
:
[
'
GEANTOPEN
'
,
'
L2_CIRCUIT
'
]
},
{
'
name
'
:
'
TENET
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
])
def
test_description_dashboard_parsing
(
interface
,
dashboard_info
):
updated
=
poller
.
_get_dashboard_data
(
interface
)
info
=
updated
[
'
dashboard_info
'
]
assert
info
==
dashboard_info
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