-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [bgp] Save admin state and set default state to shutdown * Set default behavior to no shutdown * Add build option SHUTDOWN_BGP_ON_START * Script change for default admin state to be on * Address CR comments to bgp_neighbor script * Fix script bug
- Loading branch information
Showing
8 changed files
with
74 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/bin/bash -e | ||
|
||
usage(){ | ||
echo "Usage: $0 <shutdown|startup> <neighbor_ip>" | ||
exit 255 | ||
} | ||
|
||
[[ $# -ne 2 ]] && usage | ||
|
||
COMMAND=$1 | ||
NEIGHBOR_IP=$2 | ||
|
||
if [ "$COMMAND" == "shutdown" ]; then | ||
CMD_PREFIX="" | ||
elif [ "$COMMAND" == "startup" ]; then | ||
CMD_PREFIX="no" | ||
else | ||
usage | ||
fi | ||
|
||
ASN=`vtysh -c "show ip bgp summary" | sed -n "s/.*AS number \([0-9]\+\).*/\1/p"` | ||
if [ -z "$ASN" ]; then | ||
exit 255 | ||
fi | ||
|
||
[ -f /etc/sonic/bgp_admin.yml ] || echo "bgp_admin_state:" > /etc/sonic/bgp_admin.yml | ||
|
||
# Operate on all ipv4 neighbors when "neighbor_ip" = 0.0.0.0 | ||
if [ "$NEIGHBOR_IP" == "0.0.0.0" ] ; then | ||
for NEIGHBOR in `vtysh -c "show run" | grep nei | grep -oE "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" | sort | uniq`; do | ||
vtysh -c "configure terminal" -c "router bgp $ASN" -c "$CMD_PREFIX neighbor $NEIGHBOR shutdown" | ||
|
||
# Save admin state in config file | ||
sed -i "/^\s*$NEIGHBOR:/d" /etc/sonic/bgp_admin.yml | ||
if [ "$COMMAND" == "startup" ]; then | ||
echo " $NEIGHBOR: on" >> /etc/sonic/bgp_admin.yml | ||
else | ||
echo " $NEIGHBOR: off" >> /etc/sonic/bgp_admin.yml | ||
fi | ||
done | ||
|
||
else | ||
# Examine bgp neighbor exists first | ||
vtysh -c "show ip bgp neighbor $NEIGHBOR_IP" | grep -q "BGP neighbor is" | ||
|
||
vtysh -c "configure terminal" -c "router bgp $ASN" -c "$CMD_PREFIX neighbor $NEIGHBOR_IP shutdown" | ||
|
||
# Save admin state in config file | ||
sed -i "/^\s*$NEIGHBOR_IP:/d" /etc/sonic/bgp_admin.yml | ||
if [ "$COMMAND" == "startup" ]; then | ||
echo " $NEIGHBOR_IP: on" >> /etc/sonic/bgp_admin.yml | ||
else | ||
echo " $NEIGHBOR_IP: off" >> /etc/sonic/bgp_admin.yml | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters