VPC : CS-11503, deleting staticnat works even ip is not there.

this can fix the issue for VPC,
  but Cloudstack should not send out ipdeassociate before applying ruls on this ip
This commit is contained in:
anthony 2012-07-11 14:02:46 -07:00
parent a0a0113b51
commit c5f8712b4b
2 changed files with 21 additions and 1 deletions

View File

@ -43,3 +43,17 @@ getVPCcidr () {
done
return 1
}
removeRulesForIp() {
local ip=$1
iptables-save -t mangle | grep $ip | grep "\-A" | while read rule
do
rule=$(echo $rule | sed 's/\-A/\-D/')
sudo iptables -t mangle $rule
done
iptables-save -t filter | grep $ip | grep "\-A" | while read rule
do
rule=$(echo $rule | sed 's/\-A/\-D/')
sudo iptables -t filter $rule
done
}

View File

@ -92,7 +92,13 @@ ethDev=$(getEthByIp $publicIp)
result=$?
if [ $result -gt 0 ]
then
unlock_exit $result $lock $locked
if [ "$op" == "-D" ]
then
removeRulesForIp $publicIp
unlock_exit 0 $lock $locked
else
unlock_exit $result $lock $locked
fi
fi
OUTFILE=$(mktemp)