%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/roots.pyo

�
���^c@@s2dZddlmZmZmZddlZddlZddlZddlZ	ddl
Z	ddlZ	ddlZ	ddl
Z	ddlZ	ddlZ	ddlZ	ddlZ	ddlmZeje�Zdd�Zd�Zd�Zd	�Zd
�Zd�Zd�Zd
�Zd�Zd�Z dS(u�
The default file server backend

This fileserver backend serves files from the Master's local filesystem. If
:conf_master:`fileserver_backend` is not defined in the Master config file,
then this backend is enabled by default. If it *is* defined then ``roots`` must
be in the :conf_master:`fileserver_backend` list to enable this backend.

.. code-block:: yaml

    fileserver_backend:
      - roots

Fileserver environments are defined using the :conf_master:`file_roots`
configuration option.
i(tabsolute_importtprint_functiontunicode_literalsN(tsixubasecK@s�d|kr|jd�ntjj|�}idd6dd6}tjj|�rX|S|tdkr�dtdkr�tjd|�d}q�|Snd�}d	|krRy td|t|d	�}Wn#t	k
r�|St
k
r�|SXtjj||�}tjj|�rNt
jjt|�rN||d<||d<||�S|Sxqtd|D]a}tjj||�}tjj|�rat
jjt|�ra||d<||d<||�SqaW|S(
u7
    Search the environment for the relative path.
    uenvuupathurelu
file_rootsu__env__u:salt environment '%s' maps to __env__ file_roots directorycS@s9y!ttj|d��|d<Wntk
r4nX|S(u0
        Stat the file and, assuming no errors were found, convert the stat
        result to a list of values and add to the return dict.

        Converting the stat result to a list, the elements of the list
        correspond to the following stat_result params:

        0 => st_mode=33188
        1 => st_ino=10227377
        2 => st_dev=65026
        3 => st_nlink=1
        4 => st_uid=1000
        5 => st_gid=1000
        6 => st_size=1056233
        7 => st_atime=1468284229
        8 => st_mtime=1456338235
        9 => st_ctime=1456338235
        upathustat(tlisttoststatt	Exception(tfnd((s9/usr/lib/python2.7/site-packages/salt/fileserver/roots.pyt_add_file_stat<s
!
uindex(tpopRtpathtnormpathtisabst__opts__tlogtdebugtintt
IndexErrort
ValueErrortjointisfiletsaltt
fileservertis_file_ignored(RtsaltenvtkwargsRR	troottfull((s9/usr/lib/python2.7/site-packages/salt/fileserver/roots.pyt	find_file(sB

		 

(


(

cC@sttd�S(u-
    Return the file server environments
    u
file_roots(tsortedR(((s9/usr/lib/python2.7/site-packages/salt/fileserver/roots.pytenvsmsc
C@s d|kr|jd�nidd6dd6}d|ksTd|ksTd|krX|S|dsf|S|d|d<|jd	d�}tjj|d�}tjjj	|d
��f}|j
|d�|jtd�}|r|rtjj
j||�}||d	<n||d<WdQX|S(
u?
    Return a chunk from a file based on the data received
    uenvuudataudestupathulocusaltenvurelugzipurbufile_buffer_sizeN(R
tgettNoneRRRRtutilstfilestfopentseektreadRt	gzip_utiltcompress(tloadRtrettgziptfpathtfp_tdata((s9/usr/lib/python2.7/site-packages/salt/fileserver/roots.pyt
serve_filets&

$

cC@sy-tjjtjjtddd�t�Wntt	fk
rFnXtjjtddd�}it
d6igd6d6dd6}tjjttd�}i}tjj|�r�tj
jj|d	���}x�|D]�}tj
jj|�}yb|jd
d�jdd
�\}}|||<||j||�krT|ddj|�nWq�tk
r{tjd||�q�Xq�WWdQXntjj||�|d<t|j��}t|j��}	t||	�|dd<t|	|�|dd<tjj|�}
tjj|
�s*tj|
�ntj
jj|d��O}xEtj |�D]4\}}|j!tj
jj"dj#||���qUWWdQXtjdt
�rtj
j$j%dtdtddtdt
�}|j&|tj
j$j'ddgdd��ndS(uL
    When we are asked to update (regular interval) lets reap the cache
    ucachedirurootsuhashu	mtime_mapuchangedufilesubackendu
file_rootsurbu
uu:iu+Skipped invalid cache mtime entry in %s: %sNuremoveduaddeduwbu{0}:{1}
ufileserver_eventsumasterusock_diru	transporttoptstlistenuupdatetprefixu
fileserver((RRtreap_fileserver_cache_dirRRRRRtIOErrortOSErrortFalsetgenerate_mtime_maptexistsR"R#R$tstringutilst
to_unicodetreplacetsplitR tappendRRtwarningtdiff_mtime_maptsettkeysRtdirnametmakedirsRt	iteritemstwritetto_bytestformatteventt	get_eventt
fire_eventttagify(tmtime_map_pathR.t
new_mtime_mapt
old_mtime_mapR-tlinet	file_pathtmtimet	old_filest	new_filestmtime_map_path_dirRH((s9/usr/lib/python2.7/site-packages/salt/fileserver/roots.pytupdate�s^	


$

 
		cC@s�d|kr|jd�nd|ks4d|kr8dS|d}|d}|tdkrudtdkrud}ni}|s�tjj|�r�|Std|d<tjjtdd	d
|dj|dtd��}tjj|�ry�tj	j
j|d
���}y.tj	jj
|j��jd�\}}WnMtk
r�tjd�ytj|�Wntk
r|nXt||�SXttjj|��|kr�||d<|SWdQXWqtjtfk
rtjd�ytj|�Wntk
rnXt||�SXntj	jj|td�|d<tjj|�}	tjj|	�s�ytj|	�Wq�tk
r�}
|
jtjkr�q��q�Xndj|dtjj|��}tj	j
j |d��}|j!|�WdQX|S(uL
    Return a file hash, the hash type is set in the master config file
    uenvupathusaltenvuu
file_rootsu__env__u	hash_typeucachedirurootsuhashu{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("R
RRRRRRGR8RR"R#R$R9R:R&R<RRRtunlinkR5t	file_hashtstrtgetmtimeterrorR4t	hashutilstget_hashRBRCterrnotEEXISTtflopenRE(R)RRRR*t
cache_pathR-thsumRQt	cache_dirterrtcache_object((s9/usr/lib/python2.7/site-packages/salt/fileserver/roots.pyRW�sj

 	
.





 
"c@s�d|kr|jd�n|d}|tdkrfdtdkr_tjd|�d}qfgSntjjtddd�}tjj|�s�ytj|�Wq�tj	k
r�tj
d	|�gSXntjj|d
jtj
jj|���}tjj|djtj
jj|���}tjjt|||�\}}}|dk	r^|S|r�it�d6t�d
6t�d6id6��fd�}	xwtd|D]g}
x^tj
jj|
dtd�D]=\}}}
|	�d
|
||�|	�d|
||
�q�Wq�Wt�d��d<t�d
��d
<t�d��d<|r�ytjjt�||�Wq�tk
r�q�Xn�j|g�SgS(uX
    Return a dict containing the file lists for files, dirs, emtydirs and symlinks
    uenvusaltenvu
file_rootsu__env__u:salt environment '%s' maps to __env__ file_roots directoryucachediru
file_listsurootsuUnable to make cachedir %su{0}.pu.{0}.wufilesudirsu
empty_dirsulinksc@sFd�}x6|D].}tjj||�}tjd|�tjjj|�}tjd||shdnd�|r�tdr�qn|tjj	||��}tjd||�tj
jt|�r�qn|j|�y'tj
|�s�dj|�nWntk
rnX|rtjjj|�}	tjd	||	�tjjj�r�|	jd
�r�tjd|	|�|}	n|	jd�r�tjj||	�}
n!tjjtjj|�|	�}
|tjj	tjjtjj|
��tjj|���}tjd||�|jd�s>|	�d
|<q>qqWdS(u9
            Add the files to the target set
            cS@s&tjjdkr"|jdd�S|S(uZ
                Translate path separators for Windows masterless minions
                u\u/(RRtsepR;(R((s9/usr/lib/python2.7/site-packages/salt/fileserver/roots.pyt_translate_sepRsuroots: Processing %suroots: %s is %sa linkunot uufileserver_ignoresymlinksuroots: %s relative path is %su
empty_dirsu#roots: %s symlink destination is %su\\u)roots: %s is a UNC path, using %s insteadu..ulinksN(RRRRttraceRR"tislinkRtrelpathRRtaddtlistdirRtreadlinktplatformt
is_windowst
startswithRBtrealpathR(ttgttfs_roott
parent_dirtitemsRftitemtabs_pathtis_linktrel_patht	link_desttjoinedtrel_dest(R*(s9/usr/lib/python2.7/site-packages/salt/fileserver/roots.pyt_add_toNsX	




			
tfollowlinksufileserver_followsymlinksN(R
RRRRRRtisdirRCRZtcriticalRGRR"R#tsafe_filename_leafRtcheck_file_list_cacheR!R@tos_walkRtwrite_file_list_cachet	NameErrorR (R)tformRt
list_cachedirt
list_cachetw_locktcache_matcht
refresh_cachet
save_cacheR|RRtdirsR#((R*s9/usr/lib/python2.7/site-packages/salt/fileserver/roots.pyt_file_lists'sZ
	--	



G	
cC@s
t|d�S(uV
    Return a list of all files on the file server in a specified
    environment
    ufiles(R�(R)((s9/usr/lib/python2.7/site-packages/salt/fileserver/roots.pyt	file_list�scC@s
t|d�S(u>
    Return a list of all empty directories on the master
    u
empty_dirs(R�(R)((s9/usr/lib/python2.7/site-packages/salt/fileserver/roots.pytfile_list_emptydirs�scC@s
t|d�S(u8
    Return a list of all directories on the master
    udirs(R�(R)((s9/usr/lib/python2.7/site-packages/salt/fileserver/roots.pytdir_list�scC@s�d|kr|jd�ni}|dtdkrJdtdkrJ|Sd|krl|djd�}nd}t|d�}tgtj|�D]'\}}|j|�r�||f^q��S(	uK
    Return a dict of all symlinks based on a given path on the Master
    uenvusaltenvu
file_rootsu__env__uprefixu/uulinks(R
RtstripR�tdictRRDRo(R)R*R2tsymlinkstkeytval((s9/usr/lib/python2.7/site-packages/salt/fileserver/roots.pytsymlink_list�s$(!t__doc__t
__future__RRRRR]tloggingtsalt.fileserverRtsalt.utils.eventtsalt.utils.filestsalt.utils.gzip_utiltsalt.utils.hashutilstsalt.utils.pathtsalt.utils.platformtsalt.utils.stringutilstsalt.utils.versionstsalt.extRt	getLoggert__name__RRRR/RURWR�R�R�R�R�(((s9/usr/lib/python2.7/site-packages/salt/fileserver/roots.pyt<module>s2E			I	O	�			

Zerion Mini Shell 1.0