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
6eebf4c3
Commit
6eebf4c3
authored
1 year ago
by
Sam Roberts
Browse files
Options
Downloads
Patches
Plain Diff
fix bugs, make the update chords work as intended
parent
64ef3a85
No related branches found
No related tags found
1 merge request
!22
Feature/pol1 744 fix speed issues
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
inventory_provider/juniper.py
+11
-3
11 additions, 3 deletions
inventory_provider/juniper.py
inventory_provider/tasks/worker.py
+13
-9
13 additions, 9 deletions
inventory_provider/tasks/worker.py
with
24 additions
and
12 deletions
inventory_provider/juniper.py
+
11
−
3
View file @
6eebf4c3
...
...
@@ -11,6 +11,7 @@ from jnpr.junos import exception as EzErrors
from
lxml
import
etree
import
netifaces
import
requests
from
ncclient.xml_
import
to_xml
CONFIG_SCHEMA
=
"""
<?xml version=
"
1.1
"
encoding=
"
UTF-8
"
?>
<xs:schema xmlns:xs=
"
http://www.w3.org/2001/XMLSchema
"
>
...
...
@@ -119,6 +120,10 @@ class NetconfHandlingError(Exception):
pass
class
TimeoutError
(
Exception
):
pass
TIMEOUT
=
10.0
...
...
@@ -135,8 +140,10 @@ def _nc_connection(host_params, ssh_params):
try
:
yield
conn
# wait here until caller context ends
except
EzErrors
.
ConnectTimeoutError
:
raise
TimeoutError
finally
:
conn
.
close
()
conn
.
close
_session
()
def
_raw_rpc
(
router
,
command
):
...
...
@@ -144,7 +151,8 @@ def _raw_rpc(router, command):
# query for router configs
# this is needed for querying for other things eg. interface speeds
obj
=
router
.
rpc
(
command
)
return
obj
.
reply
xml
=
obj
.
tostring
return
xml
@contextlib.contextmanager
...
...
@@ -487,7 +495,7 @@ def get_interface_info_for_router(hostname, ssh_config):
host_params
=
host_params
,
ssh_params
=
ssh_config
)
as
router
:
reply
=
_raw_rpc
(
router
,
etree
.
Element
(
'
get-interface-information
'
))
return
reply
.
xml
return
reply
def
get_interface_speeds
(
interface_info
):
...
...
This diff is collapsed.
Click to expand it.
inventory_provider/tasks/worker.py
+
13
−
9
View file @
6eebf4c3
...
...
@@ -451,16 +451,18 @@ def update_entry_point(self):
chord
(
(
ims_task
.
s
().
on_error
(
task_error_handler
.
s
()),
chord
(
(
reload_router_config_chorded
.
s
(
r
)
for
r
in
routers
),
empty_task
.
si
(
'
router tasks complete
'
)
chord
((
chord
(
(
reload_router_config_chorded
.
s
(
r
)
for
r
in
routers
),
empty_task
.
si
(
'
router tasks complete
'
)
),
chord
(
(
reload_lab_router_config_chorded
.
s
(
r
)
for
r
in
lab_routers
),
empty_task
.
si
(
'
lab router tasks complete
'
)
)),
collate_netconf_interfaces_all_cache
.
si
().
on_error
(
task_error_handler
.
s
())
),
chord
(
(
reload_lab_router_config_chorded
.
s
(
r
)
for
r
in
lab_routers
),
empty_task
.
si
(
'
lab router tasks complete
'
)
),
collate_netconf_interfaces_all_cache
.
s
().
on_error
(
task_error_handler
.
s
())
),
final_task
.
si
().
on_error
(
task_error_handler
.
s
())
)()
...
...
@@ -1462,6 +1464,8 @@ def collate_netconf_interfaces_all_cache(warning_callback=lambda s: None):
for
k
in
r
.
scan_iter
(
key_pattern
,
count
=
1000
):
key
=
k
.
decode
(
'
utf-8
'
)
doc_str
=
r
.
get
(
key
).
decode
(
'
utf-8
'
)
doc
=
json
.
loads
(
doc_str
)
doc
[
'
hostname
'
]
=
k
.
split
(
'
:
'
)[
1
]
# get hostname part of key
yield
json
.
loads
(
doc_str
)
netconf_all_key
=
'
netconf-interfaces:all
'
...
...
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