%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/runners/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/runners/ddns.pyo

�
���^c@@sdZddlmZmZmZddlZddlZeZy.ddl	Z
ddlZ
ddlZ
e
ZWnek
r�eZnXddlZddlZeje�Zd�Zd�Zddd�Zeddd	�Zddddd
�Zddd�Zddd�ZdS(
u�
Dynamic DNS Runner
==================

.. versionadded:: Beryllium

Runner to interact with DNS server and create/delete/update DNS records

:codeauthor: Nitin Madhok <nmadhok@clemson.edu>

i(tabsolute_importtprint_functiontunicode_literalsNcC@sts
tStS(ug
    Check if required libs (python-dns) is installed and load runner
    only if they are present
    (tHAS_LIBStFalsetTrue(((s5/usr/lib/python2.7/site-packages/salt/runners/ddns.pyt__virtual__$scC@spd}|rltjjtjj|��rltjjj|��(}t	j
jtjjj
|��}WdQXn|S(N(tNonetostpathtisfilet
expandusertsalttutilstfilestfopentdnsttsigkeyringt	from_texttjsontload(tkeyfiletkeyringt_f((s5/usr/lib/python2.7/site-packages/salt/runners/ddns.pyt_get_keyring/s
$*i5uhmac-md5cC@sw||kr*|j|d�jd�}ndj||�}tjj||�}tjj||||	�}
tjj	|�}tj
j	tjj||�}x:|
j
D]/}||jkr�idj||j�|6Sq�Wt|�}tjj|d|d|d|
�}|j|||�tjj||||	�}
|
j�dkr]id	j|�|6Sid
j|||�|6S(u7
    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
    uu.u{0}.{1}u3Record of type '{0}' already exists with ttl of {1}Rtkeynametkeyalgorithmiu%Failed to create record of type '{0}'u(Created record of type '{0}': {1} -> {2}(treplacetrstriptformatRtmessaget
make_querytquerytudpt	rdatatypeRtrdatat
rdataclasstINtanswertitemstttlRtupdatetUpdatetaddtrcode(tzonetnameR(trdtypetdataRRt
nameserverttimeouttportRtfqdntrequestR&trdata_valueR#trrsetRt
dns_update((s5/usr/lib/python2.7/site-packages/salt/runners/ddns.pytcreate8s$	cC@s�||kr*|j|d�jd�}ndj||�}tjj||�}
tjj|
|||
�}|js�id|6Stj	j
|�}tjj
tjj
||�}x�|jD]|}||jkr�|j}||jkr2|	rt|j�dkst|j�dkrPnidj||�|6SPq�q�Wt|�}tjj|d|d|d	|�}|j|||�tjj||||
�}|j�d
kr�idj|�|6Sidj|�|6S(
u�
    Replace, or update a DNS record. The nameserver must be an IP address and the master running
    this runner must have update privileges on that server.

    .. note::

        If ``replace`` is set to True, all records for this name and type will first be deleted and
        then recreated. Default is ``replace=False``.

    CLI Example:

    .. code-block:: bash

        salt-run ddns.update domain.com my-test-vm 3600 A 10.20.30.40 my-tsig-key /etc/salt/tsig.keyring 10.0.0.1 5
    uu.u{0}.{1}uNo matching DNS record(s) foundiu4Record of type '{0}' already present with ttl of {1}RRRiu%Failed to update record of type '{0}'uUpdated record of type '{0}'(RRRRRRR R!R&R"RR#R$R%R'R(tlenRR)R*R,(R-R.R(R/R0RRR1R2RR3RR4R5R&R6R#R7trrRR8((s5/usr/lib/python2.7/site-packages/salt/runners/ddns.pyR)^s4			c
	C@sh||kr*|j|d�jd�}ndj||�}
tjj|
|pQd�}tjj||||�}|js�id|
6St	|�}
tj
j|d|
d|d|	�}|rtjj
|�}|rtjj
tjj||�}|j||�q%|j||�n
|j|�tjj||||�}|j�d	kr]id
|
6Sid|
6S(u�
    Delete a DNS record.

    CLI Example:

    .. code-block:: bash

        salt-run ddns.delete domain.com my-test-vm my-tsig-key /etc/salt/tsig.keyring 10.0.0.1 5 A
    uu.u{0}.{1}uANYuNo matching DNS record(s) foundRRRiuFailed to delete DNS record(s)uDeleted DNS record(s)(RRRRRRR R!R&RR)R*R"RR#R$R%tdeleteR,(R-R.RRR1R2R/R0R3RR4R5R&RR8R6R#((s5/usr/lib/python2.7/site-packages/salt/runners/ddns.pyR<�s*		
c
C@s�g}
||kr0|j|d�jd�}ndj||�}t|||d|||||||	�}|
j||�|jd�ddd�}
t|
�}g}x�|dkr~|
jd�}|d8}|j|�djdj|
�d	�}dj|�}dj||�}t|||d
dj|�||||||	�}d||kr�|
j||�i|
|6Sq�W|
j||�i|
|6S(
u�
    Create both A and PTR (reverse) records for a host.

    CLI Example:

    .. code-block:: bash

        salt-run ddns.add_host domain.com my-test-vm 3600 10.20.30.40 my-tsig-key /etc/salt/tsig.keyring 10.0.0.1 5
    uu.u{0}.{1}uANi����iiu
in-addr.arpa.uPTRu{0}.uCreated(	RRRR9tappendtsplitR:tpoptjoin(R-R.R(tipRRR1R2R3RtresR4trettpartstitpoppedtptrev_fqdn((s5/usr/lib/python2.7/site-packages/salt/runners/ddns.pytadd_host�s0

cC@s,g}||kr0|j|d�jd�}ndj||�}	tjj|	d�}
tjj|
|||�}y*g|jdj	D]}|j
^q�}
Wntk
r�g}
nXt||||||d|d|�}|j
dj||	��x'|
D]}|jd�d	d	d
�}t|�}g}x�|dkr|jd�}|d8}|j
|�djdj|�d�}dj|�}dj||�}t||||||d
dj|	�||�
}d||kr5|j
dj||��i||	6Sq5W|j
||�q�Wi||	6S(u
    Delete both forward (A) and reverse (PTR) records for a host only if the
    forward (A) record exists.

    CLI Example:

    .. code-block:: bash

        salt-run ddns.delete_host domain.com my-test-vm my-tsig-key /etc/salt/tsig.keyring 10.0.0.1 5
    uu.u{0}.{1}uAiR3Ru{0} of type 'A'Ni����iu
in-addr.arpa.uPTRu{0}.uDeletedu{0} of type 'PTR'(RRRRRRR R!R&R'taddresst
IndexErrorR<R=R>R:R?R@(R-R.RRR1R2R3RRBR4R5R&REtipsRCRARDRFRGRH((s5/usr/lib/python2.7/site-packages/salt/runners/ddns.pytdelete_host�s>*

	


(t__doc__t
__future__RRRRtloggingRRt	dns.queryRt
dns.updatetdns.tsigkeyringRtImportErrortsalt.utils.filesRtsalt.utils.jsont	getLoggert__name__tlogRRR9R)RR<RIRM(((s5/usr/lib/python2.7/site-packages/salt/runners/ddns.pyt<module>s.


		
&2*,

Zerion Mini Shell 1.0