%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@sdZddlmZmZmZddlZddlZddlZddl	Zddl
ZddlZddlZddl
ZddlZddlZddlmZeje�ZdZd�Zd�Zdd	�Zd
�Zd�Zd�Zd
�Zd�Zd�ZdS(u�
Fileserver backend which serves files pushed to the Master

The :mod:`cp.push <salt.modules.cp.push>` function allows Minions to push files
up to the Master. Using this backend, these pushed files are exposed to other
Minions via the Salt fileserver.

To enable minionfs, :conf_master:`file_recv` needs to be set to ``True`` in the
master config file (otherwise :mod:`cp.push <salt.modules.cp.push>` will not be
allowed to push files to the Master), and ``minionfs`` must be added to the
:conf_master:`fileserver_backends` list.

.. code-block:: yaml

    fileserver_backend:
      - minionfs

.. note::
    ``minion`` also works here. Prior to the 2018.3.0 release, *only*
    ``minion`` would work.

Other minionfs settings include: :conf_master:`minionfs_whitelist`,
:conf_master:`minionfs_blacklist`, :conf_master:`minionfs_mountpoint`, and
:conf_master:`minionfs_env`.

.. seealso:: :ref:`tutorial-minionfs`

i(tabsolute_importtprint_functiontunicode_literalsN(tsixuminionfscC@s&ttdkrtStdr"tStS(u+
    Only load if file_recv is enabled
    ufileserver_backendu	file_recv(t__virtualname__t__opts__tFalse(((s</usr/lib/python2.7/site-packages/salt/fileserver/minionfs.pyt__virtual__8scC@s'tjjj|dtddtd�S(uN
    Check if the minion is exposed, based on the whitelist and blacklist
    t	whitelistuminionfs_whitelistt	blacklistuminionfs_blacklist(tsalttutilststringutilstcheck_whitelist_blacklistR(tminion((s</usr/lib/python2.7/site-packages/salt/fileserver/minionfs.pyt_is_exposedAs
ubasecK@sdidd6dd6}tjj|�r*|S|t�kr=|Stjj|�dkritjd|�|Stjj	j
td�}|t|�j
tjj�}y|jtjd�\}}Wntk
r�|SXt|�s�|Stjjtdd	|d
|�}tjj|�r`tjjt|�r`||d<||d<ttj|��|d<|S|S(u6
    Search the environment for the relative path
    uupathurelutop.slsuIminionfs will NOT serve top.sls for security reasons (path requested: %s)uminionfs_mountpointiucachediruminionsufilesustat(tostpathtisabstenvstbasenametlogtdebugR
Rturltstrip_protoRtlentlstriptseptsplitt
ValueErrorRtjointisfilet
fileservertis_file_ignoredtlisttstat(Rttgt_envtkwargstfndt
mountpointRtpushed_filetfull((s</usr/lib/python2.7/site-packages/salt/fileserver/minionfs.pyt	find_fileLs6
	

cC@stdgS(u]
    Returns the one environment specified for minionfs in the master
    configuration.
    uminionfs_env(R(((s</usr/lib/python2.7/site-packages/salt/fileserver/minionfs.pyRqsc
C@sidd6dd6}|ds"|S|d|d<|jdd
�}tjj|d�}tjjj|d���}|j	|d�|j
td	�}|r�tj
r�tjjj|�r�|jt�}n|r�|r�tjjj||�}||d<n||d<Wd
QX|S(u3
    Return a chunk from a file based on the data received

    CLI Example:

    .. code-block:: bash

        # Push the file to the master
        $ salt 'source-minion' cp.push /path/to/the/file
        $ salt 'destination-minion' cp.get_file salt://source-minion/path/to/the/file /destination/file
    uudataudestupathurelugzipurbulocufile_buffer_sizeN(tgettNoneRRtnormpathR
RtfilestfopentseektreadRRtPY3t	is_binarytdecodet__salt_system_encoding__t	gzip_utiltcompress(tloadR&trettgziptfpathtfp_tdata((s</usr/lib/python2.7/site-packages/salt/fileserver/minionfs.pyt
serve_fileys 
%
cC@sEy*tjjtjjtdd�t�Wntjk
r@nXdS(uL
    When we are asked to update (regular interval) lets reap the cache
    ucachediru
minionfs/hashN(	R
R treap_fileserver_cache_dirRRRRR*terror(((s</usr/lib/python2.7/site-packages/salt/fileserver/minionfs.pytupdate�s	c

C@s@|d}i}d|kr,|jd�n|dt�krCiS|s]tjj|�ra|Std|d<tjjtddd|ddj|d	td��}tjj|�r�y�t	j
jj|d
���}y.t	j
j
j|j��jd�\}}Wn,tk
r5tjd�t||�|SXtjj|�|kr\||d
<|SWdQXWq�tjk
r�tjd�t||�|SXnt	j
jj|td�|d
<tjj|�}tjj|�s�tj|�ndj|d
tjj|��}	t	j
jj|d��}|j|	�WdQX|S(uL
    Return a file hash, the hash type is set in the master config file
    upathuenvusaltenvu	hash_typeucachediruminionfsuhashu{0}.hash.{1}urelurbu:u=Fileserver attempted to read incomplete cache file. Retrying.uhsumNu>Fileserver encountered lock when reading cache file. Retrying.u{0}:{1}uw(tpopRRRRRRtformattexistsR
RR.R/Rt
to_unicodeR1RRRRt	file_hashtgetmtimeR@t	hashutilstget_hashtdirnametmakedirstflopentwrite(
R8R&RR9t
cache_pathR<thsumtmtimet	cache_dirtcache_object((s</usr/lib/python2.7/site-packages/salt/fileserver/minionfs.pyRF�sR
	.



 "cC@s�d|kr|jd�n|dt�kr3gStjjjtd�}|jdd�jd�}|r�|j	|t
jj�r�|t
|t
jj�}nt
jjtdd�}t
j|�}|r|jd�\}}}|s�gS||krtjd	|�gS|g}ng}xa|D]Y}t|�sDq,nt
jj||d
�}	t
jj|	�s�tjdt
jj||��q,nt
jj|	|�}
x�tjjj|
dt�D]�\}}}x�|D]�}
t
jjt
jj||
��rq�nt
jjt
jj||
�|	�}|j	d
�r@q�nt
jj|||�}tjjt|�s�|j|�q�q�Wq�Wq,W|S(uR
    Return a list of all files on the file server in a specified environment
    uenvusaltenvuminionfs_mountpointuprefixuu/ucachediruminionsu3No files found in minionfs cache for minion ID '%s'ufilesu2minionfs: could not find files directory under %s!tfollowlinksu../(RBRR
RRRRR+tstript
startswithRRRRRtlistdirt	partitionRtwarningRtisdirRtos_walkRtislinktrelpathR R!tappend(R8R'tprefixtminions_cache_dirtminion_dirst
tgt_miniont_R9Rtminion_files_dirtwalk_dirtrootR.tfnameR\trel_fn((s</usr/lib/python2.7/site-packages/salt/fileserver/minionfs.pyt	file_list�sV
+
!	c
	C@s=d|kr|jd�n|dt�kr3gStjjjtd�}|jdd�jd�}|r�|j	|t
jj�r�|t
|t
jj�}nt
jjtdd�}t
j|�}|r|jd�\}}}|s�gS||krtjd	|�gS|g}ng}xt
j|�D]}t|�sMq5nt
jj||d
�}	t
jj|	�s�tjdt
jj||��q5nt
jj|	|�}
x�tjjj|
dt�D]d\}}}t
jj||	�}|dks�|j	d�rq�n|jt
jj|||��q�Wq5W|S(ub
    Return a list of all directories on the master

    CLI Example:

    .. code-block:: bash

        $ salt 'source-minion' cp.push /absolute/path/file  # Push the file to the master
        $ salt 'destination-minion' cp.list_master_dirs
        destination-minion:
            - source-minion/absolute
            - source-minion/absolute/path
    uenvusaltenvuminionfs_mountpointuprefixuu/ucachediruminionsu3No files found in minionfs cache for minion ID '%s'ufilesu2minionfs: could not find files directory under %s!RSu.u..u../(u.u..(RBRR
RRRRR+RTRURRRRRRVRWRRXRRYRZRR\R](
R8R'R^R_R`RaRbR9RRcRdReR\((s</usr/lib/python2.7/site-packages/salt/fileserver/minionfs.pytdir_list2sJ+'(t__doc__t
__future__RRRRtloggingtsalt.fileserverR
tsalt.utils.filestsalt.utils.gzip_utiltsalt.utils.hashutilstsalt.utils.pathtsalt.utils.stringutilstsalt.utils.urltsalt.utils.versionstsalt.extRt	getLoggert__name__RRRRR*RR>RARFRhRi(((s</usr/lib/python2.7/site-packages/salt/fileserver/minionfs.pyt<module>s.			%		"	
	E	E

Zerion Mini Shell 1.0