def preferred_ip(vm_, ips):
 proto = config.get_cloud_config_value('protocol', vm_, __opts__, default='ipv4', search_global=False)
 family = socket.AF_INET
 if (proto == 'ipv6'):
  family = socket.AF_INET6
 for ip in ips:
  try:
   socket.inet_pton(family, ip)
   return ip
  except Exception:
   continue
 return False

def preferred_ip ( vm_ , ips ) : proto = config . get_cloud_config_value ( 'protocol' , vm_ , __opts__ , default = 'ipv4' , search_global = False ) family = socket . AF_INET if ( proto == 'ipv6' ) : family = socket . AF_INET6 for ip in ips : try : socket . inet_pton ( family , ip ) return ip except Exception : continue return False
return the preferred internet protocol .