sonic-buildimage/dockers/docker-fpm-frr/TSC
pavel-shirshov 83715cfc49
[bgpcfgd]: Support default action for "Allow prefix" feature (#6370)
* Use 20 and 30 route-map entries instead of 2 and 3 for TSA

* Added support for dynamic "Allow list" default action.

Co-authored-by: Pavel Shirshov <pavel.contrib@gmail.com>
2021-01-08 14:03:26 -08:00

53 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
function check_not_installed()
{
c=0
config=$(vtysh -c "show run")
for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p' | egrep 'V4|V6');
do
echo "$config" | grep -q "route-map $route_map_name permit 20"
c=$((c+$?))
echo "$config" | grep -q "route-map $route_map_name deny 30"
c=$((c+$?))
done
return $c
}
function check_installed()
{
c=0
e=0
config=$(vtysh -c "show run")
for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p' | egrep 'V4|V6');
do
echo "$config" | grep -q "route-map $route_map_name permit 20"
c=$((c+$?))
e=$((e+1))
echo "$config" | grep -q "route-map $route_map_name deny 30"
c=$((c+$?))
e=$((e+1))
done
return $((e-c))
}
echo "Traffic Shift Check:"
check_not_installed
not_installed=$?
check_installed
installed=$?
if [[ $installed -eq 0 ]];
then
echo "System Mode: Normal"
elif [[ $not_installed -eq 0 ]];
then
echo "System Mode: Maintenance"
else
echo "System Mode: Not consistent"
fi
echo