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
490b23b0
Commit
490b23b0
authored
2 years ago
by
Robert Latta
Browse files
Options
Downloads
Patches
Plain Diff
populated L2 Circuit customers from IMS RE POL1-526
parent
6fb43483
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
+21
-12
21 additions, 12 deletions
inventory_provider/routes/poller.py
test/test_general_poller_routes.py
+22
-21
22 additions, 21 deletions
test/test_general_poller_routes.py
with
43 additions
and
33 deletions
inventory_provider/routes/poller.py
+
21
−
12
View file @
490b23b0
...
@@ -475,7 +475,7 @@ def _get_dashboards(interface):
...
@@ -475,7 +475,7 @@ def _get_dashboards(interface):
yield
BRIAN_DASHBOARDS
.
NREN
yield
BRIAN_DASHBOARDS
.
NREN
def
_get_dashboard_data
(
ifc
,
possible_na
mes
):
def
_get_dashboard_data
(
ifc
,
custo
me
r
s
):
def
_get_interface_type
(
description
):
def
_get_interface_type
(
description
):
if
re
.
match
(
r
'
^PHY
'
,
description
):
if
re
.
match
(
r
'
^PHY
'
,
description
):
...
@@ -529,18 +529,21 @@ def _get_dashboard_data(ifc, possible_names):
...
@@ -529,18 +529,21 @@ def _get_dashboard_data(ifc, possible_names):
names
=
[
f
'
{
_get_customer_name
(
description
)
}
-
{
location
}
'
]
names
=
[
f
'
{
_get_customer_name
(
description
)
}
-
{
location
}
'
]
elif
BRIAN_DASHBOARDS
.
L2_CIRCUIT
.
name
in
dashboards
:
elif
BRIAN_DASHBOARDS
.
L2_CIRCUIT
.
name
in
dashboards
:
# This will give names derived from the Interface Description
# This will give names derived from the Interface Description
names
=
list
(
_get_l2_customer_names
(
description
))
# names = list(_get_l2_customer_names(description))
# This will give first 2 names IMS
# DBOARD3-526
names
=
[
c
[
'
name
'
]
for
c
in
customers
][:
2
]
# This will give the first customer from the Interface Description
# and additional names derived from IMS provided they also appear in
# the Interface Description
# names = [_get_customer_name(description)]
# names = names + [n for n in possible_names
# if n in description.upper().split(' ')]
else
:
else
:
names
=
[
_get_customer_name
(
description
)]
names
=
[
_get_customer_name
(
description
)]
# if no customers found just return the original data
if
not
names
:
return
ifc
# to maintain compatability with current brian dashboard manager we will
# continue to return dashboard_info with the first customer name. We will
# also return dashboards_info (note the plural of dashboards) with up to
# two customers
return
{
return
{
**
ifc
,
**
ifc
,
'
dashboard_info
'
:
{
'
dashboard_info
'
:
{
...
@@ -608,9 +611,15 @@ def _get_services_and_customers(config, hostname=None, use_next_redis=False):
...
@@ -608,9 +611,15 @@ def _get_services_and_customers(config, hostname=None, use_next_redis=False):
continue
continue
included_service_ids
.
add
(
s
[
'
id
'
])
included_service_ids
.
add
(
s
[
'
id
'
])
cs
[
'
customers
'
].
append
(
s
[
'
customer
'
])
cs
[
'
customers
'
].
append
({
'
name
'
:
s
[
'
customer
'
],
'
type
'
:
'
UNKNOWN
'
})
for
c
in
s
.
get
(
'
additional_customers
'
,
[]):
for
c
in
s
.
get
(
'
additional_customers
'
,
[]):
cs
[
'
customers
'
].
append
(
c
[
'
name
'
])
cs
[
'
customers
'
].
append
({
'
name
'
:
c
[
'
name
'
],
'
type
'
:
c
.
get
(
'
type
'
,
'
UNKNOWN
'
)
})
if
s
[
'
circuit_type
'
]
==
'
service
'
:
if
s
[
'
circuit_type
'
]
==
'
service
'
:
cs
[
'
services
'
].
append
({
cs
[
'
services
'
].
append
({
'
id
'
:
s
[
'
id
'
],
'
id
'
:
s
[
'
id
'
],
...
...
This diff is collapsed.
Click to expand it.
test/test_general_poller_routes.py
+
22
−
21
View file @
490b23b0
...
@@ -318,96 +318,97 @@ def test_interface_dashboard_mapping(description, expected_dashboards):
...
@@ -318,96 +318,97 @@ def test_interface_dashboard_mapping(description, expected_dashboards):
assert
set
(
list
(
dashboards
))
==
set
(
expected_dashboards
)
assert
set
(
list
(
dashboards
))
==
set
(
expected_dashboards
)
@pytest.mark.parametrize
(
'
interface,
expected_na
mes,dashboard_info
'
,
[
@pytest.mark.parametrize
(
'
interface,
custo
me
r
s,dashboard_info
'
,
[
({
({
'
description
'
:
'
SRV_IAS CUSTOMER JISC #JISC-AP1-IAS IASPS | ASN786
'
,
'
description
'
:
'
SRV_IAS CUSTOMER JISC #JISC-AP1-IAS IASPS | ASN786
'
,
'
dashboards
'
:
[
'
IAS_CUSTOMER
'
,
'
NREN
'
]
'
dashboards
'
:
[
'
IAS_CUSTOMER
'
,
'
NREN
'
]
},
[
'
JISC
'
],
{
'
name
'
:
'
JISC
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
},
[
{
'
name
'
:
'
JISC
'
}
],
{
'
name
'
:
'
JISC
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
({
({
'
description
'
:
'
SRV_L2CIRCUIT CUSTOMER JISC JISC #DUB-LON-NRENBBEXT-JANET-13015 | backup for niran
'
,
# noqa: E501
'
description
'
:
'
SRV_L2CIRCUIT CUSTOMER JISC JISC #DUB-LON-NRENBBEXT-JANET-13015 | backup for niran
'
,
# noqa: E501
'
dashboards
'
:
[
'
L2_CIRCUIT
'
]
'
dashboards
'
:
[
'
L2_CIRCUIT
'
]
},
[
'
JISC
'
],
{
'
name
'
:
'
JISC
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
},
[
{
'
name
'
:
'
JISC
'
}
],
{
'
name
'
:
'
JISC
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
({
({
'
description
'
:
'
SRV_L3VPN CUSTOMER EENET #EENET-AP2-LHCONE | ASN3221
'
,
'
description
'
:
'
SRV_L3VPN CUSTOMER EENET #EENET-AP2-LHCONE | ASN3221
'
,
'
dashboards
'
:
[
'
LHCONE
'
,
'
LHCONE_CUST
'
,
'
NREN
'
]
'
dashboards
'
:
[
'
LHCONE
'
,
'
LHCONE_CUST
'
,
'
NREN
'
]
},
[
'
EENET
'
],
{
'
name
'
:
'
EENET
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
},
[
{
'
name
'
:
'
EENET
'
}
],
{
'
name
'
:
'
EENET
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
({
({
'
description
'
:
'
SRV_IAS PRIVATE OPTIMA-TELEKOM #HR-EduZone | For Eduzone
'
,
# noqa: E501
'
description
'
:
'
SRV_IAS PRIVATE OPTIMA-TELEKOM #HR-EduZone | For Eduzone
'
,
# noqa: E501
'
dashboards
'
:
[
'
IAS_PEERS
'
,
'
IAS_PRIVATE
'
]
'
dashboards
'
:
[
'
IAS_PEERS
'
,
'
IAS_PRIVATE
'
]
},
},
[
'
OPTIMA-TELEKOM
'
],
[
{
'
name
'
:
'
OPTIMA-TELEKOM
'
}
],
{
'
name
'
:
'
OPTIMA-TELEKOM
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
{
'
name
'
:
'
OPTIMA-TELEKOM
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
({
({
'
description
'
:
'
SRV_CLS PRIVATE AWS #AT-AWS-CLS|ASN16509 |
'
,
'
description
'
:
'
SRV_CLS PRIVATE AWS #AT-AWS-CLS|ASN16509 |
'
,
'
dashboards
'
:
[
'
CLS
'
,
'
CLS_PEERS
'
]
'
dashboards
'
:
[
'
CLS
'
,
'
CLS_PEERS
'
]
},
[
'
AWS
'
],
{
'
name
'
:
'
AWS
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
},
[
{
'
name
'
:
'
AWS
'
}
],
{
'
name
'
:
'
AWS
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
({
({
'
description
'
:
'
SRV_IAS PUBLIC MIX #IX_Peerings_in_MIX |
'
,
'
description
'
:
'
SRV_IAS PUBLIC MIX #IX_Peerings_in_MIX |
'
,
'
dashboards
'
:
[
'
IAS_PEERS
'
,
'
IAS_PUBLIC
'
]
'
dashboards
'
:
[
'
IAS_PEERS
'
,
'
IAS_PUBLIC
'
]
},
[
'
MIX
'
],
{
'
name
'
:
'
MIX
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
},
[
{
'
name
'
:
'
MIX
'
}
],
{
'
name
'
:
'
MIX
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
({
({
'
description
'
:
'
LAG INFRASTRUCTURE BACKBONE SRF0000001 | bil-por
'
,
'
description
'
:
'
LAG INFRASTRUCTURE BACKBONE SRF0000001 | bil-por
'
,
'
dashboards
'
:
[
'
INFRASTRUCTURE_BACKBONE
'
]
'
dashboards
'
:
[
'
INFRASTRUCTURE_BACKBONE
'
]
},
[
'
bil-por
'
],
{
'
name
'
:
'
bil-por
'
,
'
interface_type
'
:
'
AGGREGATE
'
}),
},
[
{
'
name
'
:
'
bil-por
'
}
],
{
'
name
'
:
'
bil-por
'
,
'
interface_type
'
:
'
AGGREGATE
'
}),
# noqa: E501
({
({
'
description
'
:
'
SRV_GLOBAL INFRASTRUCTURE BACKBONE SRF0000001 | bil-por
'
,
# noqa: E501
'
description
'
:
'
SRV_GLOBAL INFRASTRUCTURE BACKBONE SRF0000001 | bil-por
'
,
# noqa: E501
'
dashboards
'
:
[
'
INFRASTRUCTURE_BACKBONE
'
]
'
dashboards
'
:
[
'
INFRASTRUCTURE_BACKBONE
'
]
},
[
'
bil-por
'
],
{
'
name
'
:
'
bil-por
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
},
[
{
'
name
'
:
'
bil-por
'
}
],
{
'
name
'
:
'
bil-por
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
# noqa: E501
({
({
'
description
'
:
'
SRV_GCS CUSTOMER FCCN MICROSOFT #FCCN_NoveSBE_ExpressRoute_Vlan1945 | UNIT CONFIGURATION HAS BEEN SYSTEM GENERATED
'
,
# noqa: E501
'
description
'
:
'
SRV_GCS CUSTOMER FCCN MICROSOFT #FCCN_NoveSBE_ExpressRoute_Vlan1945 | UNIT CONFIGURATION HAS BEEN SYSTEM GENERATED
'
,
# noqa: E501
'
dashboards
'
:
[
'
GCS
'
]
'
dashboards
'
:
[
'
GCS
'
]
},
[
'
FCCN
'
],
{
'
name
'
:
'
FCCN
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
},
[
{
'
name
'
:
'
FCCN
'
}
],
{
'
name
'
:
'
FCCN
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
({
({
'
description
'
:
'
PHY UPSTREAM TELIA SRF9940473 | Telia ID: IC-326863
'
,
'
description
'
:
'
PHY UPSTREAM TELIA SRF9940473 | Telia ID: IC-326863
'
,
'
router
'
:
'
mx1.bud.hu.geant.net
'
,
'
router
'
:
'
mx1.bud.hu.geant.net
'
,
'
dashboards
'
:
[
'
GWS_PHY_UPSTREAM
'
]
'
dashboards
'
:
[
'
GWS_PHY_UPSTREAM
'
]
},
[
'
TELIA - BUD
'
],
{
'
name
'
:
'
TELIA - BUD
'
,
'
interface_type
'
:
'
PHYSICAL
'
}),
},
[
{
'
name
'
:
'
TELIA - BUD
'
}
],
{
'
name
'
:
'
TELIA - BUD
'
,
'
interface_type
'
:
'
PHYSICAL
'
}),
# noqa: E501
({
({
'
description
'
:
'
SRV_IAS UPSTREAM COGENT #COGENT_GWS_VIE | ASN174
'
,
'
description
'
:
'
SRV_IAS UPSTREAM COGENT #COGENT_GWS_VIE | ASN174
'
,
'
dashboards
'
:
[
'
IAS_UPSTREAM
'
]
'
dashboards
'
:
[
'
IAS_UPSTREAM
'
]
},
[
'
COGENT
'
],
{
'
name
'
:
'
COGENT
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
},
[
{
'
name
'
:
'
COGENT
'
}
],
{
'
name
'
:
'
COGENT
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
({
({
'
description
'
:
'
SRV_L3VPN RE_INTERCONNECT CLARA #REDCLARA-LIS-LHCONE | ASN27750
'
,
# noqa: E501
'
description
'
:
'
SRV_L3VPN RE_INTERCONNECT CLARA #REDCLARA-LIS-LHCONE | ASN27750
'
,
# noqa: E501
'
dashboards
'
:
[
'
LHCONE
'
,
'
LHCONE_PEER
'
,
'
RE_PEER
'
]
'
dashboards
'
:
[
'
LHCONE
'
,
'
LHCONE_PEER
'
,
'
RE_PEER
'
]
},
[
'
CLARA
'
],
{
'
name
'
:
'
CLARA
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
},
[
{
'
name
'
:
'
CLARA
'
}
],
{
'
name
'
:
'
CLARA
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
({
({
'
description
'
:
'
SRV_MDVPN CUSTOMER REDIRIS #RedIRIS_AP1_BGP_LU_CoC_1 | MD VPN CoC-REDIRIS -
'
,
# noqa: E501
'
description
'
:
'
SRV_MDVPN CUSTOMER REDIRIS #RedIRIS_AP1_BGP_LU_CoC_1 | MD VPN CoC-REDIRIS -
'
,
# noqa: E501
'
dashboards
'
:
[
'
MDVPN_CUSTOMERS
'
,
'
NREN
'
]
'
dashboards
'
:
[
'
MDVPN_CUSTOMERS
'
,
'
NREN
'
]
},
[
'
REDIRIS
'
],
{
'
name
'
:
'
REDIRIS
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
},
[
{
'
name
'
:
'
REDIRIS
'
}
],
{
'
name
'
:
'
REDIRIS
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
# noqa: E501
({
({
'
description
'
:
'
SRV_L2CIRCUIT CUSTOMER TENET PSNC #lon-lon-GEANTOPEN-PSNC-TENET-18067 |
'
,
# noqa: E501
'
description
'
:
'
SRV_L2CIRCUIT CUSTOMER TENET PSNC #lon-lon-GEANTOPEN-PSNC-TENET-18067 |
'
,
# noqa: E501
'
dashboards
'
:
[
'
GEANTOPEN
'
,
'
L2_CIRCUIT
'
]
'
dashboards
'
:
[
'
GEANTOPEN
'
,
'
L2_CIRCUIT
'
]
},
[
'
TENET
'
,
'
PSNC
'
],
{
'
name
'
:
'
TENET
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
},
[
{
'
name
'
:
'
TENET
'
}
,
{
'
name
'
:
'
PSNC
'
}
],
{
'
name
'
:
'
TENET
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
# noqa: E501
({
({
'
description
'
:
'
SRV_GLOBAL INFRASTRUCTURE BACKBONE SRF0000001
'
,
'
description
'
:
'
SRV_GLOBAL INFRASTRUCTURE BACKBONE SRF0000001
'
,
'
dashboards
'
:
[
'
INFRASTRUCTURE_BACKBONE
'
]
'
dashboards
'
:
[
'
INFRASTRUCTURE_BACKBONE
'
]
},
},
[
'
SRV_GLOBAL INFRASTRUCTURE BACKBONE SRF0000001
'
],
[
{
'
name
'
:
'
SRV_GLOBAL INFRASTRUCTURE BACKBONE SRF0000001
'
}
],
{
'
name
'
:
'
SRV_GLOBAL INFRASTRUCTURE BACKBONE SRF0000001
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
# noqa: E501
{
'
name
'
:
'
SRV_GLOBAL INFRASTRUCTURE BACKBONE SRF0000001
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
# noqa: E501
({
({
'
description
'
:
'
SRV_MDVPN CUSTOMER
'
,
'
description
'
:
'
SRV_MDVPN CUSTOMER
'
,
'
dashboards
'
:
[
'
MDVPN_CUSTOMERS
'
,
'
NREN
'
]
'
dashboards
'
:
[
'
MDVPN_CUSTOMERS
'
,
'
NREN
'
]
},
},
[
'
SRV_MDVPN CUSTOMER
'
],
[
{
'
name
'
:
'
SRV_MDVPN CUSTOMER
'
}
],
{
'
name
'
:
'
SRV_MDVPN CUSTOMER
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
{
'
name
'
:
'
SRV_MDVPN CUSTOMER
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
({
({
'
description
'
:
'
SRV_MDVPN CUSTOMER
'
,
'
description
'
:
'
SRV_MDVPN CUSTOMER
'
,
'
dashboards
'
:
[
'
MDVPN_CUSTOMERS
'
,
'
NREN
'
]
'
dashboards
'
:
[
'
MDVPN_CUSTOMERS
'
,
'
NREN
'
]
},
},
[
'
SRV_MDVPN CUSTOMER
'
],
[
{
'
name
'
:
'
SRV_MDVPN CUSTOMER
'
}
],
{
'
name
'
:
'
SRV_MDVPN CUSTOMER
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
{
'
name
'
:
'
SRV_MDVPN CUSTOMER
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
({
({
'
description
'
:
'
SRV_L3VPN RE_INTERCONNECT REDCLARA #REDCLARA-MAD-COPERNICUS | ASN27750
'
,
# noqa: E501
'
description
'
:
'
SRV_L3VPN RE_INTERCONNECT REDCLARA #REDCLARA-MAD-COPERNICUS | ASN27750
'
,
# noqa: E501
'
dashboards
'
:
[
'
COPERNICUS
'
]
'
dashboards
'
:
[
'
COPERNICUS
'
]
},
[
'
REDCLARA
'
],
{
'
name
'
:
'
REDCLARA
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
},
[
{
'
name
'
:
'
REDCLARA
'
}
],
{
'
name
'
:
'
REDCLARA
'
,
'
interface_type
'
:
'
LOGICAL
'
}),
# noqa: E501
])
])
def
test_description_dashboard_parsing
(
def
test_description_dashboard_parsing
(
interface
,
expected_na
mes
,
dashboard_info
):
interface
,
custo
me
r
s
,
dashboard_info
):
updated
=
poller
.
_get_dashboard_data
(
interface
,
expected_na
mes
)
updated
=
poller
.
_get_dashboard_data
(
interface
,
custo
me
r
s
)
info
=
updated
[
'
dashboard_info
'
]
info
=
updated
[
'
dashboard_info
'
]
assert
info
==
dashboard_info
assert
info
==
dashboard_info
dashboards_info
=
updated
[
'
dashboards_info
'
]
dashboards_info
=
updated
[
'
dashboards_info
'
]
expected_names
=
[
c
[
'
name
'
]
for
c
in
customers
]
assert
set
(
expected_names
)
==
{
d
[
'
name
'
]
for
d
in
dashboards_info
}
assert
set
(
expected_names
)
==
{
d
[
'
name
'
]
for
d
in
dashboards_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