[MultiDB] (except ./src and ./dockers dirs): replace redis-cli with sonic-db-cli and use new DBConnector (#4035)
* [MultiDB] (except ./src and ./dockers dirs): replace redis-cli with sonic-db-cli and use new DBConnector * update comment for a potential bug * update comment * add TODO maker as review reqirement
This commit is contained in:
parent
d6aee4cc65
commit
42bffc1215
@ -22,8 +22,6 @@ SFP_MODULE_THRESHOLD_WIDTH = 56
|
|||||||
SFP_I2C_PAGE_SIZE = 256
|
SFP_I2C_PAGE_SIZE = 256
|
||||||
|
|
||||||
# parameters for DB connection
|
# parameters for DB connection
|
||||||
REDIS_HOSTNAME = "localhost"
|
|
||||||
REDIS_PORT = 6379
|
|
||||||
REDIS_TIMEOUT_USECS = 0
|
REDIS_TIMEOUT_USECS = 0
|
||||||
|
|
||||||
# parameters for SFP presence
|
# parameters for SFP presence
|
||||||
@ -190,10 +188,9 @@ class SfpUtil(SfpUtilBase):
|
|||||||
|
|
||||||
if self.db_sel == None:
|
if self.db_sel == None:
|
||||||
from swsscommon import swsscommon
|
from swsscommon import swsscommon
|
||||||
self.state_db = swsscommon.DBConnector(swsscommon.STATE_DB,
|
self.state_db = swsscommon.DBConnector("STATE_DB",
|
||||||
REDIS_HOSTNAME,
|
REDIS_TIMEOUT_USECS,
|
||||||
REDIS_PORT,
|
True))
|
||||||
REDIS_TIMEOUT_USECS)
|
|
||||||
|
|
||||||
# Subscribe to state table for SFP change notifications
|
# Subscribe to state table for SFP change notifications
|
||||||
self.db_sel = swsscommon.Select()
|
self.db_sel = swsscommon.Select()
|
||||||
|
@ -89,20 +89,20 @@ function preStartAction()
|
|||||||
docker cp /tmp/dump.rdb database:/var/lib/redis/
|
docker cp /tmp/dump.rdb database:/var/lib/redis/
|
||||||
fi
|
fi
|
||||||
{%- elif docker_container_name == "snmp" %}
|
{%- elif docker_container_name == "snmp" %}
|
||||||
docker exec -i database redis-cli -n 6 HSET 'DEVICE_METADATA|localhost' chassis_serial_number $(decode-syseeprom -s)
|
sonic-db-cli STATE_DB HSET 'DEVICE_METADATA|localhost' chassis_serial_number $(decode-syseeprom -s)
|
||||||
vrfenabled=`/usr/bin/redis-cli -n 4 hget "MGMT_VRF_CONFIG|vrf_global" mgmtVrfEnabled`
|
vrfenabled=`sonic-db-cli CONFIG_DB hget "MGMT_VRF_CONFIG|vrf_global" mgmtVrfEnabled`
|
||||||
v1SnmpTrapIp=`/usr/bin/redis-cli -n 4 hget "SNMP_TRAP_CONFIG|v1TrapDest" DestIp`
|
v1SnmpTrapIp=`sonic-db-cli CONFIG_DB hget "SNMP_TRAP_CONFIG|v1TrapDest" DestIp`
|
||||||
v1SnmpTrapPort=`/usr/bin/redis-cli -n 4 hget "SNMP_TRAP_CONFIG|v1TrapDest" DestPort`
|
v1SnmpTrapPort=`sonic-db-cli CONFIG_DB hget "SNMP_TRAP_CONFIG|v1TrapDest" DestPort`
|
||||||
v1Vrf=`/usr/bin/redis-cli -n 4 hget "SNMP_TRAP_CONFIG|v1TrapDest" vrf`
|
v1Vrf=`sonic-db-cli CONFIG_DB hget "SNMP_TRAP_CONFIG|v1TrapDest" vrf`
|
||||||
v1Comm=`/usr/bin/redis-cli -n 4 hget "SNMP_TRAP_CONFIG|v1TrapDest" Community`
|
v1Comm=`sonic-db-cli CONFIG_DB hget "SNMP_TRAP_CONFIG|v1TrapDest" Community`
|
||||||
v2SnmpTrapIp=`/usr/bin/redis-cli -n 4 hget "SNMP_TRAP_CONFIG|v2TrapDest" DestIp`
|
v2SnmpTrapIp=`sonic-db-cli CONFIG_DB hget "SNMP_TRAP_CONFIG|v2TrapDest" DestIp`
|
||||||
v2SnmpTrapPort=`/usr/bin/redis-cli -n 4 hget "SNMP_TRAP_CONFIG|v2TrapDest" DestPort`
|
v2SnmpTrapPort=`sonic-db-cli CONFIG_DB hget "SNMP_TRAP_CONFIG|v2TrapDest" DestPort`
|
||||||
v2Vrf=`/usr/bin/redis-cli -n 4 hget "SNMP_TRAP_CONFIG|v2TrapDest" vrf`
|
v2Vrf=`sonic-db-cli CONFIG_DB hget "SNMP_TRAP_CONFIG|v2TrapDest" vrf`
|
||||||
v2Comm=`/usr/bin/redis-cli -n 4 hget "SNMP_TRAP_CONFIG|v2TrapDest" Community`
|
v2Comm=`sonic-db-cli CONFIG_DB hget "SNMP_TRAP_CONFIG|v2TrapDest" Community`
|
||||||
v3SnmpTrapIp=`/usr/bin/redis-cli -n 4 hget "SNMP_TRAP_CONFIG|v3TrapDest" DestIp`
|
v3SnmpTrapIp=`sonic-db-cli CONFIG_DB hget "SNMP_TRAP_CONFIG|v3TrapDest" DestIp`
|
||||||
v3SnmpTrapPort=`/usr/bin/redis-cli -n 4 hget "SNMP_TRAP_CONFIG|v3TrapDest" DestPort`
|
v3SnmpTrapPort=`sonic-db-cli CONFIG_DB hget "SNMP_TRAP_CONFIG|v3TrapDest" DestPort`
|
||||||
v3Vrf=`/usr/bin/redis-cli -n 4 hget "SNMP_TRAP_CONFIG|v3TrapDest" vrf`
|
v3Vrf=`sonic-db-cli CONFIG_DB hget "SNMP_TRAP_CONFIG|v3TrapDest" vrf`
|
||||||
v3Comm=`/usr/bin/redis-cli -n 4 hget "SNMP_TRAP_CONFIG|v3TrapDest" Community`
|
v3Comm=`sonic-db-cli CONFIG_DB hget "SNMP_TRAP_CONFIG|v3TrapDest" Community`
|
||||||
|
|
||||||
if [ "${v1SnmpTrapIp}" != "" ]
|
if [ "${v1SnmpTrapIp}" != "" ]
|
||||||
then
|
then
|
||||||
@ -139,7 +139,11 @@ function preStartAction()
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo -n "" > /tmp/snmpagentaddr.yml
|
echo -n "" > /tmp/snmpagentaddr.yml
|
||||||
keys=`/usr/bin/redis-cli -n 4 keys "SNMP_AGENT_ADDRESS_CONFIG|*"`
|
# TODO
|
||||||
|
# we should avoid using 'keys' operation via redis-cli or sonic-db-cli
|
||||||
|
# there would be an issue when KEY in database contains space or '\n'
|
||||||
|
# for loop on the non-tty 'keys' output will take the space or `\n` as seperator when parsing the element
|
||||||
|
keys=`sonic-db-cli CONFIG_DB keys "SNMP_AGENT_ADDRESS_CONFIG|*"`
|
||||||
count=1
|
count=1
|
||||||
for key in $keys;do
|
for key in $keys;do
|
||||||
ip=`echo $key|cut -d "|" -f2`
|
ip=`echo $key|cut -d "|" -f2`
|
||||||
@ -180,10 +184,10 @@ function postStartAction()
|
|||||||
|
|
||||||
if [[ "$BOOT_TYPE" == "fast" ]]; then
|
if [[ "$BOOT_TYPE" == "fast" ]]; then
|
||||||
# set the key to expire in 3 minutes
|
# set the key to expire in 3 minutes
|
||||||
redis-cli -n 6 SET "FAST_REBOOT|system" "1" "EX" "180"
|
sonic-db-cli STATE_DB SET "FAST_REBOOT|system" "1" "EX" "180"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
redis-cli -n 4 SET "CONFIG_DB_INITIALIZED" "1"
|
sonic-db-cli CONFIG_DB SET "CONFIG_DB_INITIALIZED" "1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -x /usr/bin/db_migrator.py ]]; then
|
if [[ -x /usr/bin/db_migrator.py ]]; then
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
###########################################################################
|
###########################################################################
|
||||||
|
|
||||||
# Initialize constants
|
# Initialize constants
|
||||||
CONFIG_DB_INDEX=4
|
|
||||||
UPDATEGRAPH_CONF=/etc/sonic/updategraph.conf
|
UPDATEGRAPH_CONF=/etc/sonic/updategraph.conf
|
||||||
CONFIG_DB_JSON=/etc/sonic/config_db.json
|
CONFIG_DB_JSON=/etc/sonic/config_db.json
|
||||||
MINGRAPH_FILE=/etc/sonic/minigraph.xml
|
MINGRAPH_FILE=/etc/sonic/minigraph.xml
|
||||||
@ -107,9 +106,9 @@ reload_minigraph()
|
|||||||
if [ ! -f /etc/sonic/init_cfg.json ]; then
|
if [ ! -f /etc/sonic/init_cfg.json ]; then
|
||||||
echo "{}" > /etc/sonic/init_cfg.json
|
echo "{}" > /etc/sonic/init_cfg.json
|
||||||
fi
|
fi
|
||||||
redis-cli -n $CONFIG_DB_INDEX FLUSHDB
|
sonic-db-cli CONFIG_DB FLUSHDB
|
||||||
sonic-cfggen -H -m -j /etc/sonic/init_cfg.json --write-to-db
|
sonic-cfggen -H -m -j /etc/sonic/init_cfg.json --write-to-db
|
||||||
redis-cli -n $CONFIG_DB_INDEX SET "CONFIG_DB_INITIALIZED" "1"
|
sonic-db-cli CONFIG_DB SET "CONFIG_DB_INITIALIZED" "1"
|
||||||
if [ -f /etc/sonic/acl.json ]; then
|
if [ -f /etc/sonic/acl.json ]; then
|
||||||
acl-loader update full /etc/sonic/acl.json
|
acl-loader update full /etc/sonic/acl.json
|
||||||
fi
|
fi
|
||||||
@ -138,7 +137,7 @@ function copy_config_files_and_directories()
|
|||||||
# Check if SONiC swich has booted after a warm reboot request
|
# Check if SONiC swich has booted after a warm reboot request
|
||||||
check_system_warm_boot()
|
check_system_warm_boot()
|
||||||
{
|
{
|
||||||
SYSTEM_WARM_START=`/usr/bin/redis-cli -n 6 hget "WARM_RESTART_ENABLE_TABLE|system" enable`
|
SYSTEM_WARM_START=`sonic-db-cli STATE_DB hget "WARM_RESTART_ENABLE_TABLE|system" enable`
|
||||||
# SYSTEM_WARM_START could be empty, always make WARM_BOOT meaningful.
|
# SYSTEM_WARM_START could be empty, always make WARM_BOOT meaningful.
|
||||||
if [[ x"$SYSTEM_WARM_START" == x"true" ]]; then
|
if [[ x"$SYSTEM_WARM_START" == x"true" ]]; then
|
||||||
WARM_BOOT="true"
|
WARM_BOOT="true"
|
||||||
@ -187,7 +186,7 @@ load_config()
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
redis-cli -n $CONFIG_DB_INDEX FLUSHDB
|
sonic-db-cli CONFIG_DB FLUSHDB
|
||||||
sonic-cfggen -j ${CONFIG_FILE} --write-to-db
|
sonic-cfggen -j ${CONFIG_FILE} --write-to-db
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
return $?
|
return $?
|
||||||
@ -198,7 +197,7 @@ load_config()
|
|||||||
/usr/bin/db_migrator.py -o migrate
|
/usr/bin/db_migrator.py -o migrate
|
||||||
fi
|
fi
|
||||||
|
|
||||||
redis-cli -n $CONFIG_DB_INDEX SET "CONFIG_DB_INITIALIZED" "1"
|
sonic-db-cli CONFIG_DB SET "CONFIG_DB_INITIALIZED" "1"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
CONFIG_DB_INDEX=4
|
|
||||||
|
|
||||||
reload_minigraph()
|
reload_minigraph()
|
||||||
{
|
{
|
||||||
echo "Reloading minigraph..."
|
echo "Reloading minigraph..."
|
||||||
if [ ! -f /etc/sonic/init_cfg.json ]; then
|
if [ ! -f /etc/sonic/init_cfg.json ]; then
|
||||||
echo "{}" > /etc/sonic/init_cfg.json
|
echo "{}" > /etc/sonic/init_cfg.json
|
||||||
fi
|
fi
|
||||||
redis-cli -n $CONFIG_DB_INDEX FLUSHDB
|
sonic-db-cli CONFIG_DB FLUSHDB
|
||||||
sonic-cfggen -H -m -j /etc/sonic/init_cfg.json --write-to-db
|
sonic-cfggen -H -m -j /etc/sonic/init_cfg.json --write-to-db
|
||||||
redis-cli -n $CONFIG_DB_INDEX SET "CONFIG_DB_INITIALIZED" "1"
|
sonic-db-cli CONFIG_DB SET "CONFIG_DB_INITIALIZED" "1"
|
||||||
if [ -f /etc/sonic/acl.json ]; then
|
if [ -f /etc/sonic/acl.json ]; then
|
||||||
acl-loader update full /etc/sonic/acl.json
|
acl-loader update full /etc/sonic/acl.json
|
||||||
fi
|
fi
|
||||||
@ -77,9 +75,9 @@ if [ "$src" = "dhcp" ]; then
|
|||||||
else
|
else
|
||||||
cp -f /tmp/device_meta.json /etc/sonic/config_db.json
|
cp -f /tmp/device_meta.json /etc/sonic/config_db.json
|
||||||
fi
|
fi
|
||||||
redis-cli -n $CONFIG_DB_INDEX FLUSHDB
|
sonic-db-cli CONFIG_DB FLUSHDB
|
||||||
sonic-cfggen -j /etc/sonic/config_db.json --write-to-db
|
sonic-cfggen -j /etc/sonic/config_db.json --write-to-db
|
||||||
redis-cli -n $CONFIG_DB_INDEX SET "CONFIG_DB_INITIALIZED" "1"
|
sonic-db-cli CONFIG_DB SET "CONFIG_DB_INITIALIZED" "1"
|
||||||
if [ "$dhcp_as_static" = "true" ]; then
|
if [ "$dhcp_as_static" = "true" ]; then
|
||||||
sed -i "/enabled=/d" /etc/sonic/updategraph.conf
|
sed -i "/enabled=/d" /etc/sonic/updategraph.conf
|
||||||
echo "enabled=false" >> /etc/sonic/updategraph.conf
|
echo "enabled=false" >> /etc/sonic/updategraph.conf
|
||||||
|
@ -20,7 +20,7 @@ function debug()
|
|||||||
|
|
||||||
function check_warm_boot()
|
function check_warm_boot()
|
||||||
{
|
{
|
||||||
WARM_BOOT=`/usr/bin/redis-cli -n 6 hget "WARM_RESTART_ENABLE_TABLE|system" enable`
|
WARM_BOOT=`sonic-db-cli STATE_DB hget "WARM_RESTART_ENABLE_TABLE|system" enable`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -29,12 +29,10 @@ function wait_for_database_service()
|
|||||||
debug "Wait for database to become ready..."
|
debug "Wait for database to become ready..."
|
||||||
|
|
||||||
# Wait for redis server start before database clean
|
# Wait for redis server start before database clean
|
||||||
until [[ $(/usr/bin/docker exec database redis-cli ping | grep -c PONG) -gt 0 ]];
|
/usr/bin/docker exec database ping_pong_db_insts
|
||||||
do sleep 1;
|
|
||||||
done
|
|
||||||
|
|
||||||
# Wait for configDB initialization
|
# Wait for configDB initialization
|
||||||
until [[ $(/usr/bin/docker exec database redis-cli -n 4 GET "CONFIG_DB_INITIALIZED") ]];
|
until [[ $(sonic-db-cli CONFIG_DB GET "CONFIG_DB_INITIALIZED") ]];
|
||||||
do sleep 1;
|
do sleep 1;
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -44,7 +42,7 @@ function wait_for_database_service()
|
|||||||
|
|
||||||
function get_component_state()
|
function get_component_state()
|
||||||
{
|
{
|
||||||
/usr/bin/redis-cli -n 6 hget "WARM_RESTART_TABLE|$1" state
|
sonic-db-cli STATE_DB hget "WARM_RESTART_TABLE|$1" state
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,4 +10,4 @@ if [ -r /etc/sonic/config_db.json ]; then
|
|||||||
sonic-cfggen -j /etc/sonic/config_db.json --write-to-db
|
sonic-cfggen -j /etc/sonic/config_db.json --write-to-db
|
||||||
fi
|
fi
|
||||||
|
|
||||||
redis-cli -n 4 SET "CONFIG_DB_INITIALIZED" "1"
|
sonic-db-cli CONFIG_DB SET "CONFIG_DB_INITIALIZED" "1"
|
||||||
|
@ -31,8 +31,8 @@ function unlock_service_state_change()
|
|||||||
|
|
||||||
function check_warm_boot()
|
function check_warm_boot()
|
||||||
{
|
{
|
||||||
SYSTEM_WARM_START=`/usr/bin/redis-cli -n 6 hget "WARM_RESTART_ENABLE_TABLE|system" enable`
|
SYSTEM_WARM_START=`sonic-db-cli STATE_DB hget "WARM_RESTART_ENABLE_TABLE|system" enable`
|
||||||
SERVICE_WARM_START=`/usr/bin/redis-cli -n 6 hget "WARM_RESTART_ENABLE_TABLE|${SERVICE}" enable`
|
SERVICE_WARM_START=`sonic-db-cli STATE_DB hget "WARM_RESTART_ENABLE_TABLE|${SERVICE}" enable`
|
||||||
if [[ x"$SYSTEM_WARM_START" == x"true" ]] || [[ x"$SERVICE_WARM_START" == x"true" ]]; then
|
if [[ x"$SYSTEM_WARM_START" == x"true" ]] || [[ x"$SERVICE_WARM_START" == x"true" ]]; then
|
||||||
WARM_BOOT="true"
|
WARM_BOOT="true"
|
||||||
else
|
else
|
||||||
@ -43,7 +43,7 @@ function check_warm_boot()
|
|||||||
function validate_restore_count()
|
function validate_restore_count()
|
||||||
{
|
{
|
||||||
if [[ x"$WARM_BOOT" == x"true" ]]; then
|
if [[ x"$WARM_BOOT" == x"true" ]]; then
|
||||||
RESTORE_COUNT=`/usr/bin/redis-cli -n 6 hget "WARM_RESTART_TABLE|orchagent" restore_count`
|
RESTORE_COUNT=`sonic-db-cli STATE_DB hget "WARM_RESTART_TABLE|orchagent" restore_count`
|
||||||
# We have to make sure db data has not been flushed.
|
# We have to make sure db data has not been flushed.
|
||||||
if [[ -z "$RESTORE_COUNT" ]]; then
|
if [[ -z "$RESTORE_COUNT" ]]; then
|
||||||
WARM_BOOT="false"
|
WARM_BOOT="false"
|
||||||
@ -54,12 +54,10 @@ function validate_restore_count()
|
|||||||
function wait_for_database_service()
|
function wait_for_database_service()
|
||||||
{
|
{
|
||||||
# Wait for redis server start before database clean
|
# Wait for redis server start before database clean
|
||||||
until [[ $(/usr/bin/docker exec database redis-cli ping | grep -c PONG) -gt 0 ]];
|
/usr/bin/docker exec database ping_pong_db_insts
|
||||||
do sleep 1;
|
|
||||||
done
|
|
||||||
|
|
||||||
# Wait for configDB initialization
|
# Wait for configDB initialization
|
||||||
until [[ $(/usr/bin/docker exec database redis-cli -n 4 GET "CONFIG_DB_INITIALIZED") ]];
|
until [[ $(sonic-db-cli CONFIG_DB GET "CONFIG_DB_INITIALIZED") ]];
|
||||||
do sleep 1;
|
do sleep 1;
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@ -69,7 +67,7 @@ function wait_for_database_service()
|
|||||||
# $2 the string of a list of table prefixes
|
# $2 the string of a list of table prefixes
|
||||||
function clean_up_tables()
|
function clean_up_tables()
|
||||||
{
|
{
|
||||||
redis-cli -n $1 EVAL "
|
sonic-db-cli $1 EVAL "
|
||||||
local tables = {$2}
|
local tables = {$2}
|
||||||
for i = 1, table.getn(tables) do
|
for i = 1, table.getn(tables) do
|
||||||
local matches = redis.call('KEYS', tables[i])
|
local matches = redis.call('KEYS', tables[i])
|
||||||
@ -114,11 +112,11 @@ start() {
|
|||||||
# Don't flush DB during warm boot
|
# Don't flush DB during warm boot
|
||||||
if [[ x"$WARM_BOOT" != x"true" ]]; then
|
if [[ x"$WARM_BOOT" != x"true" ]]; then
|
||||||
debug "Flushing APP, ASIC, COUNTER, CONFIG, and partial STATE databases ..."
|
debug "Flushing APP, ASIC, COUNTER, CONFIG, and partial STATE databases ..."
|
||||||
/usr/bin/docker exec database redis-cli -n 0 FLUSHDB
|
sonic-db-cli APPL_DB FLUSHDB
|
||||||
/usr/bin/docker exec database redis-cli -n 1 FLUSHDB
|
sonic-db-cli ASIC_DB FLUSHDB
|
||||||
/usr/bin/docker exec database redis-cli -n 2 FLUSHDB
|
sonic-db-cli COUNTERS_DB FLUSHDB
|
||||||
/usr/bin/docker exec database redis-cli -n 5 FLUSHDB
|
sonic-db-cli FLEX_COUNTER_DB FLUSHDB
|
||||||
clean_up_tables 6 "'PORT_TABLE*', 'MGMT_PORT_TABLE*', 'VLAN_TABLE*', 'VLAN_MEMBER_TABLE*', 'LAG_TABLE*', 'LAG_MEMBER_TABLE*', 'INTERFACE_TABLE*', 'MIRROR_SESSION*', 'VRF_TABLE*', 'FDB_TABLE*'"
|
clean_up_tables STATE_DB "'PORT_TABLE*', 'MGMT_PORT_TABLE*', 'VLAN_TABLE*', 'VLAN_MEMBER_TABLE*', 'LAG_TABLE*', 'LAG_MEMBER_TABLE*', 'INTERFACE_TABLE*', 'MIRROR_SESSION*', 'VRF_TABLE*', 'FDB_TABLE*'"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# start service docker
|
# start service docker
|
||||||
@ -166,7 +164,7 @@ stop() {
|
|||||||
# encountered error, e.g. syncd crashed. And swss needs to
|
# encountered error, e.g. syncd crashed. And swss needs to
|
||||||
# be restarted.
|
# be restarted.
|
||||||
debug "Clearing FAST_REBOOT flag..."
|
debug "Clearing FAST_REBOOT flag..."
|
||||||
clean_up_tables 6 "'FAST_REBOOT*'"
|
clean_up_tables STATE_DB "'FAST_REBOOT*'"
|
||||||
|
|
||||||
# Unlock has to happen before reaching out to peer service
|
# Unlock has to happen before reaching out to peer service
|
||||||
unlock_service_state_change
|
unlock_service_state_change
|
||||||
|
@ -30,8 +30,8 @@ function unlock_service_state_change()
|
|||||||
|
|
||||||
function check_warm_boot()
|
function check_warm_boot()
|
||||||
{
|
{
|
||||||
SYSTEM_WARM_START=`/usr/bin/redis-cli -n 6 hget "WARM_RESTART_ENABLE_TABLE|system" enable`
|
SYSTEM_WARM_START=`sonic-db-cli STATE_DB hget "WARM_RESTART_ENABLE_TABLE|system" enable`
|
||||||
SERVICE_WARM_START=`/usr/bin/redis-cli -n 6 hget "WARM_RESTART_ENABLE_TABLE|${SERVICE}" enable`
|
SERVICE_WARM_START=`sonic-db-cli STATE_DB hget "WARM_RESTART_ENABLE_TABLE|${SERVICE}" enable`
|
||||||
# SYSTEM_WARM_START could be empty, always make WARM_BOOT meaningful.
|
# SYSTEM_WARM_START could be empty, always make WARM_BOOT meaningful.
|
||||||
if [[ x"$SYSTEM_WARM_START" == x"true" ]] || [[ x"$SERVICE_WARM_START" == x"true" ]]; then
|
if [[ x"$SYSTEM_WARM_START" == x"true" ]] || [[ x"$SERVICE_WARM_START" == x"true" ]]; then
|
||||||
WARM_BOOT="true"
|
WARM_BOOT="true"
|
||||||
@ -43,12 +43,10 @@ function check_warm_boot()
|
|||||||
function wait_for_database_service()
|
function wait_for_database_service()
|
||||||
{
|
{
|
||||||
# Wait for redis server start before database clean
|
# Wait for redis server start before database clean
|
||||||
until [[ $(/usr/bin/docker exec database redis-cli ping | grep -c PONG) -gt 0 ]];
|
/usr/bin/docker exec database ping_pong_db_insts
|
||||||
do sleep 1;
|
|
||||||
done
|
|
||||||
|
|
||||||
# Wait for configDB initialization
|
# Wait for configDB initialization
|
||||||
until [[ $(/usr/bin/docker exec database redis-cli -n 4 GET "CONFIG_DB_INITIALIZED") ]];
|
until [[ $(sonic-db-cli CONFIG_DB GET "CONFIG_DB_INITIALIZED") ]];
|
||||||
do sleep 1;
|
do sleep 1;
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@ -65,7 +63,7 @@ function getBootType()
|
|||||||
;;
|
;;
|
||||||
*SONIC_BOOT_TYPE=fast*|*fast-reboot*)
|
*SONIC_BOOT_TYPE=fast*|*fast-reboot*)
|
||||||
# check that the key exists
|
# check that the key exists
|
||||||
if [[ $(redis-cli -n 6 GET "FAST_REBOOT|system") == "1" ]]; then
|
if [[ $(sonic-db-cli STATE_DB GET "FAST_REBOOT|system") == "1" ]]; then
|
||||||
TYPE='fast'
|
TYPE='fast'
|
||||||
else
|
else
|
||||||
TYPE='cold'
|
TYPE='cold'
|
||||||
|
@ -65,7 +65,7 @@ function _docker_swss_check {
|
|||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
# Check if syncd starts
|
# Check if syncd starts
|
||||||
result=`docker exec -i swss bash -c "echo -en \"SELECT 1\\nHLEN HIDDEN\" | redis-cli | sed -n 2p"` #TBD FIX ME
|
result=`sonic-db-cli ASIC_DB HLEN HIDDEN`
|
||||||
if [ "$result" == "3" ]; then
|
if [ "$result" == "3" ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
@ -66,7 +66,7 @@ function _docker_swss_check {
|
|||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
# Check if syncd starts
|
# Check if syncd starts
|
||||||
result=`docker exec -i swss bash -c "echo -en \"SELECT 1\\nHLEN HIDDEN\" | redis-cli | sed -n 2p"` #TBD FIX ME
|
result=`sonic-db-cli ASIC_DB HLEN HIDDEN`
|
||||||
if [ "$result" == "3" ]; then
|
if [ "$result" == "3" ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
@ -65,7 +65,7 @@ function _docker_swss_check {
|
|||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
# Check if syncd starts
|
# Check if syncd starts
|
||||||
result=`docker exec -i swss bash -c "echo -en \"SELECT 1\\nHLEN HIDDEN\" | redis-cli | sed -n 2p"` #TBD FIX ME
|
result=`sonic-db-cli ASIC_DB HLEN HIDDEN`
|
||||||
if [ "$result" == "3" ]; then
|
if [ "$result" == "3" ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
@ -67,7 +67,7 @@ function _docker_swss_check {
|
|||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
# Check if syncd starts
|
# Check if syncd starts
|
||||||
result=`docker exec -i swss bash -c "echo -en \"SELECT 1\\nHLEN HIDDEN\" | redis-cli | sed -n 2p"` #TBD FIX ME
|
result=`sonic-db-cli ASIC_DB HLEN HIDDEN`
|
||||||
if [ "$result" == "3" ]; then
|
if [ "$result" == "3" ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
@ -67,7 +67,7 @@ function _docker_swss_check {
|
|||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
# Check if syncd starts
|
# Check if syncd starts
|
||||||
result=`docker exec -i swss bash -c "echo -en \"SELECT 1\\nHLEN HIDDEN\" | redis-cli | sed -n 2p"` #TBD FIX ME
|
result=`sonic-db-cli ASIC_DB HLEN HIDDEN`
|
||||||
if [ "$result" == "3" ]; then
|
if [ "$result" == "3" ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
@ -65,7 +65,7 @@ function _docker_swss_check {
|
|||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
# Check if syncd starts
|
# Check if syncd starts
|
||||||
result=`docker exec -i swss bash -c "echo -en \"SELECT 1\\nHLEN HIDDEN\" | redis-cli | sed -n 2p"` #TBD FIX ME
|
result=`sonic-db-cli ASIC_DB HLEN HIDDEN`
|
||||||
if [ "$result" == "3" ]; then
|
if [ "$result" == "3" ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
@ -66,7 +66,7 @@ function _docker_swss_check {
|
|||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
# Check if syncd starts
|
# Check if syncd starts
|
||||||
result=`docker exec -i swss bash -c "echo -en \"SELECT 1\\nHLEN HIDDEN\" | redis-cli | sed -n 2p"` #TBD FIX ME
|
result=`sonic-db-cli ASIC_DB HLEN HIDDEN`
|
||||||
if [ "$result" == "3" ]; then
|
if [ "$result" == "3" ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
@ -65,7 +65,7 @@ function _docker_swss_check {
|
|||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
# Check if syncd starts
|
# Check if syncd starts
|
||||||
result=`docker exec -i swss bash -c "echo -en \"SELECT 1\\nHLEN HIDDEN\" | redis-cli | sed -n 2p"` #TBD FIX ME
|
result=`sonic-db-cli ASIC_DB HLEN HIDDEN`
|
||||||
if [ "$result" == "3" ]; then
|
if [ "$result" == "3" ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
@ -66,7 +66,7 @@ function _docker_swss_check {
|
|||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
# Check if syncd starts
|
# Check if syncd starts
|
||||||
result=`docker exec -i swss bash -c "echo -en \"SELECT 1\\nHLEN HIDDEN\" | redis-cli | sed -n 2p"` #TBD FIX ME
|
result=`sonic-db-cli ASIC_DB HLEN HIDDEN`
|
||||||
if [ "$result" == "3" ]; then
|
if [ "$result" == "3" ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user