-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MultiDB] add mutidb warmboot support - restoring database
- Loading branch information
1 parent
fdb51e7
commit 4302c61
Showing
4 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/python | ||
import swsssdk | ||
import redis | ||
import subprocess | ||
import time | ||
|
||
output = subprocess.check_output('sonic-db-cli PING', stderr=subprocess.STDOUT, shell=True) | ||
while('PONG' not in output): | ||
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters