%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@s%dZddlmZmZmZddlZeje�Zy.ddl	Z
ddlZ
ddlZ
e
ZWnek
r�ZeZnXddlZddlZddlmZd�Zdd�Zd�Zde
d	d
d�Zdd	d
d�Zdd	ed
d
�Zdddd	d
d�ZdS(uM
Support for RFC 2136 dynamic DNS updates.

:depends:   - dnspython Python module
:configuration: If you want to use TSIG authentication for the server, there
    are a couple of optional configuration parameters made available to
    support this (the keyname is only needed if the keyring contains more
    than one key)::

        keyfile: keyring file (default=None)
        keyname: key name in file (default=None)
        keyalgorithm: algorithm used to create the key
                      (default='HMAC-MD5.SIG-ALG.REG.INT').
            Other possible values: hmac-sha1, hmac-sha224, hmac-sha256,
                hmac-sha384, hmac-sha512


    The keyring file needs to be in json format and the key name needs to end
    with an extra period in the file, similar to this:

    .. code-block:: json

        {"keyname.": "keycontent"}
i(tabsolute_importtprint_functiontunicode_literalsN(tsixcC@str
dStdfS(u)
    Confirm dnspython is available.
    uddnsuDThe ddns execution module cannot be loaded: dnspython not installed.(tdns_supporttFalse(((s5/usr/lib/python2.7/site-packages/salt/modules/ddns.pyt__virtual__.scK@sZ|dkr|}n||kr.||}n(tddj|��}|sVd}n|S(u�
    Return a value for 'name' from command line args then config file options.
    Specify 'key' if the config file option is not the same as 'name'.
    u
config.optionuddns.{0}N(tNonet__salt__tformat(tnametkeytkwargstvalue((s5/usr/lib/python2.7/site-packages/salt/modules/ddns.pyt_config7s	
	cC@sRd}|rNtjjj|��(}tjjtjjj	|��}WdQXn|S(N(
Rtsalttutilstfilestfopentdnsttsigkeyringt	from_texttjsontload(tkeyfiletkeyringt_f((s5/usr/lib/python2.7/site-packages/salt/modules/ddns.pyt_get_keyringGs
*u	127.0.0.1ii5cK@s�t|||d||||||�	}	|	tkr7tSdj||�}
|jd�ddd�}g}x�t|�dkr�|jd�}
|j|
�djdj|�d	�}dj|�}t|||d
|
|||||�	}|rntSqnW|	S(u�
    Add, replace, or update the A and PTR (reverse) records for a host.

    CLI Example:

    .. code-block:: bash

        salt ns1 ddns.add_host example.com host1 60 10.1.1.1
    uAu{0}.{1}.u.Ni����iiu{0}.{1}u
in-addr.arpa.uPTR(	tupdateRR	tsplittlentpoptappendtjointTrue(tzoneR
tttltipt
nameservertreplacettimeouttportRtrestfqdntpartstpoppedtptptr((s5/usr/lib/python2.7/site-packages/salt/modules/ddns.pytadd_hostOs"	
c
K@s�dj||�}tjj|d�}tjj||||�}y*g|jdjD]}	|	j^qV}
Wnt	k
r�g}
nXt
||d|d|d||�}|d}x�|
D]�}|jd�ddd	�}
g}x�t|
�d
krk|
j
d�}|j|�djdj|
�d�}dj|�}t
||d|d|d|d||�}q�W|r�t}q�q�W|S(
u�
    Delete the forward and reverse records for a host.

    Returns true if any records are deleted.

    CLI Example:

    .. code-block:: bash

        salt ns1 ddns.delete_host example.com host1
    u{0}.{1}uAiR&R(R)u.Ni����iu
in-addr.arpa.uPTR(R	Rtmessaget
make_querytquerytudptanswertitemstaddresst
IndexErrortdeleteRRRR R!R"(R#R
R&R(R)RR+trequestR5titipsR*R%R,R-R.R/((s5/usr/lib/python2.7/site-packages/salt/modules/ddns.pytdelete_hostps.
*

	



c		K@s�tj|�}|ddkr(|}
ndj||�}
tjj|
|�}tjj||||�}tjj	|�}tj
j	tjj||�}
t
td|	��}td|	�}td|	�p�d}t}xi|jD]^}|
|jkr�||jkrAt|j�dks1t|j�dkr>t}Pq>qAq�q�Wtjj|d	|d
|d|�}|r�|j|||
�n |s�|j|||
�nd
Stjj||||�}|j�dkr�tStS(u[
    Add, replace, or update a DNS record.
    nameserver must be an IP address and the minion running this module
    must have update privileges on that server.
    If replace is true, first deletes all records for this name and type.

    CLI Example:

    .. code-block:: bash

        salt ns1 ddns.update example.com host1 60 A 10.0.0.1
    i����u.u{0}.{1}ukeyfileukeynameukeyalgorithmuHMAC-MD5.SIG-ALG.REG.INTiRtkeynametkeyalgorithmiN(Rt	text_typeR	RR1R2R3R4t	rdatatypeRtrdatat
rdataclasstINRRRR5R6R$RR"RtUpdateR'taddRtrcode(R#R
R$trdtypetdataR&R(R'R)RR+R:R5RBRR>R?tis_existtrrsett
dns_update((s5/usr/lib/python2.7/site-packages/salt/modules/ddns.pyR�s<	*	c
K@s~tj|�}|ddkr(|}ndj||�}tjj||pOd�}	tjj|	|||�}
|
js}d
St
td|��}td|�}td|�p�d}
tjj
|d	|d
|d|
�}|r<tjj|�}|r)tjjtjj||�}|j||�qI|j||�n
|j|�tjj||||�}
|
j�dkrztStS(u|
    Delete a DNS record.

    CLI Example:

    .. code-block:: bash

        salt ns1 ddns.delete example.com host1 A
    i����u.u{0}.{1}uANYukeyfileukeynameukeyalgorithmuHMAC-MD5.SIG-ALG.REG.INTRR>R?iN(RR@R	RR1R2R3R4R5RRRRRERARRBRCRDR9RGRR"(R#R
RHRIR&R(R)RR+R:R5RR>R?RLRB((s5/usr/lib/python2.7/site-packages/salt/modules/ddns.pyR9�s2			
(t__doc__t
__future__RRRtloggingt	getLoggert__name__tlogt	dns.queryRt
dns.updatetdns.tsigkeyringR"RtImportErrorteRtsalt.utils.filesRtsalt.utils.jsontsalt.extRRRRRR0R=RR9(((s5/usr/lib/python2.7/site-packages/salt/modules/ddns.pyt<module>s.

			 *5	

Zerion Mini Shell 1.0