You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by se...@apache.org on 2014/06/17 17:10:50 UTC
[1/2] git commit: updated refs/heads/4.3 to 9289158
Repository: cloudstack
Updated Branches:
refs/heads/4.3 07602d81a -> 928915840
CLOUDSTACK-6927: less code
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/199bc08a
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/199bc08a
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/199bc08a
Branch: refs/heads/4.3
Commit: 199bc08a3f6b776d3fdbe59dca29ad41fc0beb96
Parents: 07602d8
Author: Loic Lambiel <ll...@exoscale.ch>
Authored: Wed Jun 4 16:45:07 2014 +0200
Committer: Sebastien Goasguen <ru...@gmail.com>
Committed: Tue Jun 17 17:09:21 2014 +0200
----------------------------------------------------------------------
scripts/vm/network/security_group.py | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/199bc08a/scripts/vm/network/security_group.py
----------------------------------------------------------------------
diff --git a/scripts/vm/network/security_group.py b/scripts/vm/network/security_group.py
index f80c9e4..be61842 100755
--- a/scripts/vm/network/security_group.py
+++ b/scripts/vm/network/security_group.py
@@ -547,7 +547,7 @@ def delete_rules_for_vm_in_bridge_firewall_chain(vmName):
delcmds = execute(delcmd).split('\n')
delcmds.pop()
for cmd in delcmds:
- if cmd == '':
+ if cmd == "":
continue
try:
execute("iptables " + cmd)
@@ -689,15 +689,14 @@ def cleanup_rules():
chains = execute(chainscmd).split('\n')
cleanup = []
for chain in chains:
- if chain == '':
+ if chain == "":
continue
- elif chain.startswith(':'):
+ elif chain.startswith(":"):
chain = chain[1:]
- if chain.endswith('-eg'):
+ if chain.endswith("-eg"):
chain = chain[:-3]
- elif chain.endswith('-def'):
- chain = chain[:-3]
- chain = chain + 'VM'
+ elif chain.endswith("-def"):
+ chain = chain[:-3] + "VM"
vm_name = chain
@@ -714,13 +713,12 @@ def cleanup_rules():
chainscmd = """ebtables-save | awk '{for(i=1;i<=NF;i++){ if($i ~ /[i|r|s|v]-[0-9]/){print $i} } }'"""
chains = execute(chainscmd).split('\n')
for chain in chains:
- if chain == '':
+ if chain == "":
continue
- elif chain.startswith(':'):
+ elif chain.startswith(":"):
chain = chain[1:]
- if not chain.endswith('VM'):
- chain = chain.split('VM')
- chain = chain[0] + 'VM'
+ if not chain.endswith("VM"):
+ chain = chain.split("VM")[0] + "VM"
vm_name = chain
[2/2] git commit: updated refs/heads/4.3 to 9289158
Posted by se...@apache.org.
CLOUDSTACK-6927: store virsh list in list instead of querying libvirt for each chain to speedup the function
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/92891584
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/92891584
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/92891584
Branch: refs/heads/4.3
Commit: 92891584067540b6718aede9ca4deda9a64de319
Parents: 199bc08
Author: Loic Lambiel <ll...@exoscale.ch>
Authored: Thu Jun 5 11:32:49 2014 +0200
Committer: Sebastien Goasguen <ru...@gmail.com>
Committed: Tue Jun 17 17:10:29 2014 +0200
----------------------------------------------------------------------
scripts/vm/network/security_group.py | 26 ++++++++------------------
1 file changed, 8 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/92891584/scripts/vm/network/security_group.py
----------------------------------------------------------------------
diff --git a/scripts/vm/network/security_group.py b/scripts/vm/network/security_group.py
index be61842..873fdef 100755
--- a/scripts/vm/network/security_group.py
+++ b/scripts/vm/network/security_group.py
@@ -688,6 +688,8 @@ def cleanup_rules():
chainscmd = """iptables-save | awk '{for(i=1;i<=NF;i++){ if($i ~ /[i|r|s|v]-[0-9]/){print $i} } }'"""
chains = execute(chainscmd).split('\n')
cleanup = []
+ results = []
+ results = virshlist('paused', 'running')
for chain in chains:
if chain == "":
continue
@@ -700,14 +702,8 @@ def cleanup_rules():
vm_name = chain
- result = virshdomstate(vm_name)
-
- if result == None or len(result) == 0:
- logging.debug("chain " + chain + " does not correspond to a vm, cleaning up iptable rules")
- cleanup.append(vm_name)
- continue
- if not (result == "running" or result == "paused"):
- logging.debug("vm " + vm_name + " is not running or paused, cleaning up iptable rules")
+ if not vm_name in results:
+ logging.debug("chain " + chain + " does not correspond to a vm or vm is not running or paused, cleaning up iptable rules")
cleanup.append(vm_name)
chainscmd = """ebtables-save | awk '{for(i=1;i<=NF;i++){ if($i ~ /[i|r|s|v]-[0-9]/){print $i} } }'"""
@@ -720,17 +716,11 @@ def cleanup_rules():
if not chain.endswith("VM"):
chain = chain.split("VM")[0] + "VM"
- vm_name = chain
-
- result = virshdomstate(vm_name)
+ vm_name = chain
- if result == None or len(result) == 0:
- logging.debug("chain " + chain + " does not correspond to a vm, cleaning up ebtable rules")
- cleanup.append(vm_name)
- continue
- 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)
+ if not vm_name in results:
+ logging.debug("chain " + chain + " does not correspond to a vm or vm is not running or paused, cleaning up ebtable rules")
+ cleanup.append(vm_name)
for vmname in cleanup:
destroy_network_rules_for_vm(vmname)