%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddlm	Z	ddl
mZeZ
yddlmZeZ
Wnek
r�nXddlZddlZddlZddlmZeje�ZdZid	d	6d
d
6dd6dd6d
d6d
d
6dd6dd6Zd�Zd�Zd�Z d�Z!ddddd�Z#ddd�Z$d�Z%ddd�Z&dd�Z'dd�Z(dd�Z)dS(u3
Manages configuration files via augeas

This module requires the ``augeas`` Python module.

.. _Augeas: http://augeas.net/

.. warning::

    Minimal installations of Debian and Ubuntu have been seen to have packaging
    bugs with python-augeas, causing the augeas module to fail to import. If
    the minion has the augeas module installed, but the functions in this
    execution module fail to run due to being unavailable, first restart the
    salt-minion service. If the problem persists past that, the following
    command can be run from the master to determine what is causing the import
    to fail:

    .. code-block:: bash

        salt minion-id cmd.run 'python -c "from augeas import Augeas"'

    For affected Debian/Ubuntu hosts, installing ``libpython2.7`` has been
    known to resolve the issue.
i(tabsolute_importtprint_functiontunicode_literalsN(tzip(tsix(tAugeas(tSaltInvocationErroruaugeasusetusetmumoveumvuinsertuinsuremoveurmcC@str
tStdfS(uG
    Only run this module if the augeas python module is installed
    uACannot load augeas_cfg module: augeas python module not installed(t
HAS_AUGEASt__virtualname__tFalse(((s;/usr/lib/python2.7/site-packages/salt/modules/augeas_cfg.pyt__virtual__Bscc@s|r{|jd�}||j|�fVxO|j|d�D]7}|jdd�}xt||�D]}|VqeWq=WndS(u�
    Recursive generator providing the infrastructure for
    augtools print behavior.

    This function is based on test_augeas.py from
    Harald Hoyer <harald@redhat.com>  in the python-augeas
    repository
    u/*u!u\!N(trstriptgettmatchtreplacet_recurmatch(tpathtaugt
clean_pathtit_match((s;/usr/lib/python2.7/site-packages/salt/modules/augeas_cfg.pyRKs	cC@s3tj|�j|�r/tj|�t|�S|S(uq
    Return a copy of the string after the specified prefix was removed
    from the beginning of the string
    (Rt	text_typet
startswithtlen(twordtprefix((s;/usr/lib/python2.7/site-packages/salt/modules/augeas_cfg.pyt_lstrip_word^scC@s�|dkst|tj�r#dSg}x[|jd�D]J}tjj|�rstjj|�rs|j	|�q9t
jd|�q9Wt|�dkr�dSdj
|�S(uk
    Checks the validity of the load_path, returns a sanitized version
    with invalid paths removed.
    u:u.Invalid augeas_cfg load_path entry: %s removediN(tNonet
isinstanceRtstring_typestsplittosRtisabstisdirtappendtlogtinfoRtjoin(t	load_patht_pathst_path((s;/usr/lib/python2.7/site-packages/salt/modules/augeas_cfg.pyt_check_load_pathsis$c@sitd6}id$d6d%d6d&d6d'd6d(d	6}�fd
�}t|�}|rf�rftjntj}td|d|�}|r��r�|j|tjd
d���|j�nx�|D]�}	y1|	j	dd�\}
}|
t
krdj|
�|d<|St
|
}||}
tj
jj|�}t|�|
krfdj||
|�}t|��n|dkr�||d�}t|�dkr�|dnd)}i|d6|d6}n>|dkr!||d�}|d}t|�dkr�|dnd)}i|d6|d6|d6}n�|dkr^||d�}|d}i|d6|d6}n�|dkr�|\}}}|d*kr�tdj|���n||�}i|d6|d6|dkd6}n,|d	kr�||d�}i|d6}nWnLtk
rH}tj|�dt�kr1|	}ndj|�|d<|SXtj
jj|d t�}tjd!||�t||�}||�q�Wy|j�t|d<WnXtk
r}tj|�|d<|r|jd"�r|dcd#j|�7<qnX|j �|S(+uU
    Execute Augeas commands

    .. versionadded:: 2014.7.0

    CLI Example:

    .. code-block:: bash

        salt '*' augeas.execute /files/etc/redis/redis.conf \
        commands='["set bind 0.0.0.0", "set maxmemory 1G"]'

    context
        The Augeas context

    lens
        The Augeas lens to use

    commands
        The Augeas commands to execute

    .. versionadded:: 2016.3.0

    load_path
        A colon-spearated list of directories that modules should be searched
        in. This is in addition to the standard load path and the directories
        in AUGEAS_LENS_LIB.
    uretvaliiusetiusetmumoveuinserturemovec@sV�s
|S|jd�rN|j��r,|S|jd�}tjj�|�S�SdS(u%
        Return correct path
        u/N(tlstripRRRR%(R(tcontext(s;/usr/lib/python2.7/site-packages/salt/modules/augeas_cfg.pyt	make_path�stflagstloadpathu^/filesuu u"Command {0} is not supported (yet)uerroru{0} takes {1} args: {2}iupathuvalueubaseusubusrcudstubeforeuafteru%Expected "before" or "after", not {0}ulabeluargu9Invalid formatted command, see debug log for details: {0}tto_stru%s: %su.lnsuF
Lenses are normally configured as "name.lns". Did you mean "{0}.lns"?(ii(ii(i(i(iN(ubeforeuafter(!R	R)t_AugeastNO_MODL_AUTOLOADtNONEt
add_transformtretsubtloadRt
METHOD_MAPtformattsalttutilstargstshlex_splitRt
ValueErrorRR#terrortlocalstdatatdecodetTruetdebugtgetattrtsavetIOErrorRRtendswithtclose(R+tlenstcommandsR&trettarg_mapR,R-RtcommandtcmdtargtmethodtnargstpartsterrRtvalueR;tbaseR5tdsttlabeltwheretfunc((R+s;/usr/lib/python2.7/site-packages/salt/modules/augeas_cfg.pytexecutes�





"
"

	


ucC@s�t|�}td|�}i}|jd�}|rU|dj|jd��7}ny|j|�}Wn$tk
r�}itj|�d6SX|r�|j	|�||<n
d||<|S(u�
    Get a value for a specific augeas path

    CLI Example:

    .. code-block:: bash

        salt '*' augeas.get /files/etc/hosts/1/ ipaddr

    path
        The path to get the value of

    value
        The optional value to get

    .. versionadded:: 2016.3.0

    load_path
        A colon-spearated list of directories that modules should be searched
        in. This is in addition to the standard load path and the directories
        in AUGEAS_LENS_LIB.
    R.u/u/{0}uerroru(
R)R0RR8tstripR
tRuntimeErrorRRR(RRTR&RRKRRS((s;/usr/lib/python2.7/site-packages/salt/modules/augeas_cfg.pyRs
c
G@sud}g|D]$}tj|�jd�r
|^q
}|r{t|�dkr^td��q{|djdd�d}nt|�}td|�}it	d6}g|D]>}tj|�jd�r�tj|�jd�r�|^q�}g|D]$}tj|�jd�r�|^q�}|rct|�dkrFtd	��qc|djdd�d}nt|�d
dkr�td��nt
|�}x�t||�D]�\}	}
|	}|r�tj
j|jd�|	jd��}ny|j|tj|
��Wq�tk
r+}d
j|�|d<q�Xq�Wy|j�t|d<Wn&tk
rp}tj|�|d<nX|S(u�
    Set a value for a specific augeas path

    CLI Example:

    .. code-block:: bash

        salt '*' augeas.setvalue /files/etc/hosts/1/canonical localhost

    This will set the first entry in /etc/hosts to localhost

    CLI Example:

    .. code-block:: bash

        salt '*' augeas.setvalue /files/etc/hosts/01/ipaddr 192.168.1.1 \
                                 /files/etc/hosts/01/canonical test

    Adds a new host to /etc/hosts the ip address 192.168.1.1 and hostname test

    CLI Example:

    .. code-block:: bash

        salt '*' augeas.setvalue prefix=/files/etc/sudoers/ \
                 "spec[user = '%wheel']/user" "%wheel" \
                 "spec[user = '%wheel']/host_group/host" 'ALL' \
                 "spec[user = '%wheel']/host_group/command[1]" 'ALL' \
                 "spec[user = '%wheel']/host_group/command[1]/tag" 'PASSWD' \
                 "spec[user = '%wheel']/host_group/command[2]" '/usr/bin/apt-get' \
                 "spec[user = '%wheel']/host_group/command[2]/tag" NOPASSWD

    Ensures that the following line is present in /etc/sudoers::

        %wheel ALL = PASSWD : ALL , NOPASSWD : /usr/bin/apt-get , /usr/bin/aptitude
    u
load_path=iu(Only one 'load_path=' value is permittediu=R.uretvaluprefix=u%Only one 'prefix=' value is permittediu%Uneven number of path/value argumentsu/uMultiple values: {0}uerrorN(RRRRRRRR)R0R	titerRRRR%RR*tsetR=R8RERBRF(
R;R&txt
load_pathsRRKttuplesRt
tuple_iterRRTttarget_pathRS((s;/usr/lib/python2.7/site-packages/salt/modules/augeas_cfg.pytsetvalue5sH%1

%1*
cC@s�t|�}td|�}i}y|j|�}Wntk
rH|SXxR|D]J}|r~|j|�|kr~|||<qP|sP|j|�||<qPqPW|S(u�
    Get matches for path expression

    CLI Example:

    .. code-block:: bash

        salt '*' augeas.match /files/etc/services/service-name ssh

    path
        The path to match

    value
        The value to match on

    .. versionadded:: 2016.3.0

    load_path
        A colon-spearated list of directories that modules should be searched
        in. This is in addition to the standard load path and the directories
        in AUGEAS_LENS_LIB.
    R.(R)R0R
R\R(RRTR&RRKtmatchesR((s;/usr/lib/python2.7/site-packages/salt/modules/augeas_cfg.pyR
�s


cC@s�t|�}td|�}itd6}y@|j|�}|j�|dkr]d|d<n
t|d<Wn,ttfk
r�}tj	|�|d<nX||d<|S(u�
    Get matches for path expression

    CLI Example:

    .. code-block:: bash

        salt '*' augeas.remove \
        /files/etc/sysctl.conf/net.ipv4.conf.all.log_martians

    path
        The path to remove

    .. versionadded:: 2016.3.0

    load_path
        A colon-spearated list of directories that modules should be searched
        in. This is in addition to the standard load path and the directories
        in AUGEAS_LENS_LIB.
    R.uretvali����uInvalid nodeuerrorucount(
R)R0R	tremoveRERBR\RFRR(RR&RRKtcountRS((s;/usr/lib/python2.7/site-packages/salt/modules/augeas_cfg.pyRf�s



c	@s��fd�}t|�}td|��|jd�d}|d}||�}i}xWtj|�D]F\}}t||�}||d�r�|||d<qi|||<qiW|S(u�
    List the direct children of a node

    CLI Example:

    .. code-block:: bash

        salt '*' augeas.ls /files/etc/passwd

    path
        The path to list

    .. versionadded:: 2016.3.0

    load_path
        A colon-spearated list of directories that modules should be searched
        in. This is in addition to the standard load path and the directories
        in AUGEAS_LENS_LIB.
    c@sey"�jtjjj|��}Wntk
r6iSXi}x!|D]}�j|�||<qDW|S(u Internal match function (R
R9R:tstringutilsR/R\R(RReRKt_ma(R(s;/usr/lib/python2.7/site-packages/salt/modules/augeas_cfg.pyR�s"

R.u/u*u/*(R)R0RRt	iteritemsR(	RR&Rt
match_pathReRKtkeyRTtname((Rs;/usr/lib/python2.7/site-packages/salt/modules/augeas_cfg.pytls�s
cC@sZt|�}td|�}|jd�d}|}tgt||�D]}|^qG�S(u�
    Returns recursively the complete tree of a node

    CLI Example:

    .. code-block:: bash

        salt '*' augeas.tree /files/etc/

    path
        The base of the recursive listing

    .. versionadded:: 2016.3.0

    load_path
        A colon-spearated list of directories that modules should be searched
        in. This is in addition to the standard load path and the directories
        in AUGEAS_LENS_LIB.
    R.u/(R)R0RtdictR(RR&RRkR((s;/usr/lib/python2.7/site-packages/salt/modules/augeas_cfg.pyttrees
((*t__doc__t
__future__RRRRR4tloggingtsalt.ext.six.movesRtsalt.extRR	RtaugeasRR0RBtImportErrortsalt.utils.argsR9tsalt.utils.datatsalt.utils.stringutilstsalt.exceptionsRt	getLoggert__name__R#RR7R
RRR)RRZRRdR
RfRnRp(((s;/usr/lib/python2.7/site-packages/salt/modules/augeas_cfg.pyt<module>sL


					�-	U)(3

Zerion Mini Shell 1.0