def extract_ipv4(roster_order, ipv4):
 for ip_type in roster_order:
  for ip_ in ipv4:
   if (':' in ip_):
    continue
   if (not salt.utils.validate.net.ipv4_addr(ip_)):
    continue
   if ((ip_type == 'local') and ip_.startswith('127.')):
    return ip_
   elif ((ip_type == 'private') and (not salt.utils.cloud.is_public_ip(ip_))):
    return ip_
   elif ((ip_type == 'public') and salt.utils.cloud.is_public_ip(ip_)):
    return ip_
 return None

def extract_ipv4 ( roster_order , ipv4 ) : for ip_type in roster_order : for ip_ in ipv4 : if ( ':' in ip_ ) : continue if ( not salt . utils . validate . net . ipv4_addr ( ip_ ) ) : continue if ( ( ip_type == 'local' ) and ip_ . startswith ( '127.' ) ) : return ip_ elif ( ( ip_type == 'private' ) and ( not salt . utils . cloud . is_public_ip ( ip_ ) ) ) : return ip_ elif ( ( ip_type == 'public' ) and salt . utils . cloud . is_public_ip ( ip_ ) ) : return ip_ return None
extract the preferred ip address from the ipv4 grain .