(dns_list)
Validate a string is a single dns address or comma separated dns list

    :param dns_list: dns_list to be validated
    :returns: original dns_list.
    :raise: InvalidDNS if dns format is invalid
Validate a string is a single dns address or comma separated dns list
Validate a string is a single dns address or comma separated dns list
def validate_dns(dns_list):
    """Validate a string is a single dns address or comma separated dns list

    :param dns_list: dns_list to be validated
    :returns: original dns_list.
    :raise: InvalidDNS if dns format is invalid

    """
    dns_nameservers = dns_list.split(',')
    try:
        for dns in dns_nameservers:
            netaddr.IPAddress(dns.strip(), version=4, flags=netaddr.INET_PTON)
    except netaddr.AddrFormatError:
        raise exception.InvalidDNS(dns=dns_list)
    else:
        return dns_list
def validate_dns ( dns_list ) : dns_nameservers = dns_list . split ( ',' ) try : for dns in dns_nameservers : netaddr . IPAddress ( dns . strip ( ) , version = 4 , flags = netaddr . INET_PTON ) except netaddr . AddrFormatError : raise exception . InvalidDNS ( dns = dns_list ) else : return dns_list