File tree 5 files changed +26
-8
lines changed
5 files changed +26
-8
lines changed Original file line number Diff line number Diff line change 9
9
import tabulate
10
10
import pyangbind .lib .pybindJSON as pybindJSON
11
11
from natsort import natsorted
12
- from sonic_py_common import device_info
12
+ from sonic_py_common import device_info , multi_asic
13
13
from swsscommon .swsscommon import SonicV2Connector , ConfigDBConnector , SonicDBConfig
14
14
15
15
@@ -114,8 +114,13 @@ def __init__(self):
114
114
self .tables_db_info = {}
115
115
self .rules_db_info = {}
116
116
self .rules_info = {}
117
- # Load global db config. This call is no-op in single npu platforms
118
- SonicDBConfig .load_sonic_global_db_config ()
117
+
118
+ if multi_asic .is_multi_asic ():
119
+ # Load global db config
120
+ SonicDBConfig .load_sonic_global_db_config ()
121
+ else :
122
+ SonicDBConfig .initialize ()
123
+
119
124
self .sessions_db_info = {}
120
125
self .configdb = ConfigDBConnector ()
121
126
self .configdb .connect ()
Original file line number Diff line number Diff line change @@ -211,15 +211,20 @@ def cli(ctx):
211
211
# Use the db object if given as input.
212
212
db = None if ctx .obj is None else ctx .obj .cfgdb
213
213
214
+ # Note: SonicDBConfig may be already initialized in unit test, then skip
215
+ if not SonicDBConfig .isInit ():
216
+ if multi_asic .is_multi_asic ():
217
+ # Load the global config file database_global.json once.
218
+ SonicDBConfig .load_sonic_global_db_config ()
219
+ else :
220
+ SonicDBConfig .initialize ()
221
+
214
222
context = {
215
223
"crm" : Crm (db )
216
224
}
217
225
218
226
ctx .obj = context
219
227
220
- # Load the global config file database_global.json once.
221
- SonicDBConfig .load_sonic_global_db_config ()
222
-
223
228
@cli .group ()
224
229
@click .pass_context
225
230
def config (ctx ):
Original file line number Diff line number Diff line change @@ -555,6 +555,8 @@ def main():
555
555
556
556
if args .namespace is not None :
557
557
SonicDBConfig .load_sonic_global_db_config (namespace = args .namespace )
558
+ else :
559
+ SonicDBConfig .initialize ()
558
560
559
561
if socket_path :
560
562
dbmgtr = DBMigrator (namespace , socket = socket_path )
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ import subprocess
25
25
import sys
26
26
import xml .etree .ElementTree as ET
27
27
28
- from sonic_py_common import device_info
28
+ from sonic_py_common import device_info , multi_asic
29
29
from swsscommon .swsscommon import ConfigDBConnector , SonicDBConfig
30
30
from tabulate import tabulate
31
31
@@ -47,7 +47,11 @@ class Lldpshow(object):
47
47
# So far only find Router and Bridge two capabilities in lldpctl, so any other capacility types will be read as Other
48
48
# if further capability type is supported like WLAN, can just add the tag definition here
49
49
self .ctags = {'Router' : 'R' , 'Bridge' : 'B' }
50
- SonicDBConfig .load_sonic_global_db_config ()
50
+
51
+ if multi_asic .is_multi_asic ():
52
+ SonicDBConfig .load_sonic_global_db_config ()
53
+ else :
54
+ SonicDBConfig .initialize ()
51
55
52
56
# For multi-asic platforms we will get only front-panel interface to display
53
57
namespaces = device_info .get_all_namespaces ()
Original file line number Diff line number Diff line change @@ -82,6 +82,8 @@ def main():
82
82
83
83
if args .namespace is not None :
84
84
SonicDBConfig .load_sonic_global_db_config (namespace = args .namespace )
85
+ else :
86
+ SonicDBConfig .initialize ()
85
87
86
88
try :
87
89
port = portconfig (args .verbose , args .port , args .namespace )
You can’t perform that action at this time.
0 commit comments