b2a3de5f4f
* restoring each database with all data before warmboot and then flush unused data in each instance, following the multiDB warmboot design at https://github.com/Azure/SONiC/blob/master/doc/database/multi_database_instances.md * restore needs to be done in database docker since we need to know the database_config.json in new version * copy all data rdb file into each instance restoration location andthen flush unused database * other logic is the same as before * backing up database part is in another PR at sonic-utilities https://github.com/Azure/sonic-utilities/pull/1205, they depend on each other
29 lines
803 B
Python
Executable File
29 lines
803 B
Python
Executable File
#!/usr/bin/python
|
|
import swsssdk
|
|
import redis
|
|
import subprocess
|
|
import time
|
|
|
|
while(True):
|
|
output = subprocess.Popen(['sonic-db-cli', 'PING'], stdout=subprocess.PIPE).communicate()[0]
|
|
if 'PONG' in output:
|
|
break
|
|
time.sleep(1)
|
|
|
|
instlists = swsssdk.SonicDBConfig.get_instancelist()
|
|
for instname, v in instlists.items():
|
|
insthost = v['hostname']
|
|
instsocket = v['unix_socket_path']
|
|
|
|
dblists = swsssdk.SonicDBConfig.get_dblist()
|
|
for dbname in dblists:
|
|
dbid = swsssdk.SonicDBConfig.get_dbid(dbname)
|
|
dbinst = swsssdk.SonicDBConfig.get_instancename(dbname)
|
|
|
|
# this DB is on current instance, skip flush
|
|
if dbinst == instname:
|
|
continue
|
|
|
|
r = redis.Redis(host=insthost, unix_socket_path=instsocket, db=dbid)
|
|
r.flushdb()
|