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
b12fd2f2
Commit
b12fd2f2
authored
5 months ago
by
Robert Latta
Browse files
Options
Downloads
Patches
Plain Diff
added Nokia peer refresh. RE DBOARD3-1086
parent
2923edff
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
inventory_provider/tasks/worker.py
+46
-21
46 additions, 21 deletions
inventory_provider/tasks/worker.py
with
46 additions
and
21 deletions
inventory_provider/tasks/worker.py
+
46
−
21
View file @
b12fd2f2
...
@@ -400,7 +400,7 @@ def _build_snmp_peering_db(update_callback=lambda s: None):
...
@@ -400,7 +400,7 @@ def _build_snmp_peering_db(update_callback=lambda s: None):
key_prefix
=
'
snmp-peerings:hosts:
'
key_prefix
=
'
snmp-peerings:hosts:
'
for
k
in
r
.
scan_iter
(
f
'
{
key_prefix
}
*
'
,
count
=
1000
):
for
k
in
r
.
scan_iter
(
f
'
{
key_prefix
}
*
'
,
count
=
1000
):
key_name
=
k
.
decode
(
'
utf-8
'
)
key_name
=
k
.
decode
(
'
utf-8
'
)
hostname
=
key_name
[
len
(
key_prefix
):
]
hostname
=
key_name
.
split
(
'
:
'
)[
-
1
]
host_peerings
=
r
.
get
(
key_name
).
decode
(
'
utf-8
'
)
host_peerings
=
r
.
get
(
key_name
).
decode
(
'
utf-8
'
)
host_peerings
=
json
.
loads
(
host_peerings
)
host_peerings
=
json
.
loads
(
host_peerings
)
for
p
in
host_peerings
:
for
p
in
host_peerings
:
...
@@ -621,6 +621,43 @@ def _reload_router_config_nokia(
...
@@ -621,6 +621,43 @@ def _reload_router_config_nokia(
communities
=
_nokia_community_strings
(
InventoryTask
.
config
)
communities
=
_nokia_community_strings
(
InventoryTask
.
config
)
snmp_refresh_interfaces_nokia
(
hostname
,
state_doc
,
communities
,
r
,
info_callback
)
snmp_refresh_interfaces_nokia
(
hostname
,
state_doc
,
communities
,
r
,
info_callback
)
refresh_nokia_bgp_peers
(
hostname
,
netconf_doc
)
refresh_nokia_bgp_peers
(
hostname
,
netconf_doc
)
snmp_refresh_peerings_nokia
(
hostname
,
communities
)
def
snmp_refresh_peerings_nokia
(
hostname
,
communities
,
update_callback
=
lambda
S
:
None
):
get_peerings_func
=
functools
.
partial
(
snmp
.
get_peer_state_info_nokia
,
community
=
communities
[
'
inventory-provider
'
],
)
snmp_refresh_peerings
(
get_peerings_func
,
hostname
,
'
nokia
'
,
update_callback
=
update_callback
)
def
snmp_refresh_peerings
(
get_peerings_func
,
hostname
,
redis_key_group
,
update_callback
=
lambda
s
:
None
):
try
:
peerings
=
get_peerings_func
(
hostname
)
except
ConnectionError
:
msg
=
f
'
error loading snmp peering data from
{
hostname
}
'
logger
.
exception
(
msg
)
update_callback
(
msg
)
r
=
get_current_redis
(
InventoryTask
.
config
)
peerings
=
r
.
get
(
f
'
snmp-peerings:hosts:
{
redis_key_group
}
:
{
hostname
}
'
)
if
peerings
is
None
:
raise
InventoryTaskError
(
f
'
snmp error with
{
hostname
}
and no cached peering data found
'
)
# unnecessary json encode/decode here ... could be optimized
peerings
=
json
.
loads
(
peerings
.
decode
(
'
utf-8
'
))
update_callback
(
f
'
using cached snmp peering data for
{
hostname
}
'
)
r
=
get_next_redis
(
InventoryTask
.
config
)
r
.
set
(
f
'
snmp-peerings:hosts:
{
redis_key_group
}
:
{
hostname
}
'
,
json
.
dumps
(
peerings
))
update_callback
(
f
'
snmp peering info loaded from
{
hostname
}
'
)
def
retrieve_and_persist_config_nokia
(
def
retrieve_and_persist_config_nokia
(
...
@@ -1027,27 +1064,15 @@ def snmp_refresh_interfaces_juniper(
...
@@ -1027,27 +1064,15 @@ def snmp_refresh_interfaces_juniper(
@log_task_entry_and_exit
@log_task_entry_and_exit
def
snmp_refresh_peerings_juniper
(
def
snmp_refresh_peerings_juniper
(
hostname
,
community
,
logical_systems
,
update_callback
=
lambda
S
:
None
):
hostname
,
community
,
logical_systems
,
update_callback
=
lambda
S
:
None
):
try
:
peerings
=
list
(
snmp
.
get_peer_state_info_juniper
(
hostname
,
community
,
logical_systems
))
except
ConnectionError
:
msg
=
f
'
error loading snmp peering data from
{
hostname
}
'
logger
.
exception
(
msg
)
update_callback
(
msg
)
r
=
get_current_redis
(
InventoryTask
.
config
)
peerings
=
r
.
get
(
f
'
snmp-peerings:hosts:
{
hostname
}
'
)
if
peerings
is
None
:
raise
InventoryTaskError
(
f
'
snmp error with
{
peerings
}
'
f
'
and no cached peering data found
'
)
# unnecessary json encode/decode here ... could be optimized
peerings
=
json
.
loads
(
peerings
.
decode
(
'
utf-8
'
))
update_callback
(
f
'
using cached snmp peering data for
{
hostname
}
'
)
r
=
get_next_redis
(
InventoryTask
.
config
)
get_peerings_func
=
functools
.
partial
(
r
.
set
(
f
'
snmp-peerings:hosts:
{
hostname
}
'
,
json
.
dumps
(
peerings
))
snmp
.
get_peer_state_info_juniper
,
community
=
community
,
update_callback
(
f
'
snmp peering info loaded from
{
hostname
}
'
)
logical_systems
=
logical_systems
)
snmp_refresh_peerings
(
get_peerings_func
,
hostname
,
'
juniper
'
,
update_callback
=
update_callback
)
def
cache_extracted_ims_data
(
extracted_data
,
use_current
=
False
):
def
cache_extracted_ims_data
(
extracted_data
,
use_current
=
False
):
...
...
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