From d79d189c3ef8f8a4ede952febd38223ad8e79a79 Mon Sep 17 00:00:00 2001 From: Vaibhav Hemant Dixit Date: Mon, 22 Feb 2021 08:41:36 -0800 Subject: [PATCH] Update SonicDBConfig APIs for centralize_database (#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. --- scripts/centralize_database | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/centralize_database b/scripts/centralize_database index c32b19b647..3b50184eac 100755 --- a/scripts/centralize_database +++ b/scripts/centralize_database @@ -6,19 +6,19 @@ import redis import argparse def centralize_to_target_db(target_dbname): - target_dbport = SonicDBConfig.get_port(target_dbname) - target_dbhost = SonicDBConfig.get_hostname(target_dbname) + target_dbport = SonicDBConfig.getDbPort(target_dbname) + target_dbhost = SonicDBConfig.getDbHostname(target_dbname) - dblists = SonicDBConfig.get_dblist() + dblists = SonicDBConfig.getDbList() for dbname in dblists: - dbport = SonicDBConfig.get_port(dbname) - dbhost = SonicDBConfig.get_hostname(dbname) + dbport = SonicDBConfig.getDbPort(dbname) + dbhost = SonicDBConfig.getDbHostname(dbname) # if the db is on the same instance, no need to move if dbport == target_dbport and dbhost == target_dbhost: continue - dbsocket = SonicDBConfig.get_socket(dbname) - dbid = SonicDBConfig.get_dbid(dbname) + dbsocket = SonicDBConfig.getDbSock(dbname) + dbid = SonicDBConfig.getDbId(dbname) r = redis.Redis(host=dbhost, unix_socket_path=dbsocket, db=dbid) @@ -49,7 +49,7 @@ Example : centralize_database APPL_DB if args.target_db: try: centralize_to_target_db(args.target_db) - print(SonicDBConfig.get_instancename(args.target_db)) + print(SonicDBConfig.getDbInst(args.target_db)) except Exception as ex: template = "An exception of type {0} occurred. Arguments:\n{1!r}" message = template.format(type(ex).__name__, ex.args)