%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/fileclient.pyc

�
���^c@@szdZddlmZmZmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
mZmZddlZddlmZmZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Zddl!Zddl"Zddl#Zddl$Zddl%m&Z&ddl'm(Z(ddl)j*j(j+j,Z,ddl-m.Z.m/Z/dd	l0m1Z1m2Z2ej3e4�Z5d
Z6e7d�Z8d�Z9d
e:fd��YZ;de;fd��YZ<de;fd��YZ=de=fd��YZ>e>Z?de:fd��YZ@dS(u"
Classes that manage file clients
i(tabsolute_importtprint_functiontunicode_literalsN(tparse_response_start_linetHTTPHeaderstHTTPInputError(tCommandExecutionErrortMinionError(t	SaltSwift(tsix(t	HTTPErrortURLError(turlparset
urlunparsei�cC@sX|jdd�}|r-|dkr-d}nitd6td6td6j|t�|�S(u[
    Read in the ``file_client`` option and return the correct type of file
    server
    ufile_clienturemoteulocalupillar(tgettRemoteClienttFSClienttPillarClient(toptstpillartclient((s3/usr/lib/python2.7/site-packages/salt/fileclient.pytget_file_client3s	
cC@s�tjst|t�r|Si}x]tj|�D]L\}}t|t�rvy|j�}Wqvtk
rrqvXn|||<q4W|S(u�
    Convert top level keys from bytes to strings if possible.
    This is necessary because Python 3 makes a distinction
    between these types.
    (R	tPY3t
isinstancetdictt	iteritemstbytestdecodetUnicodeError(tsrctoutputtkeytval((s3/usr/lib/python2.7/site-packages/salt/fileclient.pytdecode_dict_keys_to_strBs
tClientcB@s�eZdZd�Zd�Zd�Zd�Zd�Zej	de
d��Ze
d�Zd	e
de
e
d
�Zdd	d�Zde
e
d�Zde
d
�Zde
d�Zde
e
e
e
d�Zd�Zdd�Zdd	d�Zdd	d�Zdd	d�Zde
d�Zd�Ze
d�Zd	de
e
d�Ze
de
e
e
d�Zde
de
d�Ze
d�ZRS(u/
    Base class for Salt file interactions
    cC@s=||_tjj|j�|_tjj|j�|_dS(N(RtsalttloadertutilstpayloadtSerialtserial(tselfR((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyt__init__Zs	cC@s|j|d�dS(Nuopts(R*(R)tstate((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyt__setstate__dscC@si|jd6S(Nuopts(R(R)((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyt__getstate__iscC@sF|jd�s'tdj|���ntjjj|�\}}|S(uV
        Make sure that this path is intended for the salt master and trim it
        usalt://uUnsupported path: {0}(t
startswithRtformatR#R%turltparse(R)tpatht	file_pathtsaltenv((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyt_check_protolsc	C@s�tjj|�r|}ntjj|�}t�}x_tjjj|dt�D]B\}}}x0|D](}tjj	||�}|j
|�qhWqRW|S(uF
        Helper util to return a list of files in a directory
        tfollowlinks(tosR2tisdirtdirnametsetR#R%tos_walktTruetjointadd(	R)tdesttdestdirtfilelisttroottdirstfilestnameR2((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyt_file_local_listus		+
ubasec	c@s�|j|�}tjjj|d||�}tjj|�}tjjjd��ktjj	|�rwtj
|�nytj|�Wn+tk
r�}|j
t
jkr��q�nX|VWdQXdS(uV
        Return the local location to cache the file, cache dirs will be made
        ufilesi?N(tget_cachedirR#R%R2R=R7R9RDt	set_umasktisfiletremovetmakedirstOSErrorterrnotEEXIST(R)R2R4tcachedirR?R@texc((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyt
_cache_loc�s	
cC@sQ|dkr|jd}n1tjj|�sMtjj|jd|�}n|S(Nucachedir(tNoneRR7R2tisabsR=(R)RO((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyRG�s
ucC@s
t�dS(ub
        Copies a file from the local files or master depending on
        implementation
        N(tNotImplementedError(R)R2R?RKR4tgzipRO((s3/usr/lib/python2.7/site-packages/salt/fileclient.pytget_file�scC@s
t�dS(u%
        List the empty dirs
        N(RT(R)R4tprefix((s3/usr/lib/python2.7/site-packages/salt/fileclient.pytfile_list_emptydirs�sc	C@s"|j|dt|d|d|�S(ue
        Pull a file down from the file server and store it in the minion
        file cache
        uROtsource_hash(tget_urlR<(R)R2R4RORY((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyt
cache_file�scC@s^g}t|tj�r*|jd�}nx-|D]%}|j|j||d|��q1W|S(um
        Download a list of files stored on the master and put them in the
        minion file cache
        u,RO(RR	tstring_typestsplittappendR[(R)tpathsR4ROtretR2((s3/usr/lib/python2.7/site-packages/salt/fileclient.pytcache_files�s
#cC@sRg}xE|j|�D]4}|j|jtjjj|�|d|��qW|S(uU
        Download and cache all files on a master in a specified environment
        RO(t	file_listR^R[R#R%R0tcreate(R)R4ROR`R2((s3/usr/lib/python2.7/site-packages/salt/fileclient.pytcache_master�s&cC@s�g}|jtjjj|��}|jd�s@|d}ntjd||�x�|j|�D]�}tjjj|�}|j	�rc|j
|�rctjjj|||�r�|j
tjjj|�|d|�}|r�|j|�q�q�qcqcW|r�|j|�}tjjj|d|�}	x�|j|�D]n}tjjj|�}|j
|�r;dj|	|�}
tjj|
�s�tj|
�n|j|
�q;q;Wn|S(uE
        Download all of the files in a subdir of the master
        u/u+Caching directory '%s' for environment '%s'ROufilesu{0}/{1}(R5R#R%tdataRtendswithtlogtinfoRbtstripR.tstringutilstcheck_include_excludeR[R0RcR^RGR2R=RXR/R7R8RK(R)R2R4t
include_emptytinclude_pattexclude_patROR`tfn_R?t
minion_dir((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyt	cache_dir�s4

!
cK@sptjj|jdd|jd��}tjj|�}tjj|�s\tj|�ntj	||�|S(uJ
        Cache a local file on the minion in the localfiles cache
        ucachediru
localfilesu/(
R7R2R=RtlstripR9R8RKtshutiltcopyfile(R)R2tkwargsR?R@((s3/usr/lib/python2.7/site-packages/salt/fileclient.pytcache_local_filescC@sltjj|jdd|�}tjj|jdd�}|j|�}|j|�}t|j|��S(uL
        List files in the local minion files and localfiles caches
        ucachedirufilesu
localfiles(R7R2R=RRFtsortedtunion(R)R4t	filesdesttlocalfilesdesttfdesttldest((s3/usr/lib/python2.7/site-packages/salt/fileclient.pytfile_local_lists
cC@sgS(u3
        This function must be overwritten
        ((R)R4RW((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyRb'scC@sgS(u3
        This function must be overwritten
        ((R)R4RW((s3/usr/lib/python2.7/site-packages/salt/fileclient.pytdir_list-scC@siS(u3
        This function must be overwritten
        ((R)R4RW((s3/usr/lib/python2.7/site-packages/salt/fileclient.pytsymlink_list3sc	C@s@|jd�r<tjjj|�\}}|r<|}q<ntjjj|�rWtnt}tj	j
|jdd|jd��}tj	j
|jdd||jd��}|j
||d|�}tj	j|�r�|r�tjjj|�S|Stj	j|�r&|r"tjjj|�S|Stj	j|�r<|SdS(u�
        Returns the full path to a file if it is cached locally on the minion
        otherwise returns a blank string
        usalt://ucachediru
localfilesu|/ufilesROu(R.R#R%R0R1t
is_escapedR<tFalseR7R2R=RRrt_extrn_pathtexiststescape(	R)R2R4ROtsenvtescapedtlocalsfilesdestRyt	extrndest((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyt	is_cached9s$!		"cC@s�t�}x�|j|�D]�}tjjj�rF|jdd�}n|jd�r|jd�r�|j|jdd�d �q�|j|jdd�d �qqWt	|�S(uj
        Return a list of all available sls modules on the master for a given
        environment
        u\u/u.slsu	/init.slsu.i����i����(
R:RbR#R%tplatformt
is_windowstreplaceRfR>Rw(R)R4tstatesR2((s3/usr/lib/python2.7/site-packages/salt/fileclient.pytlist_statesWs	 $cC@s�d|kr!|jdd�}ntjjj|d�}tjjj|d�}xD||gD]6}|j||d|�}|r`i|d6|d6Sq`WiS(u�
        Get a state file from the master and store it in the local minion
        cache; return the location of the file
        u.u/u.slsu	/init.slsROusourceudest(R�R#R%R0RcR[(R)tslsR4ROtsls_urltinit_urlR2R?((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyt	get_statehscC@s�g}|j|�jd�}|jdd�}t|�dkrKd}n
|d}x�|j|d|�D]�}	y |	t|�dkr�wknWntk
r�qknX|	t|�jd�}
|j|jt	j
jj|	�dj
||
�t||��qkWy�x�|j|d|�D]�}	y |	t|�dkr@wnWntk
rWqnX|	t|�jd�}
dj
||
�}tjj|�s�tj|�n|j|�qWWntk
r�nX|j�|S(uB
        Get a directory recursively from the salt-master
        u/iiuiRWu{0}/{1}(R5trstriptrsplittlenRbt
IndexErrorRrR^RVR#R%R0RcR/R<RXR7R2R8RKt	TypeErrortsort(R)R2R?R4RUROR`t	separatedRWRotminion_relpathtminion_mkdir((s3/usr/lib/python2.7/site-packages/salt/fileclient.pytget_dirwsD	






c%@sAt|�}|j}	tjj|j|j�jtj�}
|dk	r�tjj	|�si|j
dI�r�|js�t|j�dkr�|jj
d�r�|j
d�d}nd}tjjj�r�tjjj|�}ntjj||�}n|	r1|	j�tjkr1dj|	|
f�}
d}	n|	dJkr�tjj|
�sgtd	j|
���n|dkr�tjjj|
d
��}|j�}
WdQX|
S|
S|	dkr�j||||d
|���r|dkrtjjj�d
��}|j�}
WdQX|
S�S|rctjj|�}tjj	|�sO|rYtj|�q`dSqOn�|sO�j||d
|�}|dk	ryh|j
d�d}tjjj t|�}tjj!j"||�|kr�t#j$d|||�|SWqt%t&t't(fk
rqXntjj|�}tjj	|�sOtj|�qOn|jdkrBy�d�fd�}�jdddd|jd|jddt)d|ddd|d�d|d�d|d�d |d!t*�d"|d#�d$|d%t)�d&|d't*��
|SWqBt+k
r>}t,d(j||���qBXn|jd)kry�t-j.�}|j/|j0|j1�|j2|j3|j4�|jj5d�}tjjj|d*��#}|j6d+j|�|j7�WdQX|j8�|SWqt+k
r}t,d,j||���qXn|jd-kr�ym�fd.�}t9|d/d�|d0d�|d1d�|d2d��}|j:|j|jd|�|SWq�t+k
r�t,d3j|���q�Xni}|j3dk	rb|jdKkrb|j}|j;d6�}|dkr||d}nt<|j||j|j=|j|j>f�}|j3|j4f|d7<n|}d�z�y@dt)dg��fd8�}|r�g���fd9�}n9d:j|�}tjjj|d*����fd;�}tjj?j|d<t*d=|d>|d?|j3d@|j4dA�j@|�}dB|kr\t,dCj|dD|���n|r��dErydj��SdFj��S�jA�d�tjjjB||�|SWnktCk
r�}t,dGj|jD|tEjFjG|jD���n.tHk
r}t,dHj||jI���nXWd�dk	r<�jA�nXdS(Lu/
        Get a single file from a URL.
        u/u\ii����u
index.htmlu:ufileuuPath '{0}' is not absoluteurbNusaltROu=u@Cached copy of %s (%s) matches source_hash %s, skipping downloadus3c@sXd|�jkr"�jd|Sy�jdd|SWnttfk
rS|SXdS(ua
                    Get value of s3.<key> from Minion config or from Pillar
                    us3.upillarus3N(RtKeyErrorR�(Rtdefault(R)(s3/usr/lib/python2.7/site-packages/salt/fileclient.pyts3_opt�sus3.querytmethoduGETtbucketR2t
return_bint
local_filetactionRukeytkeyidukeyidtservice_urluservice_urlt
verify_sslu
verify_ssltlocationulocationt
path_styleu
path_stylethttps_enableuhttps_enableu(Could not fetch from {0}. Exception: {1}uftpuwbuRETR {0}u6Could not retrieve {0} from FTP server. Exception: {1}uswiftc@sL|�jkr�j|Sy�jd|SWnttfk
rG|SXdS(u^
                    Get value of <key> from Minion config or from Pillar
                    upillarN(RR�R�(RR�(R)(s3/usr/lib/python2.7/site-packages/salt/fileclient.pyt	swift_opt'su
keystone.userukeystone.tenantukeystone.auth_urlukeystone.passworduCould not fetch from {0}uhttpuhttpsu@uauthc@s��dtk	r[�ddkr[|j�rhd�dkrh�dtk	rZd�d<nt�d<dS�dj|�d�dkr[�djd�}|jd�s�t�d<�d<n\d}|jd�}x0|D](}d|kr�|jd	�d
}q�q�W|�d<t�d<�d�dko;tknrXd�d<�d<qXq[n�ddkr�yt|�}Wnt	k
r�dSX|j
dk�d<t��d<ndS(NiiuContent-Typeiutextuutf-8u;uencodingu	encoding=i����i-i.i/i3(i-i.i/i3(R�RRRiR<t
parse_lineRR.R]RRtcodeR(thdrtcontent_typetencodingtfieldstfield(t
write_body(s3/usr/lib/python2.7/site-packages/salt/fileclient.pyt	on_headerjs6 




	$
c@s>�dr:�dr*|j�d�}n�j|�ndS(Nii(RR^(tchunk(tresultR�(s3/usr/lib/python2.7/site-packages/salt/fileclient.pyton_chunk�s

u{0}.partc@s�dr�j|�ndS(Ni(twrite(R�(tdestfpR�(s3/usr/lib/python2.7/site-packages/salt/fileclient.pyR��s
tstreamtstreaming_callbacktheader_callbacktusernametpasswordRuhandleuError: {0} reading {1}uerrorituHTTP error {0} reading {1}: {3}uError reading {0}: {1}(u/u\(ufileu(uhttpuhttps(JRtschemeR7R2R=tnetlocR�tsepRRR8RftqueryR�R]R#R%R�R�tsanitize_win_pathtlowertstringtascii_lowercaseRSRR/RDtfopentreadRVR9RKR�t
HASHES_REVMAPt	hashutilstget_hashRgtdebugtAttributeErrorR�tIOErrorRLR�R<t	ExceptionRtftplibtFTPtconnectthostnametporttloginR�R�Rrt
retrbinaryR�tquitRt
get_objecttrfindR
tparamstfragmentthttpRtclosetrenameR
R�tBaseHTTPServertBaseHTTPRequestHandlert	responsesRtreason(R)R0R?RKR4tno_cacheRORYturl_datat
url_schemeturl_pathtstrpathtfp_ReR@tformR�RPtftptremote_file_pathR�t
swift_connt
get_kwargsR�tat_sign_post	fixed_urlR�R�tdest_tmpR�((R�R�R)R�s3/usr/lib/python2.7/site-packages/salt/fileclient.pyRZ�s*		!1	


	
"


	2			



	#ujinjacK@sid|kr|jd�n||d<t|�}|j||d|�}	|	sdtjj|	�rhdS|tjjj	kr�tjjj	||	|�}
nt
jd|�dS|
ds�t
jd|
d�dS|s�|j||d|�}t
}ntjj|�}tjj|�sQ|r3tj|�qQtjjj|
d�dSntj|
d|�|S(	u<
        Cache a file then process it as a template
        uenvusaltenvROuu7Attempted to render template with unavailable engine %suresultu(Failed to render template with error: %sudata(tpopRR[R7R2R�R#R%t	templatestTEMPLATE_REGISTRYRgterrorR�R<R9R8RKRDtsafe_rmRstmove(R)R0R?ttemplateRKR4RORuR�tsfnReR@((s3/usr/lib/python2.7/site-packages/salt/fileclient.pytget_template�s:

	cC@st|�}tjjj�r9tjjj|j�}n	|j}|jd�d}|dkrq|j
d}n1tjj|�s�tjj
|j
d|�}n|jr�dj
|j|jg�}n	|j}t|�tkr�tjjj|�}ntjjj
|d|||�S(u;
        Return the extrn_filepath for a given url
        u@i����ucachediru-uextrn_filesN(RR#R%R�R�R2R�R�R]RRRR7RSR=R�R�tMAX_FILENAME_LENGTHR�t
sha256_digest(R)R0R4ROR�R�t	file_name((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyR�s(			( t__name__t
__module__t__doc__R*R,R-R5RFt
contextlibtcontextmanagerRRRQRGR�RVRXR[RaRdRqRvR}RbR~RR�R�R�R�RZR�R�(((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyR"VsL	
						2			:� -RcB@s�eZdZdd�Zdedddd�Zddd�Zddd�Zddd�Z	dd�Z
dd	�Zdd
�Zdd�Z
d�Zd
�Zd�ZRS(u6
    Used by pillar to handle fileclient requests
    ubasecC@s�idd6dd6}tjjj|�rAtjjj|�}nx`|jdj|g�D]E}tjj	||�}tjj
|�r[||d<||d<|Sq[W|S(u&
        Locate the file path
        uupathurelupillar_roots(R#R%R0R�tunescapeRRR7R2R=RI(R)R2R4tfndRBtfull((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyt
_find_file)s

 

uc	C@s>|j|�}|j||�}|jd�}|s:dS|S(u�
        Copies a file from the local files directory into :param:`dest`
        gzip compression settings are ignored for local files
        upathu(R5RR(	R)R2R?RKR4RURORtfnd_path((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyRV;scC@s�g}|jd�}x�|jdj|g�D]�}x�tjjjtjj||�dt	�D]�\}}}g|D]$}tj
j|j|�sv|^qv|(xN|D]F}	tjjtjj||	�|�}
|j
tjjj|
��q�Wq`Wq/W|S(u�
        Return a list of files in the given environment
        with optional relative prefix path to limit directory traversal
        u/upillar_rootsR6(RiRRR#R%R2R;R7R=R<t
fileservertis_file_ignoredtrelpathR^ReR(R)R4RWR`R2RBRCRDtdtfnameR
((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyRbNs +2
$(c	C@s�g}|jd�}x�|jdj|g�D]�}x�tjjjtjj||�dt	�D]}\}}}g|D]$}tj
j|j|�sv|^qv|(|r`|r`|jtjj
jtjj||���q`q`Wq/W|S(u�
        List the empty dirs in the pillar_roots
        with optional relative prefix path to limit directory traversal
        u/upillar_rootsR6(RiRRR#R%R2R;R7R=R<RR	R^ReRR
(	R)R4RWR`R2RBRCRDR((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyRX`s +26cC@s�g}|jd�}x�|jdj|g�D]o}xftjjjtjj||�dt	�D]:\}}}|j
tjjjtjj
||���q`Wq/W|S(u{
        List the dirs in the pillar_roots
        with optional relative prefix path to limit directory traversal
        u/upillar_rootsR6(RiRRR#R%R2R;R7R=R<R^ReRR
(R)R4RWR`R2RBRCRD((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyR~qs +3cC@sfy|j|�}Wn@tk
rU}tjj|�sNtjd||�dS|SnX|j||�S(uU
        Return either a file path or the result of a remote find_file call.
        u5specified file %s is not present to generate hash: %sN(	R5RR7R2RIRgtwarningRRR(R)R2R4terr((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyt__get_file_paths
cC@s�i}|j||�}|dkr(|Sy|d}Wntk
rO|}nX|jjdd�}tjjj|d|�|d<||d<|S(u�
        Return the hash of a file, to get the hash of a file in the pillar_roots
        prepend the path with salt://<file on server> otherwise, prepend the
        file with / for a local file.
        upathu	hash_typeumd5R�uhsumN(	t_PillarClient__get_file_pathRRR�RRR#R%R�R�(R)R2R4R`RRt	hash_type((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyt	hash_file�s


cC@s�i}|j||�}|dkr.|dfSy|d}|jd�}WnJtk
r�|}yttj|��}Wq�tk
r�d}q�XnX|jjdd�}t	j
jj|d|�|d<||d<||fS(u7
        Return the hash of a file, to get the hash of a file in the pillar_roots
        prepend the path with salt://<file on server> otherwise, prepend the
        file with / for a local file.

        Additionally, return the stat result of the file, or None if no stat
        results were found.
        upathustatu	hash_typeumd5R�uhsumN(
RRRRR�tlistR7tstatR�RR#R%R�R�(R)R2R4R`RRtfnd_statR((s3/usr/lib/python2.7/site-packages/salt/fileclient.pythash_and_stat_file�s"	




cC@s
|j|�S(uW
        Return a list of the files in the file server's specified environment
        (Rb(R)R4((s3/usr/lib/python2.7/site-packages/salt/fileclient.pytlist_env�scC@s|jS(u-
        Return the master opts data
        (R(R)((s3/usr/lib/python2.7/site-packages/salt/fileclient.pytmaster_opts�scC@s/g}x"|jdD]}|j|�qW|S(u3
        Return the available environments
        upillar_roots(RR^(R)R`R4((s3/usr/lib/python2.7/site-packages/salt/fileclient.pytenvs�scC@siS(uX
        Originally returned information via the external_nodes subsystem.
        External_nodes was deprecated and removed in
        2014.1.6 in favor of master_tops (which had been around since pre-0.17).
             salt-call --local state.show_top
        ends up here, but master_tops has not been extended to support
        show_top in a completely local environment yet.  It's worth noting
        that originally this fn started with
            if 'external_nodes' not in opts: return {}
        So since external_nodes is gone now, we are just returning the
        empty dict.
        ((R)((s3/usr/lib/python2.7/site-packages/salt/fileclient.pytmaster_tops�s
N(R�R�RRR�RRRVRbRXR~RRRRRRR(((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyR%s"
			RcB@s�eZdZd�Zd�Zd�Zd�Zdedddd�Z	ddd�Z
ddd	�Zddd
�Zddd�Z
dd�Zdd
�Zdd�Zdd�Zd�Zd�Zd�ZRS(u4
    Interact with the salt master file server.
    cC@shtj||�t|_tjjjj|j	�|_
t|j
d�r[|j
j|_n	d|_dS(Nuauthu(
R"R*R�t_closingR#t	transportRt
ReqChanneltfactoryRtchannelthasattrtauth(R)R((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyR*�s	cC@s%tjjjj|j�|_|jS(uD
        Reset the channel, in the event of an interruption
        (R#RRRRRR(R)((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyt_refresh_channel�scC@s|j�dS(N(tdestroy(R)((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyt__del__scC@sZ|jr
dSt|_d}y
|j}Wntk
r<nX|dk	rV|j�ndS(N(RR<RRRR�R�(R)R((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyR#s		

uubasecC@s}tjjj|�\}}|r*|}ntjjj�s�|j||�\}}	y|	d}
Wq�ttfk
r�d	}
q�Xn|j
||�}d	}
|dkr�tjd||�t
S|d	k	r3tjj|�s�|jd!�r3tjj|tjj|��}tjd|tjj|�|�n|}|s�|j|�}tjd|||�|j||d|��
}
|
}Wd	QXntjd
|||�|rBtjj|�rBtjjj�s|j||�\}}y|d}Wq/ttfk
rd	}q/Xn|j
||�}d	}||krB|Sntjd||�d}d}|j|�}i|d6|d
6dd6}|r�t|�}||d<nd	}|rDtjj|�}tjj|�s)|r"ytj|�Wq&tk
r}|jtjkr�qq&Xq)t
Sntjjj|d�}n
tjd�x�tr?|smd|d<n|j �|d<|j!j"|dt�}t#j$r�t%|�}ny�|ds�|r+|dr+|j|d|d|��?}
|
}tjjj|
d��}|j&|d�Wd	QXWd	QXnd|kr�|dkr�|d7}tjj'j(|tjj)j*|j+dd���}||dkr�tj,d||�wTq�nPn|s$|j|d|d|��M}
|
}tjj|�rtjjj-|�ntjj.j/|d�}Wd	QXn|j+dd	�rRtjj0j1|d�}n
|d}t#j$r�t2|t3�r�|j4�}n|j&|�WqTtt5fk
r;}yt6|�j7}Wn&t8k
r�t#j9t6|��}nX|d7}tj,d||||�|j:�|dkr<tj;d|||�Pq<qTXqTW|rf|j<�tj=d||�ntjd ||�|S("u�
        Get a single file from the salt-master
        path must be a salt server location, aka, salt://path/to/file, if
        dest is omitted, then the downloaded file will be placed in the minion
        cache
        iuu(Could not find file '%s' in saltenv '%s'u/u\u;In saltenv '%s', '%s' is a directory. Changing dest to '%s'u9In saltenv '%s', looking at rel_path '%s' to resolve '%s'RONu<In saltenv '%s', ** considering ** path '%s' to resolve '%s'u6Fetching file from saltenv '%s', ** attempting ** '%s'upathusaltenvu_serve_fileucmdugzipuwb+uNo dest file founduloctrawudataudestuhsumiiu	hash_typetmd5u(Bad download of file %s, attempt %d of 3uKData transport is broken, got: %s, type: %s, exception: %s, attempt %d of 3uTData transport is broken, got: %s, type: %s, exception: %s, retry attempts exhaustedu0Fetching file from saltenv '%s', ** done ** '%s'u3In saltenv '%s', we are ** missing ** the file '%s'(u/u\(>R#R%R0t	split_envR�R�RR�R�RRRRgR�R�R7R2R8RfR=tbasenameR9R5RQRItintRKRLRMRNRDR�R<ttellRtsendR	RR!R�R�R�Rjtto_strRR
trm_rft
atomicfiletatomic_opent	gzip_utilt
uncompressRtstrtencodeR�ttypeR�R�t	text_typeR"R�R�Rh(R)R2R?RKR4RUROR�thash_servertstat_servertmode_servert
dest2checktrel_patht
cache_destt
hash_localt
stat_localt
mode_localtd_triesttransport_triestloadRoR@RPRetofilethsumt	data_type((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyRVs
	

!!








	
	
 
3
	!







cC@sSi|d6|d6dd6}tjrCtjjj|jj|��S|jj|�S(u.
        List the files on the master
        usaltenvuprefixu
_file_listucmd(R	tPY2R#R%ReRRR+(R)R4RWRA((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyRb�s


(cC@sSi|d6|d6dd6}tjrCtjjj|jj|��S|jj|�S(u3
        List the empty dirs on the master
        usaltenvuprefixu_file_list_emptydirsucmd(R	RER#R%ReRRR+(R)R4RWRA((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyRX�s


(cC@sSi|d6|d6dd6}tjrCtjjj|jj|��S|jj|�S(u-
        List the dirs on the master
        usaltenvuprefixu	_dir_listucmd(R	RER#R%ReRRR+(R)R4RWRA((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyR~�s


(cC@sSi|d6|d6dd6}tjrCtjjj|jj|��S|jj|�S(u=
        List symlinked files and dirs on the master
        usaltenvuprefixu
_symlink_listucmd(R	RER#R%ReRRR+(R)R4RWRA((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyR�s


(cC@s�y|j|�}Wn�tk
r�}tjj|�sTtjd||�id
fSi}|jj	dd�}t
jjj
|d|�|d<||d<|SnXi|d6|d6dd	6}|jj|�S(u;
        Common code for hashing and stating files
        u5specified file %s is not present to generate hash: %su	hash_typeumd5R�uhsumupathusaltenvu
_file_hashucmdN(R5RR7R2RIRgR
RRRRR#R%R�R�RR+(R)R2R4RR`RRA((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyt__hash_and_stat_files"




cC@s|j||�S(u�
        Return the hash of a file, to get the hash of a file on the salt
        master file server prepend the path with salt://<file on server>
        otherwise, prepend the file with / for a local file.
        (t!_RemoteClient__hash_and_stat_file(R)R2R4((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyRscC@s�|j||�}y|j|�}Wngtk
r�}tjj|�sS|dfSy|ttj|��fSWq�t	k
r�|dfSXnXi|d6|d6dd6}|j
j|�}y|jd�}Wnt
k
r�d}nX||fS(uu
        The same as hash_file, but also return the file's mode, or None if no
        mode data is present.
        upathusaltenvu
_file_finducmdustatN(RR5RR7R2RIRRRRR�RR+RR�(R)R2R4thash_resultRRARtstat_result((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyR s&





cC@sLi|d6dd6}tjr<tjjj|jj|��S|jj|�S(uW
        Return a list of the files in the file server's specified environment
        usaltenvu
_file_listucmd(R	RER#R%ReRRR+(R)R4RA((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyR:s

(cC@sEidd6}tjr5tjjj|jj|��S|jj|�S(u9
        Return a list of available environments
        u
_file_envsucmd(R	RER#R%ReRRR+(R)RA((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyRCs
(cC@sEidd6}tjr5tjjj|jj|��S|jj|�S(u-
        Return the master opts data
        u_master_optsucmd(R	RER#R%ReRRR+(R)RA((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyRKs
(cC@s�tjd�idd6|jdd6|jd6}|jrT|jjd�|d<ntjr|tjj	j
|jj|��S|jj|�S(uI
        Return the metadata derived from the master_tops system
        u�The _ext_nodes master function has been renamed to _master_tops. To ensure compatibility when using older Salt masters we will continue to invoke the function as _ext_nodes until the Magnesium release.u
_ext_nodesucmduiduoptsR#utok(
RgR�RR!t	gen_tokenR	RER#R%ReRRR+(R)RA((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyRSs

	(N(R�R�RR*R"R$R#R�RRRVRbRXR~RRGRRRRRR(((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyR�s*					�



			RcB@seZdZd�ZRS(ui
    A local client that uses the RemoteClient but substitutes the channel for
    the FSChan object
    cC@s>tj||�t|_tjj|�|_t�|_	dS(N(
R"R*R�RR#RtFSChanRtDumbAuthR!(R)R((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyR*ms	(R�R�RR*(((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyRhsRLcB@seZdZd�ZRS(ua
    The dumbauth class is used to stub out auth calls fired from the FSClient
    subsystem
    cC@s|S(N((R)t	clear_tok((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyRJ~s(R�R�RRJ(((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyRLys(ARt
__future__RRRRRMtloggingR7R�RsR�ttornado.httputilRRRtsalt.utils.atomicfileR#tsalt.exceptionsRRtsalt.clienttsalt.loadertsalt.payloadtsalt.transport.clienttsalt.fileservertsalt.utils.datatsalt.utils.filestsalt.utils.gzip_utiltsalt.utils.hashutilstsalt.utils.httptsalt.utils.pathtsalt.utils.platformtsalt.utils.stringutilstsalt.utils.templatestsalt.utils.urltsalt.utils.versionstsalt.utils.openstack.swiftRtsalt.extR	t!salt.ext.six.moves.BaseHTTPServertexttmovesR�tsalt.ext.six.moves.urllib.errorR
Rtsalt.ext.six.moves.urllib.parseRR
t	getLoggerR�RgR�R�RR!tobjectR"RRRtLocalClientRL(((s3/usr/lib/python2.7/site-packages/salt/fileclient.pyt<module>sZ	�����}

Zerion Mini Shell 1.0