cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wid...@apache.org
Subject [2/2] git commit: updated refs/heads/4.2 to 0898a26
Date Thu, 11 Jul 2013 10:01:00 GMT
CLOUDSTACK-3409: Do not clean up security group rules for Instances in the "paused" state.

When 'security_group.py cleanup_rules' is called by the KVM Agent it will clean up all Instances
not in the "running" state according to libvirt.

However, when a snapshot is created of a Instance it will go to the "paused" state while the
snapshot
is created.

This leads to Security Rules being removed when a Instance is being snapshotted and the cleanup
process
is initiated.


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

Branch: refs/heads/4.2
Commit: 0898a264a5463b85c4cab3033f9c3161c5ef83f8
Parents: 4a9c665
Author: Wido den Hollander <wido@widodh.nl>
Authored: Wed Jul 10 12:50:06 2013 +0200
Committer: Wido den Hollander <wido@widodh.nl>
Committed: Thu Jul 11 12:00:48 2013 +0200

----------------------------------------------------------------------
 scripts/vm/network/security_group.py | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0898a264/scripts/vm/network/security_group.py
----------------------------------------------------------------------
diff --git a/scripts/vm/network/security_group.py b/scripts/vm/network/security_group.py
index 6c12409..0ac8b74 100755
--- a/scripts/vm/network/security_group.py
+++ b/scripts/vm/network/security_group.py
@@ -621,18 +621,18 @@ def cleanup_rules():
             if 1 in [ chain.startswith(c) for c in ['r-', 'i-', 's-', 'v-'] ]:
                 vm_name = chain
                 
-                cmd = "virsh list |grep " + vm_name 
+                cmd = "virsh list |grep " + vm_name + "|awk '{print $3}'"
                 try:
-                    result = execute(cmd)
+                    result = execute(cmd).strip()
                 except:
                     result = None
 
                 if result == None or len(result) == 0:
-                    logging.debug("chain " + chain + " does not correspond to a vm, cleaning
up")
+                    logging.debug("chain " + chain + " does not correspond to a vm, cleaning
up iptable rules")
                     cleanup.append(vm_name)
                     continue
-                if result.find("running") == -1:
-                    logging.debug("vm " + vm_name + " is not running, cleaning up")
+                if not (result == "running" or result == "paused"):
+                    logging.debug("vm " + vm_name + " is not running or paused, cleaning
up iptable rules")
                     cleanup.append(vm_name)
         
         chainscmd = "ebtables-save |grep :i |awk '{print $1}' |sed -e 's/\-in//g' |sed -e
's/\-out//g' |sed -e 's/^://g'"
@@ -641,18 +641,18 @@ def cleanup_rules():
             if 1 in [ chain.startswith(c) for c in ['r-', 'i-', 's-', 'v-'] ]:
                 vm_name = chain
     
-                cmd = "virsh list |grep " + vm_name
+                cmd = "virsh list |grep " + vm_name + "|awk '{print $3}'"
                 try:
-                    result = execute(cmd)
+                    result = execute(cmd).strip()
                 except:
                     result = None
 
                 if result == None or len(result) == 0:
-                    logging.debug("chain " + chain + " does not correspond to a vm, cleaning
up")
+                    logging.debug("chain " + chain + " does not correspond to a vm, cleaning
up ebtable rules")
                     cleanup.append(vm_name)
                     continue
-                if result.find("running") == -1:
-                    logging.debug("vm " + vm_name + " is not running, cleaning up")
+                if not (result == "running" or result == "paused"):
+                    logging.debug("vm " + vm_name + " is not running or paused, cleaning
up ebtable rules")
                     cleanup.append(vm_name)
 
         for vmname in cleanup:


Mime
View raw message