Commit 6bc1457
committed
Improve facts gathering while creating SonicHost instance
The SonicHost __init__ method needs to run multiple commands on the SONiC host to gather some basic facts. Execution of each command has some overhead. To improve the performance, multi threads were introduced to run the commands in parallel. It looks like a over kill. In some scenarios, it will cause multiple threads in multiple threads and could make things even more complicated. What's more, getting versions still need to run commands on SONiC host multiple times.
To simplify the procedure of gathering facts and ensure performance at the same time, this change introduced a new customized ansible module `sonic_basic_facts.py`. This module will be executed on SONiC host and use various methods to directly gather facts:
* call sonic_py_common library
* read from config_db using DB connector
* read files
The time requred to run the `sonic_basic_facts` module is similiar as running a single command on the SONiC device.
By this method, the code for gathering facts is significantly simplified with even better performance. When there is no cache, run a script may need 10 seconds less.
The __init__ method of MultiAsicSonicHost is also updated to use gathered facts instead of running the config_facts module which is a little bit slow and produces too much log.
Signed-off-by: Xin Wang <[email protected]>1 parent d6aba5c commit 6bc1457
File tree
3 files changed
+521
-214
lines changed- ansible/library
- tests/common/devices
3 files changed
+521
-214
lines changed
0 commit comments