cleanup ebtables rules if vm is manually deleted

This commit is contained in:
Edison Su 2011-06-20 10:31:53 -04:00
parent 8becb77674
commit 45ea2b2ad6
2 changed files with 4 additions and 5 deletions

View File

@ -130,9 +130,8 @@ def destroy_network_rules_for_vm(vm_name, vif=None):
return 'true'
def destroy_ebtables_rules(vm_name, vif):
if vif is None:
return
delcmd = "ebtables -t nat -L PREROUTING | grep " + vif
delcmd = "ebtables -t nat -L PREROUTING | grep " + vm_name
delcmds = []
try:
delcmds = execute(delcmd).split('\n')
@ -142,7 +141,7 @@ def destroy_ebtables_rules(vm_name, vif):
pass
postcmds = []
try:
postcmd = "ebtables -t nat -L POSTROUTING | grep " + vif
postcmd = "ebtables -t nat -L POSTROUTING | grep " + vm_name
postcmds = execute(postcmd).split('\n')
postcmds.pop()
postcmds = ["-D POSTROUTING " + x for x in postcmds]

View File

@ -73,7 +73,7 @@ arping_vm() {
# ping the default route
ping_default_route() {
defaultRoute=`grep GATEWAY /etc/sysconfig/network | awk -F"=" '{ print $2 }'`
defaultRoute=`route |grep default|awk '{print $2}'`
ping -c 1 -n -q $defaultRoute > /dev/null
return $?
}