File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/runners/__pycache__/ddns.cpython-310.pyc
o
�N�gQ# � @ s� d Z ddlZddlZddlZddlZdZzddlZddl Zddl
ZdZW n ey/ dZY nw e�e
�Zdd� Zdd� Z
ddd�Z
dd
d�Z
ddd�Z
ddd�Z
ddd�ZdS )z�
Dynamic DNS Runner
==================
.. versionadded:: 2015.8.0
Runner to interact with DNS server and create/delete/update DNS records
:codeauthor: Nitin Madhok <nmadhok@g.clemson.edu>
� NFTc C s t sdS dS )zg
Check if required libs (python-dns) is installed and load runner
only if they are present
FT)�HAS_LIBS� r r �E/opt/saltstack/salt/lib/python3.10/site-packages/salt/runners/ddns.py�__virtual__! s r c C sf d }| r1t j�t j�| ��r1tjj�| ��}tj �
tjj�|��}W d � |S 1 s,w Y |S )N)
�os�path�isfile�
expanduser�salt�utils�filesZfopen�dnsZtsigkeyring� from_text�json�load)�keyfile�keyringZ_fr r r �_get_keyring, s
��r �5 �hmac-md5c C s | |v r
|� | d��d�}|� d| � �}tj�||�}tj�|||| �}
tj�|�}tj �tj
j||�}|
jD ]}||j
v rI|d�||j�i S q7t|�}tjj| |||
d�}|�|||� tj�|||| �}
|
�� dkrv|d|� d�iS |d|� d |� d
|� �iS )a7
Create a DNS record. The nameserver must be an IP address and the master running
this runner must have create privileges on that server.
CLI Example:
.. code-block:: bash
salt-run ddns.create domain.com my-test-vm 3600 A 10.20.30.40 my-tsig-key /etc/salt/tsig.keyring 10.0.0.1 5
� �.z1Record of type '{}' already exists with ttl of {}�r �keyname�keyalgorithmr z!Failed to create record of type '�'zCreated record of type 'z': z -> )�replace�rstripr
�message�
make_query�query�udp� rdatatyper �rdata�
rdataclass�IN�answer�items�format�ttlr �update�Update�add�rcode)�zone�namer) �rdtype�datar r �
nameserver�timeout�portr �fqdn�requestr&