2021-02-12 12:56:44 -06:00
|
|
|
#!/bin/bash
|
|
|
|
|
2022-11-03 10:54:33 -05:00
|
|
|
switch_type=`sonic-cfggen -d -v "DEVICE_METADATA['localhost']['switch_type']"`
|
2021-02-12 12:56:44 -06:00
|
|
|
# Check whether the routemap is for internal BGP sessions.
|
|
|
|
function is_internal_route_map()
|
|
|
|
{
|
2023-04-28 08:11:55 -05:00
|
|
|
[[ "$1" =~ .*"_INTERNAL_".* || "$1" =~ .*"VOQ_".* ]]
|
2021-02-12 12:56:44 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
function check_not_installed()
|
|
|
|
{
|
|
|
|
c=0
|
|
|
|
config=$(vtysh -c "show run")
|
2021-04-08 17:16:43 -05:00
|
|
|
for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p' | egrep 'V4|V6' | uniq);
|
2021-02-12 12:56:44 -06:00
|
|
|
do
|
|
|
|
is_internal_route_map $route_map_name && continue
|
|
|
|
echo "$config" | egrep -q "^route-map $route_map_name permit 20$"
|
|
|
|
c=$((c+$?))
|
|
|
|
echo "$config" | egrep -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")
|
2021-04-08 17:16:43 -05:00
|
|
|
for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p' | egrep 'V4|V6' | uniq);
|
2021-02-12 12:56:44 -06:00
|
|
|
do
|
|
|
|
is_internal_route_map $route_map_name && continue
|
|
|
|
echo "$config" | egrep -q "^route-map $route_map_name permit 20$"
|
|
|
|
c=$((c+$?))
|
|
|
|
e=$((e+1))
|
|
|
|
echo "$config" | egrep -q "^route-map $route_map_name deny 30$"
|
|
|
|
c=$((c+$?))
|
|
|
|
e=$((e+1))
|
|
|
|
done
|
|
|
|
return $((e-c))
|
|
|
|
}
|
2021-04-08 17:16:43 -05:00
|
|
|
|
|
|
|
function find_num_routemap()
|
|
|
|
{
|
|
|
|
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' | uniq);
|
|
|
|
do
|
|
|
|
is_internal_route_map $route_map_name && continue
|
|
|
|
c=$((c+1))
|
|
|
|
done
|
|
|
|
return $c
|
|
|
|
}
|