sonic-buildimage/dockers/docker-fpm-frr/TSA
pavel-shirshov 03391f20c5 [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-09 08:29:19 -08:00

45 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');
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
}
check_not_installed
not_installed=$?
if [[ $not_installed -ne 0 ]];
then
TSA_FILE=$(mktemp)
for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p');
do
case "$route_map_name" in
*V4*)
ip_version=V4
ip_protocol=ip
;;
*V6*)
ip_version=V6
ip_protocol=ipv6
;;
*)
continue
;;
esac
sonic-cfggen -d -a "{\"route_map_name\":\"$route_map_name\", \"ip_version\": \"$ip_version\", \"ip_protocol\": \"$ip_protocol\"}" -y /etc/sonic/constants.yml -t /usr/share/sonic/templates/bgpd/tsa/bgpd.tsa.isolate.conf.j2 > "$TSA_FILE"
vtysh -f "$TSA_FILE"
rm -f "$TSA_FILE"
done
echo "System Mode: Normal -> Maintenance"
else
echo "System is already in Maintenance mode"
fi