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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
geant-swd
dashboardv3
inventory-provider
Commits
fbfc3afd
Commit
fbfc3afd
authored
Mar 7, 2024
by
Robert Latta
Browse files
Options
Downloads
Patches
Plain Diff
removed redundant functions and returned netconf document. RE DBOARD3-894
parent
caf3e5fa
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
inventory_provider/tasks/worker.py
+10
-28
10 additions, 28 deletions
inventory_provider/tasks/worker.py
test/test_worker.py
+2
-2
2 additions, 2 deletions
test/test_worker.py
with
12 additions
and
30 deletions
inventory_provider/tasks/worker.py
+
10
−
28
View file @
fbfc3afd
...
...
@@ -568,11 +568,7 @@ def retrieve_and_persist_neteng_managed_device_list(
@log_task_entry_and_exit
def
reload_router_config_try_all
(
self
,
hostname
,
lab
=
False
):
try
:
_reload_router_config_nokia
(
hostname
,
lab
,
self
.
log_info
,
self
.
log_warning
)
reload_router_config_nokia
(
self
,
hostname
,
lab
)
except
Exception
as
e1
:
self
.
log_warning
(
f
'
error loading
{
hostname
}
info:
{
e1
}
- trying juniper
'
)
...
...
@@ -595,9 +591,12 @@ def reload_router_config_try_all(self, hostname, lab=False):
@log_task_entry_and_exit
def
reload_router_config_nokia
(
self
,
hostname
,
lab
=
False
):
try
:
netconf_doc
=
_reload_router_config_nokia
(
hostname
,
lab
,
self
.
log_info
,
self
.
log_warning
)
refresh_nokia_interface_list
(
hostname
,
netconf_doc
,
lab
)
self
.
log_info
(
f
'
loading netconf data for
{
"
lab
"
if
lab
else
""
}
{
hostname
}
'
)
netconf_doc
=
retrieve_and_persist_netconf_config_nokia
(
hostname
,
lab
,
self
.
log_warning
)
r
=
get_next_redis
(
InventoryTask
.
config
)
refresh_nokia_interface_list
(
hostname
,
netconf_doc
,
r
,
lab
)
except
Exception
as
e
:
errmsg
=
f
'
unhandled exception loading
{
hostname
}
info:
{
e
}
'
logger
.
exception
(
errmsg
)
...
...
@@ -606,19 +605,6 @@ def reload_router_config_nokia(self, hostname, lab=False):
# TODO: re-raise and handle in some common way for all tasks
@log_task_entry_and_exit
def
_reload_router_config_nokia
(
hostname
,
lab
=
False
,
info_callback
=
lambda
s
:
None
,
warning_callback
=
lambda
s
:
None
):
info_callback
(
f
'
loading netconf data for
{
"
lab
"
if
lab
else
""
}
{
hostname
}
'
)
return
retrieve_and_persist_netconf_config_nokia
(
hostname
,
lab
,
warning_callback
)
def
retrieve_and_persist_netconf_config_nokia
(
hostname
,
lab
=
False
,
update_callback
=
lambda
s
:
None
):
redis_key
=
f
'
netconf-nokia:
{
hostname
}
'
...
...
@@ -642,21 +628,17 @@ def retrieve_and_persist_netconf_config_nokia(
raise
InventoryTaskError
(
f
'
netconf error with
{
hostname
}
'
f
'
and no cached netconf data found
'
)
netconf_doc
=
etree
.
fromstring
(
netconf_str
)
logger
.
info
(
f
'
Returning cached netconf data for
{
hostname
}
'
)
update_callback
(
f
'
Returning cached netconf data for
{
hostname
}
'
)
r
=
get_next_redis
(
InventoryTask
.
config
)
r
.
set
(
redis_key
,
netconf_str
)
logger
.
info
(
f
'
netconf info loaded from
{
hostname
}
'
)
return
netconf_str
def
refresh_nokia_interface_list
(
hostname
,
netconf
,
lab
=
False
):
r
=
get_next_redis
(
InventoryTask
.
config
)
_refresh_nokia_interface_list
(
hostname
,
netconf
,
r
,
lab
)
return
netconf_doc
def
_
refresh_nokia_interface_list
(
hostname
,
netconf
,
redis
,
lab
=
False
):
def
refresh_nokia_interface_list
(
hostname
,
netconf
,
redis
,
lab
=
False
):
bundles_keybase
=
f
'
netconf-interface-bundles:
{
hostname
}
'
interfaces_all_key
=
f
'
netconf-interfaces-hosts:
{
hostname
}
'
...
...
This diff is collapsed.
Click to expand it.
test/test_worker.py
+
2
−
2
View file @
fbfc3afd
...
...
@@ -8,7 +8,7 @@ from inventory_provider.tasks import common
from
inventory_provider.tasks.worker
import
transform_ims_data
,
\
extract_ims_data
,
persist_ims_data
,
\
retrieve_and_persist_neteng_managed_device_list
,
\
populate_poller_interfaces_cache
,
_
refresh_nokia_interface_list
populate_poller_interfaces_cache
,
refresh_nokia_interface_list
def
test_extract_ims_data
(
mocker
):
...
...
@@ -844,7 +844,7 @@ def test_refresh_nokia_interface_list(mocked_redis, data_config):
netconf_doc
=
etree
.
parse
(
pathlib
.
Path
(
__file__
).
parent
.
joinpath
(
'
data/rt0.lon.uk.lab.office.geant.net-netconf-nokia.xml
'
))
r
=
common
.
_get_redis
(
data_config
)
_
refresh_nokia_interface_list
(
'
rt0.lon.uk.lab.office.geant.net
'
,
netconf_doc
,
r
,
True
)
refresh_nokia_interface_list
(
'
rt0.lon.uk.lab.office.geant.net
'
,
netconf_doc
,
r
,
True
)
keybase
=
'
lab:netconf-interface-bundles:rt0.lon.uk.lab.office.geant.net:
'
keys
=
r
.
keys
(
f
'
{
keybase
}
*
'
)
bundles
=
{}
...
...
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
sign in
to comment