Refactor getting primary ip of a vm
This commit is contained in:
		
					parent
					
						
							
								1ec7cb8761
							
						
					
				
			
			
				commit
				
					
						4a5c5f7942
					
				
			
		
					 1 changed files with 2 additions and 8 deletions
				
			
		| 
						 | 
					@ -629,14 +629,8 @@ class OpenNebulaManager():
 | 
				
			||||||
                         "the ssh keys.".format(self.email))
 | 
					                         "the ssh keys.".format(self.email))
 | 
				
			||||||
            for order in all_orders:
 | 
					            for order in all_orders:
 | 
				
			||||||
                try:
 | 
					                try:
 | 
				
			||||||
                    vm = self.get_vm(order.vm_id)
 | 
					                    ip = self.get_primary_ip(order.vm_id)
 | 
				
			||||||
                    for nic in vm.template.nics:
 | 
					                    hosts.append(ip)
 | 
				
			||||||
                        if hasattr(nic, 'ip'):
 | 
					 | 
				
			||||||
                            if str(nic.ip).startswith("10."):
 | 
					 | 
				
			||||||
                                if hasattr(nic, 'ip6_global'):
 | 
					 | 
				
			||||||
                                    hosts.append(nic.ip6_global)
 | 
					 | 
				
			||||||
                            else:
 | 
					 | 
				
			||||||
                                hosts.append(nic.ip)
 | 
					 | 
				
			||||||
                except WrongIdError:
 | 
					                except WrongIdError:
 | 
				
			||||||
                    logger.debug(
 | 
					                    logger.debug(
 | 
				
			||||||
                        "VM with ID {} does not exist".format(order.vm_id))
 | 
					                        "VM with ID {} does not exist".format(order.vm_id))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue