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:
Rohit Yadav 2015-04-21 12:58:39 +02:00
parent 4df55f199e
commit 2a14f78248
2 changed files with 5 additions and 1504 deletions

File diff suppressed because it is too large Load Diff

View File

@ -233,16 +233,14 @@ def destroy_ebtables_rules(vm_name, vif):
delcmd = "ebtables -t nat -L PREROUTING | grep " + vm_name
delcmds = []
try:
delcmds = execute(delcmd).split('\n')
delcmds.pop()
delcmds = filter(None, execute(delcmd).split('\n'))
delcmds = ["-D PREROUTING " + x for x in delcmds ]
except:
pass
postcmds = []
try:
postcmd = "ebtables -t nat -L POSTROUTING | grep " + vm_name
postcmds = execute(postcmd).split('\n')
postcmds.pop()
postcmds = filter(None, execute(postcmd).split('\n'))
postcmds = ["-D POSTROUTING " + x for x in postcmds]
except:
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):
vm_name = vmName
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
delcmd = """iptables-save | awk '/BF(.*)physdev-is-bridged(.*)%s/ { sub(/-A/, "-D", $1) ; print }'""" % vmchain
delcmds = execute(delcmd).split('\n')
delcmds.pop()
delcmds = filter(None, execute(delcmd).split('\n'))
for cmd in delcmds:
try:
execute("iptables " + cmd)
@ -646,8 +643,7 @@ def network_rules_for_rebooted_vm(vmName):
ipts = []
for cmd in [delcmd, inscmd]:
logging.debug(cmd)
cmds = execute(cmd).split('\n')
cmds.pop()
cmds = filter(None, execute(cmd).split('\n'))
for c in cmds:
ipt = "iptables " + c
ipts.append(ipt)