Fix for TSA error logging on multi-asic (#11519)
This commit is contained in:
parent
b1456ee1c8
commit
f2d7481b5f
@ -5,12 +5,16 @@
|
||||
|
||||
PLATFORM=${PLATFORM:-`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform`}
|
||||
|
||||
if [[ $1 == "TSA" ]]; then
|
||||
if [[ $1 == "TSA" ]]; then
|
||||
TSA_STATE_UPDATE='{"BGP_DEVICE_GLOBAL":{"STATE":{"tsa_enabled": "true"}}}'
|
||||
log_msg='System Mode: Normal -> Maintenance'
|
||||
err_msg='System is already in Maintenance'
|
||||
desired_tsa_state=true
|
||||
elif [[ $1 == "TSB" ]]; then
|
||||
TSA_STATE_UPDATE='{"BGP_DEVICE_GLOBAL":{"STATE":{"tsa_enabled": "false"}}}'
|
||||
log_msg='System Mode: Maintenance -> Normal'
|
||||
err_msg='System is already in Normal mode'
|
||||
desired_tsa_state=false
|
||||
fi
|
||||
|
||||
# Parse the device specific asic conf file, if it exists
|
||||
@ -28,10 +32,16 @@ if [[ ($NUM_ASIC -gt 1) ]]; then
|
||||
if [ $sub_role == 'FrontEnd' ]
|
||||
then
|
||||
echo -e "BGP"$asic" : \c"
|
||||
if [[ -n "$TSA_STATE_UPDATE" ]]; then
|
||||
sonic-cfggen -a "$TSA_STATE_UPDATE" -w -n $NAMESPACE_PREFIX$asic
|
||||
logger -t $1 -p user.info "BGP$asic: $log_msg"
|
||||
echo "$log_msg"
|
||||
if [[ -n "$TSA_STATE_UPDATE" ]]; then
|
||||
current_tsa_state="$(sonic-cfggen -d -v BGP_DEVICE_GLOBAL.STATE.tsa_enabled -n $NAMESPACE_PREFIX$asic)"
|
||||
if [[ $current_tsa_state == $desired_tsa_state ]]; then
|
||||
echo "$err_msg"
|
||||
logger -t $1 -p user.info "$err_msg"
|
||||
else
|
||||
sonic-cfggen -a "$TSA_STATE_UPDATE" -w -n $NAMESPACE_PREFIX$asic
|
||||
logger -t $1 -p user.info "$log_msg"
|
||||
echo "$log_msg"
|
||||
fi
|
||||
else
|
||||
# If TSC is executed, invoke FRR script to check installed route-maps
|
||||
docker exec -i bgp$asic /usr/bin/$1
|
||||
@ -40,10 +50,16 @@ if [[ ($NUM_ASIC -gt 1) ]]; then
|
||||
asic=$[$asic+1]
|
||||
done
|
||||
else
|
||||
if [[ -n "$TSA_STATE_UPDATE" ]]; then
|
||||
sonic-cfggen -a "$TSA_STATE_UPDATE" -w
|
||||
logger -t $1 -p user.info "$log_msg"
|
||||
echo "$log_msg"
|
||||
if [[ -n "$TSA_STATE_UPDATE" ]]; then
|
||||
current_tsa_state="$(sonic-cfggen -d -v BGP_DEVICE_GLOBAL.STATE.tsa_enabled)"
|
||||
if [[ $current_tsa_state == $desired_tsa_state ]]; then
|
||||
echo "$err_msg"
|
||||
logger -t $1 -p user.info "$err_msg"
|
||||
else
|
||||
sonic-cfggen -a "$TSA_STATE_UPDATE" -w
|
||||
logger -t $1 -p user.info "$log_msg"
|
||||
echo "$log_msg"
|
||||
fi
|
||||
else
|
||||
# If TSC is executed, invoke FRR script to check installed route-maps
|
||||
docker exec -i bgp /usr/bin/$1
|
||||
|
@ -1,20 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
if [[ "$(sonic-cfggen -d -v BGP_DEVICE_GLOBAL.STATE.tsa_enabled)" == "true" ]]; then
|
||||
echo "System is already in Maintenance"
|
||||
logger -t TSA -p user.info "System is already in Maintenance"
|
||||
else
|
||||
# toggle the mux to standby if dualtor and any mux active
|
||||
if
|
||||
[[ "$(sonic-cfggen -d -v DEVICE_METADATA.localhost.subtype | tr [:upper:] [:lower:])" == *"dualtor"* ]] &&
|
||||
[[ $(show mux status | grep active | wc -l) > 0 ]];
|
||||
then
|
||||
logger -t TSA -p user.info "Toggle all mux mode to standby"
|
||||
sudo config mux mode standby all
|
||||
fi
|
||||
|
||||
/usr/bin/TS TSA
|
||||
echo "Please execute 'config save' to preserve System mode in Maintenance after reboot or config reload"
|
||||
# toggle the mux to standby if dualtor and any mux active
|
||||
if
|
||||
[[ "$(sonic-cfggen -d -v DEVICE_METADATA.localhost.subtype | tr [:upper:] [:lower:])" == *"dualtor"* ]] &&
|
||||
[[ $(show mux status | grep active | wc -l) > 0 ]];
|
||||
then
|
||||
logger -t TSA -p user.info "Toggle all mux mode to standby"
|
||||
sudo config mux mode standby all
|
||||
fi
|
||||
|
||||
/usr/bin/TS TSA
|
||||
echo "Please execute 'config save' to preserve System mode in Maintenance after reboot or config reload"
|
||||
|
@ -1,17 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ "$(sonic-cfggen -d -v BGP_DEVICE_GLOBAL.STATE.tsa_enabled)" == "false" ]]; then
|
||||
echo "System is already in Normal mode"
|
||||
logger -t TSB -p user.info "System is already in Normal mode"
|
||||
else
|
||||
# toggle the mux to auto if dualtor
|
||||
if [[ "$(sonic-cfggen -d -v DEVICE_METADATA.localhost.subtype | tr [:upper:] [:lower:])" == *"dualtor"* ]];
|
||||
then
|
||||
logger -t TSB -p user.info "Toggle all mux mode to auto"
|
||||
sudo config mux mode auto all
|
||||
fi
|
||||
|
||||
/usr/bin/TS TSB
|
||||
echo "Please execute 'config save' to preserve System mode in Normal state after reboot or config reload"
|
||||
# toggle the mux to auto if dualtor
|
||||
if [[ "$(sonic-cfggen -d -v DEVICE_METADATA.localhost.subtype | tr [:upper:] [:lower:])" == *"dualtor"* ]];
|
||||
then
|
||||
logger -t TSB -p user.info "Toggle all mux mode to auto"
|
||||
sudo config mux mode auto all
|
||||
fi
|
||||
|
||||
/usr/bin/TS TSB
|
||||
echo "Please execute 'config save' to preserve System mode in Normal state after reboot or config reload"
|
||||
|
@ -7,9 +7,15 @@ from . import swsscommon_test
|
||||
from .util import load_constants
|
||||
import bgpcfgd.managers_device_global
|
||||
from swsscommon import swsscommon
|
||||
from copy import deepcopy
|
||||
|
||||
TEMPLATE_PATH = os.path.abspath('../../dockers/docker-fpm-frr/frr')
|
||||
BASE_PATH = os.path.abspath('../sonic-bgpcfgd/tests/data/general/peer-group.conf/')
|
||||
global_constants = {
|
||||
"bgp": {
|
||||
"traffic_shift_community" :"12345:12345"
|
||||
}
|
||||
}
|
||||
|
||||
def constructor():
|
||||
cfg_mgr = MagicMock()
|
||||
@ -32,7 +38,7 @@ def constructor():
|
||||
cfg_mgr.push = push
|
||||
cfg_mgr.get_config = get_config
|
||||
|
||||
constants = load_constants()['constants']
|
||||
constants = deepcopy(global_constants)
|
||||
common_objs = {
|
||||
'directory': Directory(),
|
||||
'cfg_mgr': cfg_mgr,
|
||||
|
Loading…
Reference in New Issue
Block a user