bug 13606: Fix releasing of the first IP of second public nic

The problem is remove_first_ip() in ipassoc.sh can't be called more than one.
The call after the first time would result in iptable and ip command failure,
thus result in failure of execution of IpAssocCommand.

Use the same way to detect already disassociated ip address of non-first
IP(remove_an_ip()) to fix the issue.

reviewed-by: Edison Su

status 13606: resolved fixed
This commit is contained in:
Sheng Yang 2012-02-10 18:48:02 -08:00
parent 82cae89124
commit 9fc1991d5b
1 changed files with 4 additions and 0 deletions

View File

@ -272,6 +272,10 @@ remove_first_ip() {
logger -t cloud "$(basename $0):Removing first ip $pubIp on interface $ethDev"
local ipNoMask=$(echo $1 | awk -F'/' '{print $1}')
local mask=$(echo $1 | awk -F'/' '{print $2}')
local existingIpMask=$(sudo ip addr show dev $ethDev | grep inet | awk '{print $2}' | grep -w $ipNoMask)
[ "$existingIpMask" == "" ] && return 0
[ "$mask" == "" ] && mask="32"
sudo iptables -D FORWARD -i $ethDev -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT