mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	bug CS-16172
Reviewed-by: chiradeep
This commit is contained in:
		
							parent
							
								
									0d9b81aac6
								
							
						
					
					
						commit
						cefc5cbff3
					
				| @ -490,10 +490,8 @@ def cleanup_rules_for_dead_vms(): | |||||||
| 
 | 
 | ||||||
| def cleanup_rules(): | def cleanup_rules(): | ||||||
|     try: |     try: | ||||||
| 
 |  | ||||||
|         chainscmd = "iptables-save | grep '^:' | grep -v '.*-def' | grep -v '.*-eg' | awk '{print $1}' | cut -d':' -f2" |         chainscmd = "iptables-save | grep '^:' | grep -v '.*-def' | grep -v '.*-eg' | awk '{print $1}' | cut -d':' -f2" | ||||||
|         chains = execute(chainscmd).split('\n') |         chains = execute(chainscmd).split('\n') | ||||||
|     cleaned = 0 |  | ||||||
|         cleanup = [] |         cleanup = [] | ||||||
|         for chain in chains: |         for chain in chains: | ||||||
|             if 1 in [ chain.startswith(c) for c in ['r-', 'i-', 's-', 'v-'] ]: |             if 1 in [ chain.startswith(c) for c in ['r-', 'i-', 's-', 'v-'] ]: | ||||||
| @ -513,6 +511,26 @@ def cleanup_rules(): | |||||||
|                     logging.debug("vm " + vm_name + " is not running, cleaning up") |                     logging.debug("vm " + vm_name + " is not running, cleaning up") | ||||||
|                     cleanup.append(vm_name) |                     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'" | ||||||
|  |         chains = execute(chainscmd).split('\n') | ||||||
|  |         for chain in chains: | ||||||
|  |             if 1 in [ chain.startswith(c) for c in ['r-', 'i-', 's-', 'v-'] ]: | ||||||
|  |                 vm_name = chain | ||||||
|  |      | ||||||
|  |                 cmd = "virsh list |grep " + vm_name | ||||||
|  |                 try: | ||||||
|  |                     result = execute(cmd) | ||||||
|  |                 except: | ||||||
|  |                     result = None | ||||||
|  | 
 | ||||||
|  |                 if result == None or len(result) == 0: | ||||||
|  |                     logging.debug("chain " + chain + " does not correspond to a vm, cleaning up") | ||||||
|  |                     cleanup.append(vm_name) | ||||||
|  |                     continue | ||||||
|  |                 if result.find("running") == -1: | ||||||
|  |                     logging.debug("vm " + vm_name + " is not running, cleaning up") | ||||||
|  |                     cleanup.append(vm_name) | ||||||
|  | 
 | ||||||
|         for vmname in cleanup: |         for vmname in cleanup: | ||||||
|             destroy_network_rules_for_vm(vmname) |             destroy_network_rules_for_vm(vmname) | ||||||
|                      |                      | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user