Skip to content

Commit d79d189

Browse files
authored
Update SonicDBConfig APIs for centralize_database (sonic-net#1441)
The DB backup during warmboot has started failing recently after the changes made to deprecate the usage of SonicDBConfig methods originally implemented by python in https://github.com/Azure/sonic-py-swsssdk/. The new implementation is based on hiredis C++ library. How I did it: The centralize_database script still uses the Python APIs instead of C++, update the method names which are now defined in sonic-swss-common. With the new changes, the warm-boot goes ahead without DB save errors.
1 parent d8b224f commit d79d189

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

scripts/centralize_database

+8-8
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ import redis
66
import argparse
77

88
def centralize_to_target_db(target_dbname):
9-
target_dbport = SonicDBConfig.get_port(target_dbname)
10-
target_dbhost = SonicDBConfig.get_hostname(target_dbname)
9+
target_dbport = SonicDBConfig.getDbPort(target_dbname)
10+
target_dbhost = SonicDBConfig.getDbHostname(target_dbname)
1111

12-
dblists = SonicDBConfig.get_dblist()
12+
dblists = SonicDBConfig.getDbList()
1313
for dbname in dblists:
14-
dbport = SonicDBConfig.get_port(dbname)
15-
dbhost = SonicDBConfig.get_hostname(dbname)
14+
dbport = SonicDBConfig.getDbPort(dbname)
15+
dbhost = SonicDBConfig.getDbHostname(dbname)
1616
# if the db is on the same instance, no need to move
1717
if dbport == target_dbport and dbhost == target_dbhost:
1818
continue
1919

20-
dbsocket = SonicDBConfig.get_socket(dbname)
21-
dbid = SonicDBConfig.get_dbid(dbname)
20+
dbsocket = SonicDBConfig.getDbSock(dbname)
21+
dbid = SonicDBConfig.getDbId(dbname)
2222

2323
r = redis.Redis(host=dbhost, unix_socket_path=dbsocket, db=dbid)
2424

@@ -49,7 +49,7 @@ Example : centralize_database APPL_DB
4949
if args.target_db:
5050
try:
5151
centralize_to_target_db(args.target_db)
52-
print(SonicDBConfig.get_instancename(args.target_db))
52+
print(SonicDBConfig.getDbInst(args.target_db))
5353
except Exception as ex:
5454
template = "An exception of type {0} occurred. Arguments:\n{1!r}"
5555
message = template.format(type(ex).__name__, ex.args)

0 commit comments

Comments
 (0)