forked from sonic-net/sonic-mgmt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[multi-asic]: Add function to load database config (sonic-net#4112)
What is the motivation for this PR? With the changes in sonic-net/sonic-buildimage#8173, the applications that connect to namespace dbs have to load global database configuration. Due to this change, the sonic-py-common.multi_asic functions that connect to database will fail if database configuration is not loaded in ansible library functions. How did you do it? Add a new module_utility library function to load the right db configuration based on single or multi-asic platform. Invoke this function in port_util and lag_facts where mutli_asic library function is invoked which connects to db. How did you verify/test it? Bring up a multi-asic VS testbed. ./testbed-cli.sh -t vtestbed.csv -m veos_vtb -k ceos add-topo vms-kvm-four-asic-t1-lag password.txt Before adding this change, failure seen while running test_bgp_fact.py
- Loading branch information
1 parent
ef9bd43
commit 21a9d1e
Showing
3 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
def load_db_config(): | ||
''' | ||
Load the correct database config file: | ||
- database_global.json for multi asic | ||
- database_config.json for single asic | ||
Loading database config file is not required for | ||
201911 images so ignore import error or function | ||
name error. | ||
''' | ||
try: | ||
from sonic_py_common import multi_asic | ||
from swsscommon import swsscommon | ||
if multi_asic.is_multi_asic(): | ||
if not swsscommon.SonicDBConfig.isGlobalInit(): | ||
swsscommon.SonicDBConfig.load_sonic_global_db_config() | ||
else: | ||
if not swsscommon.SonicDBConfig.isInit(): | ||
swsscommon.SonicDBConfig.load_sonic_db_config() | ||
except ImportError: | ||
pass | ||
except NameError: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters