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
78ccaa1c
Commit
78ccaa1c
authored
1 year ago
by
Sam Roberts
Browse files
Options
Downloads
Patches
Plain Diff
fix timeout issue and speeds not being collected properly
parent
d7f0d8ef
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!22
Feature/pol1 744 fix speed issues
,
!21
Draft: Feature/pol1 744 fix speed issues
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
inventory_provider/juniper.py
+1
-1
1 addition, 1 deletion
inventory_provider/juniper.py
inventory_provider/routes/poller.py
+28
-11
28 additions, 11 deletions
inventory_provider/routes/poller.py
with
29 additions
and
12 deletions
inventory_provider/juniper.py
+
1
−
1
View file @
78ccaa1c
...
@@ -122,7 +122,7 @@ class TimeoutError(Exception):
...
@@ -122,7 +122,7 @@ class TimeoutError(Exception):
pass
pass
TIMEOUT
=
3.0
TIMEOUT
=
3
0
.0
@contextlib.contextmanager
@contextlib.contextmanager
...
...
This diff is collapsed.
Click to expand it.
inventory_provider/routes/poller.py
+
28
−
11
View file @
78ccaa1c
...
@@ -207,7 +207,6 @@ INTERFACE_LIST_SCHEMA = {
...
@@ -207,7 +207,6 @@ INTERFACE_LIST_SCHEMA = {
'
items
'
:
{
'
$ref
'
:
'
#/definitions/interface
'
}
'
items
'
:
{
'
$ref
'
:
'
#/definitions/interface
'
}
}
}
INTERFACE_SPEED_LIST_SCHEMA
=
{
INTERFACE_SPEED_LIST_SCHEMA
=
{
'
$schema
'
:
'
https://json-schema.org/draft-07/schema#
'
,
'
$schema
'
:
'
https://json-schema.org/draft-07/schema#
'
,
...
@@ -344,7 +343,6 @@ GWS_DIRECT_DATA_SCHEMA = {
...
@@ -344,7 +343,6 @@ GWS_DIRECT_DATA_SCHEMA = {
'
items
'
:
{
'
$ref
'
:
'
#/definitions/interface-counters
'
}
'
items
'
:
{
'
$ref
'
:
'
#/definitions/interface-counters
'
}
}
}
SERVICES_LIST_SCHEMA
=
{
SERVICES_LIST_SCHEMA
=
{
'
$schema
'
:
'
https://json-schema.org/draft-07/schema#
'
,
'
$schema
'
:
'
https://json-schema.org/draft-07/schema#
'
,
...
@@ -405,7 +403,6 @@ SERVICES_LIST_SCHEMA = {
...
@@ -405,7 +403,6 @@ SERVICES_LIST_SCHEMA = {
'
items
'
:
{
'
$ref
'
:
'
#/definitions/service
'
}
'
items
'
:
{
'
$ref
'
:
'
#/definitions/service
'
}
}
}
STRING_LIST_SCHEMA
=
{
STRING_LIST_SCHEMA
=
{
'
$schema
'
:
'
https://json-schema.org/draft-07/schema#
'
,
'
$schema
'
:
'
https://json-schema.org/draft-07/schema#
'
,
'
type
'
:
'
array
'
,
'
type
'
:
'
array
'
,
...
@@ -490,7 +487,6 @@ def _get_dashboards(interface):
...
@@ -490,7 +487,6 @@ def _get_dashboards(interface):
def
_get_dashboard_data
(
ifc
,
customers
):
def
_get_dashboard_data
(
ifc
,
customers
):
def
_get_interface_type
(
description
):
def
_get_interface_type
(
description
):
if
re
.
match
(
r
'
^PHY
'
,
description
):
if
re
.
match
(
r
'
^PHY
'
,
description
):
return
INTERFACE_TYPES
.
PHYSICAL
return
INTERFACE_TYPES
.
PHYSICAL
...
@@ -573,7 +569,6 @@ def _load_interface_bundles(config, hostname=None, use_next_redis=False):
...
@@ -573,7 +569,6 @@ def _load_interface_bundles(config, hostname=None, use_next_redis=False):
key_pattern
=
key_pattern
,
key_pattern
=
key_pattern
,
num_threads
=
20
,
num_threads
=
20
,
use_next_redis
=
use_next_redis
):
use_next_redis
=
use_next_redis
):
m
=
re
.
match
(
m
=
re
.
match
(
r
'
.*netconf-interface-bundles:([^:]+):(.+)
'
,
doc
[
'
key
'
])
r
'
.*netconf-interface-bundles:([^:]+):(.+)
'
,
doc
[
'
key
'
])
assert
m
assert
m
...
@@ -664,7 +659,6 @@ def _load_netconf_docs(
...
@@ -664,7 +659,6 @@ def _load_netconf_docs(
key_pattern
=
filter_pattern
,
key_pattern
=
filter_pattern
,
num_threads
=
10
,
num_threads
=
10
,
use_next_redis
=
use_next_redis
):
use_next_redis
=
use_next_redis
):
yield
{
yield
{
'
router
'
:
doc
[
'
key
'
][
key_prefix_len
:],
'
router
'
:
doc
[
'
key
'
][
key_prefix_len
:],
'
netconf
'
:
doc
[
'
value
'
]
'
netconf
'
:
doc
[
'
value
'
]
...
@@ -681,6 +675,7 @@ def _load_interfaces(
...
@@ -681,6 +675,7 @@ def _load_interfaces(
:param use_next_redis:
:param use_next_redis:
:return:
:return:
"""
"""
def
_load_docs
(
key_pattern
):
def
_load_docs
(
key_pattern
):
for
doc
in
_load_netconf_docs
(
config
,
key_pattern
,
use_next_redis
):
for
doc
in
_load_netconf_docs
(
config
,
key_pattern
,
use_next_redis
):
...
@@ -705,6 +700,19 @@ def _load_interfaces(
...
@@ -705,6 +700,19 @@ def _load_interfaces(
yield
from
_load_docs
(
f
'
lab:
{
base_key_pattern
}
'
)
yield
from
_load_docs
(
f
'
lab:
{
base_key_pattern
}
'
)
def
_add_speeds
(
config
,
interfaces
):
all_netconf_interfaces
=
list
(
common
.
load_json_docs
(
config
,
'
classifier-cache:netconf-interfaces:all
'
))
netconf_interface_index
=
{
f
"
{
ifc
[
'
router
'
]
}
---
{
ifc
[
'
name
'
]
}
"
:
ifc
for
ifc
in
all_netconf_interfaces
[
0
][
'
value
'
]}
for
ifc
in
interfaces
:
netconf_interface
=
netconf_interface_index
.
get
(
f
"
{
ifc
[
'
router
'
]
}
---
{
ifc
[
'
name
'
]
}
"
,
{})
if
'
speed
'
in
netconf_interface
:
ifc
[
'
speed
'
]
=
netconf_interface
[
'
speed
'
]
else
:
ifc
[
'
speed
'
]
=
''
yield
ifc
def
_add_bundle_parents
(
interfaces
,
hostname
=
None
):
def
_add_bundle_parents
(
interfaces
,
hostname
=
None
):
"""
"""
generator that adds bundle-parents info to each interface.
generator that adds bundle-parents info to each interface.
...
@@ -715,12 +723,16 @@ def _add_bundle_parents(interfaces, hostname=None):
...
@@ -715,12 +723,16 @@ def _add_bundle_parents(interfaces, hostname=None):
"""
"""
bundles
=
_load_interface_bundles
(
bundles
=
_load_interface_bundles
(
current_app
.
config
[
'
INVENTORY_PROVIDER_CONFIG
'
],
hostname
)
current_app
.
config
[
'
INVENTORY_PROVIDER_CONFIG
'
],
hostname
)
# create a quick look-up for interface details
interface_index
=
{
f
"
{
ifc
[
'
router
'
]
}
---
{
ifc
[
'
name
'
]
}
"
:
ifc
for
ifc
in
interfaces
}
for
ifc
in
interfaces
:
for
ifc
in
interfaces
:
router_bundle
=
bundles
.
get
(
ifc
[
'
router
'
],
None
)
router_bundle
=
bundles
.
get
(
ifc
[
'
router
'
],
None
)
if
router_bundle
:
if
router_bundle
:
base_ifc
=
ifc
[
'
name
'
].
split
(
'
.
'
)[
0
]
base_ifc
=
ifc
[
'
name
'
].
split
(
'
.
'
)[
0
]
ifc
[
'
bundle-parents
'
]
=
router_bundle
.
get
(
base_ifc
,
[])
bundle_parents
=
[
interface_index
.
get
(
f
"
{
ifc
[
'
router
'
]
}
---
{
bundle_ifc
}
"
)
for
bundle_ifc
in
router_bundle
.
get
(
base_ifc
,
[])]
ifc
[
'
bundle-parents
'
]
=
bundle_parents
yield
ifc
yield
ifc
...
@@ -780,6 +792,7 @@ def load_interfaces_to_poll(
...
@@ -780,6 +792,7 @@ def load_interfaces_to_poll(
yield
ifc
yield
ifc
else
:
else
:
continue
continue
return
_get_populated_interfaces
(
basic_interfaces
)
return
_get_populated_interfaces
(
basic_interfaces
)
...
@@ -880,13 +893,14 @@ def interface_speed(ifc):
...
@@ -880,13 +893,14 @@ def interface_speed(ifc):
logger
.
warning
(
f
'
unrecognised speed:
{
speed
}
, using _name_to_speed fallback
'
)
logger
.
warning
(
f
'
unrecognised speed:
{
speed
}
, using _name_to_speed fallback
'
)
return
_name_to_speed
(
ifc
[
'
name
'
])
return
_name_to_speed
(
ifc
[
'
name
'
])
else
:
else
:
logger
.
warning
(
f
'
no speed data for interface, using _name_to_speed fallback
'
)
return
_name_to_speed
(
ifc
[
'
name
'
])
return
_name_to_speed
(
ifc
[
'
name
'
])
if
ifc
[
'
bundle-parents
'
]:
if
ifc
[
'
bundle-parents
'
]:
if
not
ifc
[
'
name
'
].
startswith
(
'
ae
'
):
if
not
ifc
[
'
name
'
].
startswith
(
'
ae
'
):
logger
.
warning
(
logger
.
warning
(
f
'
ifc has bundle-parents, but name is
{
ifc
[
"
name
"
]
}
'
)
f
'
ifc has bundle-parents, but name is
{
ifc
[
"
name
"
]
}
'
)
return
sum
(
_
name_to_speed
(
name
)
for
name
in
ifc
[
'
bundle-parents
'
])
return
sum
(
_
get_speed
(
parent_ifc
)
for
parent_ifc
in
ifc
[
'
bundle-parents
'
])
return
_get_speed
(
ifc
)
return
_get_speed
(
ifc
)
...
@@ -903,7 +917,10 @@ def _load_interfaces_and_speeds(hostname=None):
...
@@ -903,7 +917,10 @@ def _load_interfaces_and_speeds(hostname=None):
current_app
.
config
[
'
INVENTORY_PROVIDER_CONFIG
'
],
current_app
.
config
[
'
INVENTORY_PROVIDER_CONFIG
'
],
hostname
,
hostname
,
no_lab
=
no_lab
)
no_lab
=
no_lab
)
with_bundles
=
_add_bundle_parents
(
basic_interfaces
,
hostname
)
basic_interfaces_with_speeds
=
_add_speeds
(
current_app
.
config
[
'
INVENTORY_PROVIDER_CONFIG
'
],
basic_interfaces
)
with_bundles
=
_add_bundle_parents
(
list
(
basic_interfaces_with_speeds
),
hostname
)
def
_result_ifc
(
ifc
):
def
_result_ifc
(
ifc
):
return
{
return
{
...
@@ -1007,9 +1024,9 @@ def eumetsat_multicast(hostname=None):
...
@@ -1007,9 +1024,9 @@ def eumetsat_multicast(hostname=None):
}
for
idx
in
range
(
1
,
73
)]
}
for
idx
in
range
(
1
,
73
)]
SUBSCRIPTIONS
.
append
(
SUBSCRIPTIONS
.
append
(
{
'
subscription
'
:
'
232.223.223.1
'
,
'
endpoint
'
:
'
193.17.9.7
'
})
{
'
subscription
'
:
'
232.223.223.1
'
,
'
endpoint
'
:
'
193.17.9.7
'
})
SUBSCRIPTIONS
.
append
(
SUBSCRIPTIONS
.
append
(
{
'
subscription
'
:
'
232.223.223.22
'
,
'
endpoint
'
:
'
193.17.9.7
'
})
{
'
subscription
'
:
'
232.223.223.22
'
,
'
endpoint
'
:
'
193.17.9.7
'
})
def
_oid
(
sub
):
def
_oid
(
sub
):
return
(
'
1.3.6.1.2.1.83.1.1.2.1.16
'
return
(
'
1.3.6.1.2.1.83.1.1.2.1.16
'
...
...
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