Set static DNS configuration on a Windows NIC

    Args:

        iface (str): The name of the interface to set

        addrs (*):
            One or more DNS servers to be added. To clear the list of DNS
            servers pass an empty list (``[]``). If undefined or ``None`` no
            changes will be made.

    Returns:
        dict: A dictionary containing the new DNS settings

    CLI Example:

    .. code-block:: bash

        salt -G 'os_family:Windows' ip.set_static_dns 'Local Area Connection' '192.168.1.1'
        salt -G 'os_family:Windows' ip.set_static_dns 'Local Area Connection' '192.168.1.252' '192.168.1.253'

def set_static_dns(iface, *addrs):
    '''
    Set static DNS configuration on a Windows NIC

    Args:

        iface (str): The name of the interface to set

        addrs (*):
            One or more DNS servers to be added. To clear the list of DNS
            servers pass an empty list (``[]``). If undefined or ``None`` no
            changes will be made.

    Returns:
        dict: A dictionary containing the new DNS settings

    CLI Example:

    .. code-block:: bash

        salt -G 'os_family:Windows' ip.set_static_dns 'Local Area Connection' '192.168.1.1'
        salt -G 'os_family:Windows' ip.set_static_dns 'Local Area Connection' '192.168.1.252' '192.168.1.253'
    '''
    if addrs is () or str(addrs[0]).lower() == 'none':
        return {'Interface': iface, 'DNS Server': 'No Changes'}
    # Clear the list of DNS servers if [] is passed
    if str(addrs[0]).lower() == '[]':
        log.debug('Clearing list of DNS servers')
        cmd = ['netsh', 'interface', 'ip', 'set', 'dns',
               'name={0}'.format(iface),
               'source=static',
               'address=none']
        __salt__['cmd.run'](cmd, python_shell=False)
        return {'Interface': iface, 'DNS Server': []}
    addr_index = 1
    for addr in addrs:
        if addr_index == 1:
            cmd = ['netsh', 'interface', 'ip', 'set', 'dns',
                   'name={0}'.format(iface),
                   'source=static',
                   'address={0}'.format(addr),
                   'register=primary']
            __salt__['cmd.run'](cmd, python_shell=False)
            addr_index = addr_index + 1
        else:
            cmd = ['netsh', 'interface', 'ip', 'add', 'dns',
                   'name={0}'.format(iface),
                   'address={0}'.format(addr),
                   'index={0}'.format(addr_index)]
            __salt__['cmd.run'](cmd, python_shell=False)
            addr_index = addr_index + 1
    return {'Interface': iface, 'DNS Server': addrs}