File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/win_dns_client.cpython-310.pyc
Back
o ;jo � @ s� d Z ddlZddlZzddlZddlZdZW n ey! dZY nw e�e �Z dd� Zddd �Zdd d�Z dd d�Zddd�Zddd�ZdS )z6 Module for configuring DNS Client on Windows systems � NTFc C s t jj�� sdS tsdS dS )z' Only works on Windows systems )Fz;Module win_dns_client: module only works on Windows systems)Fz1Module win_dns_client: missing required librariesZwin_dns_client)�salt�utils�platformZ is_windows�HAS_LIBS� r r �O/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/win_dns_client.py�__virtual__ s r �Local Area Connectionc C s� | � d�} d�| �} tjj�� �G t�� }|jdd�D ]4}| |j krO|j |jd��� }zt |j�W W d � S tyN g Y W d � S w qW d � n1 sZw Y t�d| � dS ) a� Return a list of the configured DNS servers of the specified interface Args: interface (:obj:`str`, optional): The name of the network interface. This is the name as it appears in the Control Panel under Network Connections. Default is ``Local Area Connection``. Returns: list: A list of dns servers CLI Example: .. code-block:: bash salt '*' win_dns_client.get_dns_servers 'Local Area Connection' �\� T)Z NetEnabled)�IndexNzInterface "%s" not foundF)�split�joinr r �winapi�Com�wmi�WMIZWin32_NetworkAdapterZNetConnectionID�!Win32_NetworkAdapterConfigurationr �pop�listZDNSServerSearchOrder� TypeError�log�debug)� interface�c�ifaceZiface_configr r r �get_dns_servers s. ��� � ���r c C s( ddddd|| dg}t d |dd �d kS )a� Remove the DNS server from the network interface Args: ip (str): The IP address of the DNS server to remove. interface (:obj:`str`, optional): The name of the network interface. This is the name as it appears in the Control Panel under Network Connections. Default is ``Local Area Connection``. CLI Example: .. code-block:: bash salt '*' win_dns_client.rm_dns <ip> <interface> �netshr �ip�delete�dns�validate=no�cmd.retcodeF�Zpython_shellr ��__salt__)r r �cmdr r r �rm_dnsG s � r'