cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [2/2] git commit: updated refs/heads/4.5 to 64ab355
Date Tue, 21 Apr 2015 15:40:18 GMT
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.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/64ab3554
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/64ab3554
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/64ab3554

Branch: refs/heads/4.5
Commit: 64ab3554a14afa48bb33839631ed4f8e71945874
Parents: f4cbc4c
Author: Rohit Yadav <rohit.yadav@shapeblue.com>
Authored: Tue Apr 21 17:33:18 2015 +0200
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Tue Apr 21 17:33:18 2015 +0200

----------------------------------------------------------------------
 scripts/vm/network/security_group.py | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/64ab3554/scripts/vm/network/security_group.py
----------------------------------------------------------------------
diff --git a/scripts/vm/network/security_group.py b/scripts/vm/network/security_group.py
index b4a355d..5e022d8 100755
--- a/scripts/vm/network/security_group.py
+++ b/scripts/vm/network/security_group.py
@@ -234,16 +234,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
@@ -544,13 +542,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)
@@ -647,8 +644,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)


Mime
View raw message