mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-16 10:32:34 +01:00
xenserver: remove unwanted vmops.orig file (created during a past merge)
scripts: filter output instead of popping string from list This is a defensive enhancement for KVM SG script that filters out empty string instead of popping last item which may or may not be an empty string. Squashed commits: (cherry picked from commit f4cbc4c010947a41c1e296b46822531e7f2bc1c9) (cherry picked from commit 64ab3554a14afa48bb33839631ed4f8e71945874) Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
parent
4df55f199e
commit
2a14f78248
File diff suppressed because it is too large
Load Diff
@ -233,16 +233,14 @@ def destroy_ebtables_rules(vm_name, vif):
|
|||||||
delcmd = "ebtables -t nat -L PREROUTING | grep " + vm_name
|
delcmd = "ebtables -t nat -L PREROUTING | grep " + vm_name
|
||||||
delcmds = []
|
delcmds = []
|
||||||
try:
|
try:
|
||||||
delcmds = execute(delcmd).split('\n')
|
delcmds = filter(None, execute(delcmd).split('\n'))
|
||||||
delcmds.pop()
|
|
||||||
delcmds = ["-D PREROUTING " + x for x in delcmds ]
|
delcmds = ["-D PREROUTING " + x for x in delcmds ]
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
postcmds = []
|
postcmds = []
|
||||||
try:
|
try:
|
||||||
postcmd = "ebtables -t nat -L POSTROUTING | grep " + vm_name
|
postcmd = "ebtables -t nat -L POSTROUTING | grep " + vm_name
|
||||||
postcmds = execute(postcmd).split('\n')
|
postcmds = filter(None, execute(postcmd).split('\n'))
|
||||||
postcmds.pop()
|
|
||||||
postcmds = ["-D POSTROUTING " + x for x in postcmds]
|
postcmds = ["-D POSTROUTING " + x for x in postcmds]
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
@ -543,13 +541,12 @@ def post_default_network_rules(vm_name, vm_id, vm_ip, vm_mac, vif, brname, dhcpS
|
|||||||
def delete_rules_for_vm_in_bridge_firewall_chain(vmName):
|
def delete_rules_for_vm_in_bridge_firewall_chain(vmName):
|
||||||
vm_name = vmName
|
vm_name = vmName
|
||||||
if vm_name.startswith('i-') or vm_name.startswith('r-'):
|
if vm_name.startswith('i-') or vm_name.startswith('r-'):
|
||||||
vm_name = '-'.join(vm_name.split('-')[:-1]) + "-def"
|
vm_name = '-'.join(vm_name.split('-')[:-1]) + "-def"
|
||||||
|
|
||||||
vmchain = vm_name
|
vmchain = vm_name
|
||||||
|
|
||||||
delcmd = """iptables-save | awk '/BF(.*)physdev-is-bridged(.*)%s/ { sub(/-A/, "-D", $1) ; print }'""" % vmchain
|
delcmd = """iptables-save | awk '/BF(.*)physdev-is-bridged(.*)%s/ { sub(/-A/, "-D", $1) ; print }'""" % vmchain
|
||||||
delcmds = execute(delcmd).split('\n')
|
delcmds = filter(None, execute(delcmd).split('\n'))
|
||||||
delcmds.pop()
|
|
||||||
for cmd in delcmds:
|
for cmd in delcmds:
|
||||||
try:
|
try:
|
||||||
execute("iptables " + cmd)
|
execute("iptables " + cmd)
|
||||||
@ -646,8 +643,7 @@ def network_rules_for_rebooted_vm(vmName):
|
|||||||
ipts = []
|
ipts = []
|
||||||
for cmd in [delcmd, inscmd]:
|
for cmd in [delcmd, inscmd]:
|
||||||
logging.debug(cmd)
|
logging.debug(cmd)
|
||||||
cmds = execute(cmd).split('\n')
|
cmds = filter(None, execute(cmd).split('\n'))
|
||||||
cmds.pop()
|
|
||||||
for c in cmds:
|
for c in cmds:
|
||||||
ipt = "iptables " + c
|
ipt = "iptables " + c
|
||||||
ipts.append(ipt)
|
ipts.append(ipt)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user