2021-05-20 17:47:46 -05:00
|
|
|
#!/usr/bin/python3
|
2020-12-10 13:06:19 -06:00
|
|
|
import swsssdk
|
|
|
|
import redis
|
|
|
|
import subprocess
|
|
|
|
import time
|
|
|
|
|
|
|
|
while(True):
|
2021-05-31 07:36:24 -05:00
|
|
|
output = subprocess.Popen(['sonic-db-cli', 'PING'], stdout=subprocess.PIPE, text=True).communicate()[0]
|
2020-12-10 13:06:19 -06:00
|
|
|
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()
|