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
cea4da4b
Commit
cea4da4b
authored
2 years ago
by
Bjarke Madsen
Browse files
Options
Downloads
Patches
Plain Diff
Add port_type parsing from description for BRIAN
parent
df06a688
No related branches found
No related tags found
1 merge request
!5
Add port_type parsing from description for BRIAN
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
inventory_provider/routes/poller.py
+19
-10
19 additions, 10 deletions
inventory_provider/routes/poller.py
test/test_general_poller_routes.py
+13
-0
13 additions, 0 deletions
test/test_general_poller_routes.py
with
32 additions
and
10 deletions
inventory_provider/routes/poller.py
+
19
−
10
View file @
cea4da4b
...
@@ -182,12 +182,13 @@ INTERFACE_LIST_SCHEMA = {
...
@@ -182,12 +182,13 @@ INTERFACE_LIST_SCHEMA = {
'
dashboards_info
'
:
{
'
dashboards_info
'
:
{
'
type
'
:
'
array
'
,
'
type
'
:
'
array
'
,
'
items
'
:
{
'
$ref
'
:
'
#/definitions/db_info
'
}
'
items
'
:
{
'
$ref
'
:
'
#/definitions/db_info
'
}
}
},
'
port_type
'
:
{
'
type
'
:
'
string
'
}
},
},
'
required
'
:
[
'
required
'
:
[
'
router
'
,
'
name
'
,
'
description
'
,
'
router
'
,
'
name
'
,
'
description
'
,
'
snmp-index
'
,
'
bundle
'
,
'
bundle-parents
'
,
'
snmp-index
'
,
'
bundle
'
,
'
bundle-parents
'
,
'
circuits
'
,
'
dashboards
'
],
'
circuits
'
,
'
dashboards
'
,
'
port_type
'
],
'
additionalProperties
'
:
False
'
additionalProperties
'
:
False
},
},
},
},
...
@@ -498,13 +499,6 @@ def _get_dashboard_data(ifc, customers):
...
@@ -498,13 +499,6 @@ def _get_dashboard_data(ifc, customers):
if
len
(
dashboards
)
==
0
:
if
len
(
dashboards
)
==
0
:
return
ifc
return
ifc
def
_get_l2_customer_names
(
description
):
info
=
description
.
upper
().
split
(
'
#
'
)[
0
].
split
(
'
|
'
)[
0
].
split
()[
1
:]
yield
info
[
1
]
if
info
[
0
]
in
[
'
CUSTOMER
'
,
'
RE_INTERCONNECT
'
]
\
and
len
(
info
)
>
2
and
info
[
2
]:
yield
info
[
2
]
def
_get_customer_name
(
description
):
def
_get_customer_name
(
description
):
name
=
description
.
split
(
'
'
)
name
=
description
.
split
(
'
'
)
if
len
(
name
)
>=
3
:
if
len
(
name
)
>=
3
:
...
@@ -720,6 +714,17 @@ def _add_bundle_parents(interfaces, hostname=None):
...
@@ -720,6 +714,17 @@ def _add_bundle_parents(interfaces, hostname=None):
yield
ifc
yield
ifc
def
_get_port_type
(
description
):
rex
=
re
.
search
(
r
'
\$([a-zA-Z]+\-\d+)
'
,
description
)
if
rex
:
sid
=
rex
.
group
(
1
)
if
'
GA
'
in
sid
:
return
'
access
'
elif
'
GS
'
in
sid
:
return
'
service
'
return
'
unknown
'
def
load_interfaces_to_poll
(
def
load_interfaces_to_poll
(
config
,
hostname
=
None
,
no_lab
=
False
,
use_next_redis
=
False
):
config
,
hostname
=
None
,
no_lab
=
False
,
use_next_redis
=
False
):
basic_interfaces
=
\
basic_interfaces
=
\
...
@@ -757,8 +762,12 @@ def load_interfaces_to_poll(
...
@@ -757,8 +762,12 @@ def load_interfaces_to_poll(
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
_get_dashboard_data
(
ifc
=
_get_dashboard_data
(
ifc
,
ifc_services_and_customers
.
get
(
'
customers
'
,
[]))
ifc
,
ifc_services_and_customers
.
get
(
'
customers
'
,
[]))
port_type
=
_get_port_type
(
ifc
[
'
description
'
])
ifc
[
'
port_type
'
]
=
port_type
yield
ifc
else
:
else
:
continue
continue
return
_get_populated_interfaces
(
basic_interfaces
)
return
_get_populated_interfaces
(
basic_interfaces
)
...
...
This diff is collapsed.
Click to expand it.
test/test_general_poller_routes.py
+
13
−
0
View file @
cea4da4b
...
@@ -412,6 +412,19 @@ def test_description_dashboard_parsing(
...
@@ -412,6 +412,19 @@ def test_description_dashboard_parsing(
assert
set
(
expected_names
)
==
{
d
[
'
name
'
]
for
d
in
dashboards_info
}
assert
set
(
expected_names
)
==
{
d
[
'
name
'
]
for
d
in
dashboards_info
}
@pytest.mark.parametrize
(
'
description,expected_port_type
'
,
[
(
'
SRV_IAS CUSTOMER JISC #JISC-AP1-IAS IASPS | ASN786
'
,
'
unknown
'
),
(
'
SRV_GLOBAL CUSTOMER RENATER #RENATER-AP1 $GS-00505 | ASN2200 |
'
,
'
service
'
),
# noqa: E501
(
'
PHY CUSTOMER AZSCIENCENET SRF19095 $GA-01599 | GEANT-10G-Baku-CO-Interxion|
'
,
'
access
'
)
# noqa: E501
])
def
test_description_port_type_parsing
(
description
,
expected_port_type
):
_port_type
=
poller
.
_get_port_type
(
description
)
assert
_port_type
==
expected_port_type
def
test_gws_config_json
(
client
):
def
test_gws_config_json
(
client
):
rv
=
client
.
get
(
rv
=
client
.
get
(
'
/poller/gws/direct-config
'
,
'
/poller/gws/direct-config
'
,
...
...
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