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
d3d956cf
Commit
d3d956cf
authored
6 years ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
use snmp community from netconf
parent
6a8fe7a5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
inventory_provider/tasks/worker.py
+48
-7
48 additions, 7 deletions
inventory_provider/tasks/worker.py
with
48 additions
and
7 deletions
inventory_provider/tasks/worker.py
+
48
−
7
View file @
d3d956cf
...
...
@@ -215,6 +215,53 @@ def update_junosspace_device_list():
task_logger
.
debug
(
'
<<< update_junosspace_device_list
'
)
def
load_netconf_data
(
hostname
):
"""
this method should only be called from a task
:param hostname:
:return:
"""
r
=
get_redis
(
InventoryTask
.
config
)
netconf
=
r
.
get
(
'
netconf:
'
+
hostname
)
if
not
netconf
:
return
None
return
etree
.
fromstring
(
netconf
.
decode
(
'
utf-8
'
))
def
clear_cached_classifier_responses
(
hostname
):
task_logger
=
logging
.
getLogger
(
constants
.
TASK_LOGGER_NAME
)
task_logger
.
debug
(
'
removing cached classifier responses for %r
'
%
hostname
)
r
=
get_redis
(
InventoryTask
.
config
)
for
k
in
r
.
keys
(
'
classifier:cache:%s:*
'
%
hostname
):
r
.
delete
(
k
)
@app.task
()
def
update_router_config
(
hostname
):
task_logger
=
logging
.
getLogger
(
constants
.
TASK_LOGGER_NAME
)
task_logger
.
debug
(
'
>>> update_router_config
'
)
netconf_refresh_config
.
apply
(
hostname
)
netconf_doc
=
load_netconf_data
(
hostname
)
if
not
netconf_doc
:
task_logger
.
error
(
'
no netconf data available for %r
'
%
hostname
)
else
:
community
=
juniper
.
snmp_community_string
(
netconf_doc
)
if
not
community
:
task_logger
.
error
(
'
error extracting community string for %r
'
%
hostname
)
else
:
snmp_refresh_interfaces
.
apply
(
hostname
,
community
)
# TODO: move this out of else? (i.e. clear even if netconf fails?)
clear_cached_classifier_responses
(
hostname
)
task_logger
.
debug
(
'
<<< update_router_config
'
)
def
_derive_router_hostnames
(
config
):
r
=
get_redis
(
config
)
junosspace_equipment
=
set
()
...
...
@@ -261,12 +308,6 @@ def start_refresh_cache_all(config):
for
hostname
in
_derive_router_hostnames
(
config
):
task_logger
.
debug
(
'
queueing router refresh jobs for %r
'
%
hostname
)
# TODO: !!!! extract community string from netconf data
task_logger
.
error
(
'
TODO: !!!! extract community string from netconf data
'
)
subtasks
.
append
(
netconf_refresh_config
.
s
(
hostname
))
# TODO: these should be synchronous, and then cleanup classifier cache
subtasks
.
append
(
snmp_refresh_interfaces
.
s
(
hostname
,
'
0pBiFbD
'
))
subtasks
.
append
(
update_router_config
.
s
(
hostname
))
return
group
(
subtasks
).
apply_async
()
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