%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddl
ZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Zddl!Zddl"Zddl#Zddl!Zddl$Zddl%Zddl&Zddl'Zddl Zddl(Zddl)m*Z*ddlm+Z+ddl,m-Z-yddl.Z.e/Z0Wne1k
r=e2Z0nXej3e4�Z5d�Z6d�Z7d	�Z8d
�Z9d�Z:d�Z;d
�Z<d�Z=de>fd��YZ?de>fd��YZ@de>fd��YZAdS(u�
This module contains all of the routines needed to set up a master server, this
involves preparing the three listeners and the workers needed by the master.
i(tabsolute_importtprint_functiontunicode_literalsN(tDEFAULT_TARGET_DELIM(t
git_pillar(tsixc
C@s�g}x�g|jdg�D]}|^qD]�}d|kr,yHtjjj||ddtjdtjdtj�}|j	|�Wq�tj
jk
r�|jdt�r��q�t
jd�q�Xq,q,W|S(uF
    Clear out the ext pillar caches, used when the master starts
    u
ext_pillarugittper_remote_overridestper_remote_onlytglobal_onlyugit_pillar_verify_configuCould not initialize git_pillar(tgettsalttutilstgitfst	GitPillarRtPER_REMOTE_OVERRIDEStPER_REMOTE_ONLYtGLOBAL_ONLYtappendt
exceptionstFileserverConfigErrortTruetlogtcritical(toptstrettxt	opts_dicttpillar((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pytinit_git_pillarCs ,
		cC@sgx`dD]X}||dkrtjj|ddj|�d�}tjj|�r�tjd|�ytj|�Wq�tk
r�}tj	d	||�q�Xntjj|dd
dj|��}ytj
|�}Wntk
r�qnXxltj|d�D]U}tjj||�}ytj|�Wqtk
rW}tj	d||�qXqWqqWd
S(u/
    Clean out the old fileserver backends
    ugituhgusvnufileserver_backenducachediru{0}fsuenvs.puClearing %sfs env cacheu%Unable to clear env cache file %s: %su
file_listsu*.pu&Unable to file_lists cache file %s: %sN(ugituhgusvn(
tostpathtjointformattisfileRtdebugtremovetOSErrorRtlistdirtfnmatchtfilter(Rtbackendt	env_cachetexctfile_lists_dirtfile_lists_cachestfile_lists_cachet
cache_file((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pytclean_fsbackendZs<
			
cC@svtjj|�}x]|j�D]O}|j|�}d|ks^|jdd�tj�kr|j|�qqWdS(u.
    Clean expired tokens from the master
    uexpireiN(R
tauthtLoadAuthtlist_tokenstget_tokR	ttimetrm_token(Rtloadauthttokt
token_data((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pytclean_expired_tokens�s
*cC@s�y�tjj|dd�}tjj|�s2dSx�tjjj|�D]�\}}}xu|D]m}tjj||�}tjj|�s�q^ntj�tjj	|�|ddkr^tj
|�q^q^WqHWWn$ttfk
r�t
jd�nXdS(Nucachedirupublish_authu	keep_jobsiuUnable to delete pub auth file(RRRtexistsR
Rtos_walkR!R4tgetmtimeR#tIOErrorR$Rterror(Rt
auth_cachetdirpathtdirnamest	filenamest	auth_filetauth_file_path((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pytclean_pub_auth�s%
cC@sUtjj|dtdt�}dj|d�}||jkrQ|j|�ndS(u3
    Clean out the old jobs from the job cache
    tstatestrendu{0}.clean_old_jobsumaster_job_cacheN(R
tminiontMasterMiniontFalseR t	returners(Rtmminiontfstr((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pytclean_old_jobs�s		cC@s�trGd}ytj|�j}WqGtk
rC|drDdSqGXntjjj	�r�t
jj|ddj
|jdd���}n"t
jj|ddj
|��}t
jj|�r#tjd|�tjjj	�rt
j|t
j�rt
j|tjtjB�nt
j|�ntjjj�}tjjjd��Btjjj|d��#}|jtjj j!|��WdQXWdQXt
j|d	�tr�|dk	r�yt
j"||d
�Wq�t#k
r�q�Xn|S(Nuclient_acl_verifyucachediru.{0}_keyu\u_uRemoving stale keyfile: %si�uw+i�i����($tHAS_PWDtNonetpwdtgetpwnamtpw_uidtKeyErrorR
Rtplatformt
is_windowsRRRR treplaceR:RR"taccesstW_OKtchmodtstattS_IRUSRtS_IWUSRtunlinktcryptt	Crypticletgenerate_key_stringtfilest	set_umasktfopentwritetstringutilstto_strtchownR$(Rtusertuidtkeyfiletkeytfp_((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pytmk_key�s8

	(	((
cC@s5i}|d}t|j��}|jd�rE|j|d�n|jtjjj��xF|D]>}tj	d|�t
||�}|dk	re|||<qeqeW|dr1tr1tj
d�xZtj�D]L}|j}||kr�tjjj|d|�r�t
||�||<q�q�Wtj
d�n|S(	uv
    A key needs to be placed in the filesystem with permissions 0400 so
    clients are required to run as root.
    u
publisher_acluuseru,Preparing the %s key for local communicationuclient_acl_verifyu?Beginning pwd.getpwall() call in masterapi access_keys functiont	whitelistu9End pwd.getpwall() call in masterapi access_keys functionN(tsettkeysR	taddR
RRitget_userRtinfoRnRPROtprofileRQtgetpwalltpw_nameRftcheck_whitelist_blacklist(RRqt
publisher_aclt	acl_usersRiRl((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pytaccess_keys�s&


	'cC@sly9|js.tjd�tjjd��n|j�Wn,tk
rg}tjd|dtj	�nXdS(ul
    Update the fileserver backends, requires that a salt.fileserver.Fileserver
    object be passed in
    uLNo fileservers loaded, the master will not be able to serve files to minionsu No fileserver backends availableu+Exception %s occurred in file server updatetexc_info_on_loglevelN(
tserversRR>R
RtSaltMasterErrortupdatet	ExceptiontloggingtDEBUG(t
fileserverR*((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pytfileserver_update�s		tAutoKeycB@sPeZdZd�Zd�Zd�Zd�Zd�Zd�Zdd�Z
RS(	uH
    Implement the methods to run auto key acceptance and rejection
    cC@si|_||_dS(N(t
signing_filesR(tselfR((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pyt__init__s	cC@s�tjjj�rtStjjj|jddt�}t	j
|�}t
j|j@r[tSt
j
|j@r�|jjdt�s�tSt	j�dkr�|j|kr�tSntS(uI
        Check if the specified filename has correct permissions
        uusertinclude_defaultupermissive_pki_accessi(R
RRURVRRitget_gid_listRRJRR[tS_IWOTHtst_modetS_IWGRPR	tgetuidtst_gid(R�tfilenametgroupstfmode((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pytcheck_permissionss"!c	@s3|stjj|�rtS|j|�sAtjd|�tStjj|�}|jj	|i�j	d�|kr||jj
|i�d<tjj
j|d��Y}gg|D]}|j�^q�D]!}|j�jd�s�|^q�|j|d<WdQXnt�fd�|j|j	dg�D��S(u@
        Check a keyid for membership in a signing file
        u*Wrong permissions for %s, ignoring contentumtimeuru#udataNc3@s'|]}tjjj�|�VqdS(N(R
RRft
expr_match(t.0tline(tkeyid(s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pys	<genexpr>Es(RRR:RJR�RtwarningR<R�R	t
setdefaultR
RRbRdtstript
startswithtany(R�R�tsigning_filetmtimeRmR�tentry((R�s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pytcheck_signing_file3s$[cC@s#tjj|jdd�}|jjdd�}|dkr�tj�dt|�}x�tjjj	|�D]s\}}}xa|D]Y}tjj||�}	tjj
|	�}
|
|kr�tjd|	�tj
|	�q�q�WqmWntjj||�}	tjj|	�stStj
|	�tS(uG
        Check a keyid for membership in a autosign directory.
        upki_diruminions_autosignuautosign_timeoutixii<uAutosign keyid expired %s(RRRRR	R4tintR
RR;R<RR�R#R:RJR(R�R�tautosign_dirtexpire_minutestmin_timetroottdirsRBtft	stub_fileR�((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pytcheck_autosign_dirHs %

c

C@s|sd|jkrtS|jd}x�tj|�D]�\}}}x�|D]�}||krMtjj||�}|j|�s�tjd|�qMnt	j
jj|d��\}xR|D]J}	t	j
j
j|	�j�}	|	jd�r�q�n|||	kr�tSq�WWdQXqMqMWq7WtS(uG
        Check for matching grains in the autosign_grains_dir.
        uautosign_grains_diru*Wrong permissions for %s, ignoring contenturu#N(RRJRtwalkRRR�RR�R
RRbRdRft
to_unicodeR�R�R(
R�tautosign_grainstautosign_grains_dirR�R�RBtgraint
grain_fileR�R�((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pytcheck_autosign_grains`s(


cC@s|j||jjdd��S(uQ
        Checks if the specified keyid should automatically be rejected.
        uautoreject_fileN(R�RR	RP(R�R�((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pytcheck_autoreject}scC@s`|jdrtS|j||jjdd��r6tS|j|�rItS|j|�r\tStS(uO
        Checks if the specified keyid should automatically be signed.
        uauto_acceptu
autosign_fileN(RRR�R	RPR�R�RJ(R�R�R�((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pytcheck_autosign�s
!N(t__name__t
__module__t__doc__R�R�R�R�R�R�RPR�(((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pyR�s							tRemoteFuncscB@s�eZdZd�Zd�Zd�Zd�Zed�Zed�Z	ed�Z
d�Zed	�Zd
�Z
d�Zd�Zd
�Zd�Zd�Zed�Zd�Zd�Zd�ZRS(u�
    Funcitons made available to minions, this class includes the raw routines
    post validation that make up the minion access to the master
    cC@s�||_tjjjd|jd|jdd|jdt�|_tjj|�|_tjj	j
|�|_tjj
|j�|_
tjjd|j�|_tjj|jdtdt�|_|j�tjj|�|_dS(	Numasterusock_diru	transportRtlistentmoptsRFRG(RR
Rteventt	get_eventRJtpayloadtSerialtserialtminionst	CkMinionst	ckminionstloaderttopstclienttget_local_clienttlocalRHRIRLt_RemoteFuncs__setup_fileservertcachetfactory(R�R((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pyR��s"	

			
cC@sytjj|j�}|j|_|j|_|j|_	|j
|_|j|_
|j|_|j|_|j|_dS(uK
        Set the local file objects from the file server interface
        N(R
R�t
FileserverRt
serve_filet_serve_filet
_find_filet
_file_findt	file_hasht
_file_hasht	file_listt
_file_listtfile_list_emptydirst_file_list_emptydirstdir_listt	_dir_listtsymlink_listt
_symlink_listtenvst
_file_envs(R�tfs_((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pyt__setup_fileserver�sc@sod|jkrtSt|jdt�s-tSt�fd�d
D��rMtStjd�d�rgtSg}xc|jdD]T}tj|�d�r{t|jd|t�r�|j|jd|�q�q{q{Wd	�dkr5�dj	d	��d<g}x%�dD]}|j
|j	��qW|�d<n|jj|�d�d�d�j
d
d�dt�S(uS
        Verify that the passed information authorized a minion to execute
        upeerc3@s|]}|�kVqdS(N((R�Rl(tload(s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pys	<genexpr>�sufunuargutgturetuidu	publish.*u,utgt_typeuglobtpublish_validate(ufunuargutgturetuid(RRJt
isinstancetdictR�tretmatchtlisttextendtsplitRR�t
auth_checkR	R(R�R�tpermsR�targ_targ((R�s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pyt__verify_minion_publish�s4"
	cC@sbi}i}|j�}x'|D]}||krg||<qqW||d<|jd|d<|jd|d<|jd|d<|jd�r�|S|jd|d<|jd|d<|jd|d<|jd	|d	<|jd
|d
<|jd|d<|jd|d<|jd
|d
<|jd|d<|jd|d<|jd|d<|jd|d<|S(u9
        Return the master options to the minion
        u
file_rootsutop_file_merging_strategyu	env_orderudefault_topuenv_onlyurendererufailhardu	state_topustate_top_saltenvu
nodegroupsustate_auto_orderustate_eventsustate_aggregateu	jinja_envu
jinja_sls_envujinja_lstrip_blocksujinja_trim_blocks(R�RR	(R�R�R�t
file_rootsR�tsaltenv((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pyt_master_opts�s2

cC@s6|sId|kr#tjd�iStjjj|j|d�sIiSni}i}i}d|kr�|d}d|dkr�|dd}q�nx�|jD]�}||jjdi�kr�q�ny8tjj	j
||j|d|d|�dt�}Wq�tk
r-}tjd	|||d�q�Xq�W|S(
uC
        Return the results from master_tops if configured
        uidu.Received call for external nodes without an iduoptsugrainsumaster_topsRtgrainstmerge_listsu2Top function %s failed with error %s for minion %s(
RR>R
Rtverifytvalid_idRR�R	t
dictupdatetmergeRR�(R�R�tskip_verifyRR�RtfunR*((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pyt_master_topss.

8c
@sQ|s)t�fd�dD��r)iSnd|jkr�t|jdt�sRiSt�}xc|jdD]T}tj|�d�rit|jd|t�r�|j|jd|�q�qiqiWt�fd�|D��s�iSni}t	j
jj|j�d�s
|S�j
d�}|dk	r`d�kr`t	j
jjd	d
j�d��|}n�j
dd�}|j�dkr�d
}n|j�dkr�d}nt	j
jj|j�}|j�d|dt�}	|	d}
xd|
D]\}|jjdj|�d�}t|t�r�|j
�d�}|rI|||<qIq�q�W|S(uC
        Gathers the data from the specified minions' mine
        c3@s|]}|�kVqdS(N((R�Rl(R�(s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pys	<genexpr>&suidutgtufunumine_getc3@s%|]}tj|�d�VqdS(ufunN(R�R�(R�tperm(R�(s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pys	<genexpr>1su	expr_formutgt_typeuNeonu�_mine_get: minion {0} uses pre-Nitrogen API key "expr_form". Accepting for backwards compatibility but this is not guaranteed after the Neon releaseuglobupillarupillar_exactucompounducompound_pillar_exacttgreedyuminionsuminions/{0}umine(uidutgtufunN(R�RR�R�RpR�R�R�RR
RR�R�R	RPtversionst
warn_untilR tlowerR�R�t
check_minionsRJR�tfetch(
R�R�R�R�R�Rt	expr_formt
match_typetcheckert_resR�RHtfdata((R�s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pyt	_mine_get!sR	"				

cC@s�|s%d|ksd|kr%tSn|jjdt�sO|jjdt�r�dj|d�}d}|jdt�s�|jj||�}t|t�r�|j|d�||d<q�n|jj	|||d�nt
S(u&
        Return the mine data
        uidudatauminion_data_cacheuenforce_mine_cacheuminions/{0}umineuclear(RJRR	R R�R�R�R�RtstoreR(R�R�R�tcbanktckeytdata((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pyt_mineUs*cC@s�d|ksd|krtS|jjdt�sF|jjdt�r�dj|d�}d}y`|jj||�}t|t�s�tS|d|kr�||d=|jj|||�nWq�t	k
r�tSXnt
S(uR
        Allow the minion to delete a specific function from its own mine
        uidufunuminion_data_cacheuenforce_mine_cacheuminions/{0}umine(RJRR	R R�R�R�R�RR$R(R�R�RRR((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pyt_mine_deletegs*
cC@se|rd|krtS|jjdt�sA|jjdt�ra|jjdj|d�d�StS(uI
        Allow the minion to delete all of its own mine contents
        uiduminion_data_cacheuenforce_mine_cacheuminions/{0}umine(RJRR	R�tflushR R(R�R�R�((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pyt_mine_flush{s
* c@s�t�fd�dD��r tS|jdsDtjj�d�rHtStjj�d�snd�dkrrtStjjj	|j�d�s�tSd|jd}d�kr��dd	kr�t
jd
�tS�jdd	�|kr�t
jd|�tSt
�d
��jdd	�|kr9t
jd|�tS�d}d|krv|jdd�}tjj|�}ntjj|jdd�dd|�}tjj|�}tjj|�s�ytj|�Wq�tjk
r�q�Xntjj|�r�dd	krd}nd}tjjj||��E}�drX|j�d�n|jtjjj�d
��WdQXtS(um
        Allows minions to send files to the master, files are sent to the
        master file cache
        c3@s|]}|�kVqdS(N((R�Rl(R�(s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pys	<genexpr>�suidupathulocu	file_recvu../iufile_recv_max_sizeiu#Invalid file pointer: load[loc] < 0usizeu&Exceeding file_recv_max_size limit: %sudatau:u\u/ucachediruminionsufilesuabuwbN(uidupathuloci(R�RJRRRtisabsR
RR�R�RR>R	tlenRWtnormpathRtdirnametisdirtmakedirsR!RbRdtseekReRfRgR(R�R�tfile_recv_max_sizeR
tcpathtcdirtmodeRm((R�s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pyt
_file_recv�s\$&
&
	
	"	
&c@sFt�fd�dD��r tStjd�jd��tjj|j�d�d�jd�jd���jd�|j	j
d�jd	i��}|j�}|jjd
t�rB|jj
dj�d�di�dd6|d
6�|jjd�tkrB|jjidd6tjjj�ddd��qBn|S(u7
        Return the pillar data for the minion
        c3@s|]}|�kVqdS(N((R�Rl(R�(s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pys	<genexpr>�suidugrainsuMaster _pillar using ext: %suextusaltenvuenvtpillar_overrideupillar_overrideuminion_data_cacheuminions/{0}udataupillaruminion_data_cache_eventsuMinion data cache refreshucommenturefreshuminion(uidugrains(R�RJRR"R	R
Rt
get_pillarRRLt	functionstcompile_pillarR�RR RR�t
fire_eventRttagify(R�R�RR((R�s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pyt_pillar�s&	9c
C@s�d|krtSd|kr8d|ks4d|kr8tSd|kr�x�|dD]�}d|krn|d}n|}|jj||d�|jd�dk	rO|jj|tjjj|dd|d��qOqOWn|d}|jj||�tS(ud
        Receive an event from the minion and fire it on the master event
        interface
        uidueventsutagudataupretagtbaseN(	RJR�RR	RPR
RRR(R�R�R�t
event_datattag((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pyt
_minion_event�s$
:
c@s�tjjjtjjj|j��}t�fd�dD��rGtS�ddkr�dj|jd�}|j	j
|d�jd	t���d<d
j|jd�}|j	j
|�d��ntj
d�d�d�|jj��d�|jj�tjjj�dd�dgd
��|jj��|jdsb|jjd�rfdSdj|jd�}|jjd�r�||j	j
kr�|j	j
|�d|�ndj|jd�}|j	j
|��dS(u>
        Handle the return data sent from the minions
        c3@s|]}|�kVqdS(N((R�Rl(R�(s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pys	<genexpr>�sureturnujiduidurequ{0}.prep_jidumaster_job_cachetnocacheunocacheu
{0}.save_loaduGot return from %s for job %suretujobu	job_cacheu
ext_job_cacheNu{0}.update_endtimeujob_cache_store_endtimeu{0}.returner(ureturnujiduid(R
Rtjidtjid_to_timetgen_jidRR�RJR RLRKR	RRtR�RRt
fire_ret_load(R�R�tendtimet	prep_fstrt
saveload_fstrRM((R�s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pyt_return�s(')6 c@s�t�fd�d
D��r d	Sd�krddj|jd�}|jj|�d�d�nxjtj�d�D]U\}}i�dd6|d6|d6}d�kr��d|d<n|j|�qxWd	S(ut
        Receive a syndic minion return and format it to look like returns from
        individual minions.
        c3@s|]}|�kVqdS(N((R�Rl(R�(s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pys	<genexpr>sureturnujiduiduloadu
{0}.save_loadumaster_job_cacheuoutN(ureturnujiduid(	R�RPR RRLRKRt	iteritemsR*(R�R�RMRltitemR((R�s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pyt_syndic_returns" 
c@s�d|jkriSt|jdt�s-iSt�fd�dD��rMiSt�}xc|jdD]T}tj|�d�rdt|jd|t�r�|j|jd|�q�qdqdWt	}x-|D]%}tj|�d�r�t
}q�q�W|stjd�d�iSi}|j|j�|ji�dd6t
jjj�dd�jdg��d6�dd6t	d	6|jd
d
6�t
jj|�}|j�S(uS
        Execute a runner from a minion, return the runner's function data
        upeer_runc3@s|]}|�kVqdS(N((R�Rl(R�(s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pys	<genexpr>1sufunuarguidu&Minion id %s is not who it says it is!tno_parseuno_parseudocu	conf_file(ufunuarguid(RR�R�R�RpR�R�R�RRJRRR�R
Rtargstparse_inputR	trunnertRunnertrun(R�R�R�R�tgoodR�RR1((R�s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pyt
minion_runner)s:	"


c@s�|r't�fd�dD��r'iStjj|jdd�}tjj|�setj|�ntjj|�d�}tjj	j
|d��0}�dtjjj|j
��ks�iSWdQX|jj�d�SdS(	u�
        Request the return data from a specific jid, only allowed
        if the requesting minion also initialted the execution.
        c3@s|]}|�kVqdS(N((R�Rl(R�(s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pys	<genexpr>Tsujiduiducachedirupublish_authurN(ujiduid(R�RRRRRRR
RRbRdRfR�treadR�tget_cache_returns(R�R�R�R?tjid_fnRm((R�s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pytpub_retOs#	
	%
cC@s�|j|�siSi|dd6tjjj|dd|jdg��d6|jdd�d6|dd6|dd6|d	d	6}d|kr�|djd
�r�|d|jdkr�|jd|d|d<d|d<q�iSq�|d|d<ni}|jj	|�|d
<|j
j|d|d�}|d|d<tj
j|jdd�}tj
j|�s}tj|�ntj
j|tj|d
��}tjjj|d��'}|jtjjj|d	��WdQX|S(u�
        Publish a command initiated from a minion, this method executes minion
        restrictions so that the minion publication will only work if it is
        enabled in the config.
        The configuration on the master allows minions to be matched to
        salt functions, so the minions can only publish allowed salt functions
        The config will look like this:
        peer:
            .*:
                - .*
        This configuration will enable all minions to execute all commands.
        peer:
            foo.example.com:
                - test.*
        This configuration will only allow the minion foo.example.com to
        execute commands from the test module
        ufunuargR.uno_parseutgt_typeuglobutgturetuidunodeu
nodegroupsucompoundujiduminionsucachedirupublish_authuw+N(t#_RemoteFuncs__verify_minion_publishR
RR/R0R	R�RR�t	cmd_asyncR�R�RRRRRRt	text_typeRbRdReRfRg(R�R�tpub_loadRRR?R8Rm((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pyt
minion_pubcsB

	
	
	"&c	C@s�|j|�siSi|dd6tjjj|dd|jdg��d6|jdd�d6|dd6|dd6|d	d	6}d
|kr�yt|d
�|d<Wq�tk
r�dj|d
�}t	j
|�iSXnd|kr<yt|d�|d<Wq<tk
r8dj|d�}t	j
|�iSXnd|kr�|djd
�r�|d|jdkr�|jd|d|d<d|d<q�iSq�|d|d<nt
|d<i}x�|jj|�D]�}|jdd�dkr8|}d|kr|d|d<n|jd�|d<|||d	<q�|d||d	<d|kr�|d|d<q�q�WxFtj|jj|d��D]%\}}||kr�|||<q�q�W|jdd�dkr�|jd�n|S(u�
        Publish a command initiated from a minion, this method executes minion
        restrictions so that the minion publication will only work if it is
        enabled in the config.
        The configuration on the master allows minions to be matched to
        salt functions, so the minions can only publish allowed salt functions
        The config will look like this:
        peer:
            .*:
                - .*
        This configuration will enable all minions to execute all commands.
        peer:
            foo.example.com:
                - test.*
        This configuration will only allow the minion foo.example.com to
        execute commands from the test module
        ufunuargR.uno_parseutgt_typeuglobutgturetuidutmoutimeoutu"Failed to parse timeout value: {0}unodeu
nodegroupsucompoundurawuformuufullujidu__jid__ureturn(R:R
RR/R0R	R�t
ValueErrorR RR�R�RRR�tcmd_itertpopRR+R7(	R�R�R=tmsgRRHRRltval((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pytminion_publish�sh








,cC@sLd|krtStjj|j�}|j|dd|jdt��tS(uE
        Allow a minion to request revocation of its own key
        uidtpreserve_minionsupreserve_minion_cache(RJR
RltKeyRt
delete_keyR	R(R�R�tkeyapi((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pytrevoke_auth�s	
(R�R�R�R�R�R:R�RJR�RRRR
RRR!R*R-R5R9R>RDRI(((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pyR��s(			$	!4	
	=			!		&	8	Lt
LocalFuncscB@sMeZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	RS(u;
    Set up methods for use only from the local system
    cC@s�||_tjj|�|_||_tjjjd|jd|jdd|jdt	�|_tj
jd|j�|_tjj
j|�|_tjj|�|_tjj|jdt	dt	�|_tjj|�|_dS(	Numasterusock_diru	transportRR�R�RFRG(RR
R�R�R�RlRR�R�RJR�R�R�R�R�R�R0R1R6RHRIRLtwheeltWheeltwheel_(R�RRl((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pyR��s"		

			cC@so|j|�\}}}|jj||�}|jd�}|rMi|d6S|jj|jdg�|d|d�}|jd�}|s�ii|d6dj||�d6d6St|t�r�d|kr�|SyG|j	d�}	t
jj|j
�}
|
j|	|jdi�|�SWnOtk
rj}tjd	�ii|jjd6|jd
6tj|�d6d6SXdS(uJ
        Send a master control function back to the runner system
        uerroru	auth_listufunukwarguusernameunameu;Authentication failure of type "{0}" occurred for user {1}.umessageu)Exception occurred while introspecting %suargsN(t_prep_auth_infoR6tcheck_authenticationR	R�trunner_checkR R�R�RAR
R1tRunnerClientRtasynchronousR�Rt	exceptiont	__class__R�R/RR<(R�R�t	auth_typeterr_nameRlR�R>RPtusernameR�t
runner_clientR*((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pyR1s6	

	

cC@s||j|�\}}}|jj||d|dt�}|jd�}|rYi|d6S|jd�}|dkr�|jj|jdg�|d|d�}|s�ii|d	6d
j||�d6d6St|t	�r�d|kr�|Snt
jjj
|j�}	|jd�}
t
jjj|	dd
�}idj|
�d6|	d6|d6|d6}y�|jj|t
jjj|	dgd
��|jj|
|�}
|
|d<t|d<|jj|t
jjj|	dgd
��i|d6|d6SWn�tk
rw}tjd|
�dj|
|jj|�|d<t|d<|jj|t
jjj|	dgd
��i|d6|d6SXdS(uI
        Send a master control function back to the wheel system
        Rlt
show_usernameuerroruusernameuuseru	auth_listufunukwargunameu;Authentication failure of type "{0}" occurred for user {1}.umessagetprefixuwheelu	wheel.{0}ujidutagunewureturnusuccessuretudatau)Exception occurred while introspecting %su)Exception occurred in wheel {0}: {1}: {2}N(RNR6RORR	R�twheel_checkR R�R�R
RR#R%RRAR�RRRMt	call_funcR�RRSRTR�RJ(R�R�RURVRlR�R>RWR[R#R�R RRR*((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pyRK@s\			


+

+
	

+
cC@s-|jj|�}|s)tjd�dS|S(u�
        Create and return an authentication token, the clear load needs to
        contain the eauth key and the needed authentication creds.
        u0Authentication failure of type "eauth" occurred.u(R6tmk_tokenRR�(R�R�ttoken((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pyR]�s

cC@s$d|krtS|jj|d�S(uZ
        Return the name associated with a token or False if the token is invalid
        utoken(RJR6R3(R�R�((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pyt	get_token�sc
C@s�|jdi�}tjj|jd�}|j|d�sQ|j|d�r�tjd|d|d�iidd6dd	6d
6S|jdi�jdt	�}|j
j|d|jd
d�|�}|d}|j|�\}}}	|dkr|j
j||d|	�}
n|j
j||�}
|
jdg�}|
jd
�}dj|�}
|r�tj|
�iidd6dd	6d
6S|dks�|dkrw|rw|j
j||d|d|d|jd
d�d|ddg�}|stj|
�iidd6dd	6d
6S|dkrO|
jd�}||d<tjd|�qw|dkrw|j
j|�|d<qwn|jjd�s�|s�idd6id;d 6|d6d!6Sn|d s�d"j|jd#�}|jj|d$|jd%t��|d <n|jji|d6|d �i|d d 6|d
d
6|dd6|dd6|dd6tjjj|dd&|jd'g��d6|d6}|jj|d(�|jj|tjjj|d d)gd*��|jd+ray5d,j|jd+�}|jj||d |�Wqatk
r:tjd-|jd+�qat k
r]tjd.d/t!�qaXny5d,j|jd#�}|jj||d |�WnKtk
r�tjd0|jd#�n$t k
r�tjd.d/t!�nXi|dd6tjjj|dd&|jd'g��d6|dd6|d d 6|d1d16}d2|kr_|d2|d2<nd
|kr||d
|d
<nd3|kr�|d3|d3<nd|kr&d4|dkr�|djd4�|d4<nd5|dkr�|djd5�|d5<nd6|dkr&|djd6�|d6<q&nd|kretj"d7|d|d|d �|d|d<ntj"d8|d|d �tjd9|�ii|d d 6|d6d16|d:6S(<ut
        This method sends out publications to the minions, it can only be used
        by the LocalClient.
        ukwargsupublisher_acl_blacklistuuserufunup%s does not have permissions to run %s. Please contact your local administrator if you believe this is in error.uAuthorizationErrorunameuAuthorization error occurred.umessageuerroru	delimiterutgtutgt_typeuglobuminionsRlu	auth_listu.Authentication failure of type "{0}" occurred.uAuthenticationErroruAuthentication error occurred.uargR�Rousaltutil.find_jobutokenuusernameuMinion tokenized user = "%s"ueauthu
order_mastersuclearuencujiduloadu{0}.prep_jidumaster_job_cacheR"unocacheR.uno_parseunew_jobunewujobu
ext_job_cacheu
{0}.save_loadu_The specified returner used for the external job cache "%s" does not have a save_load function!u+The specified returner threw a stack trace:texc_infou]The specified returner used for the master job cache "%s" does not have a save_load function!uretuidutou
ret_configumetadatau
ret_kwargsu(User %s Published command %s with jid %su Published command %s with jid %suPublished command details %supubN(#R	R
tacltPublisherACLRtuser_is_blacklistedtcmd_is_blacklistedRR>RR�R�RNR6ROR R�R�R"t	load_nameRPRLRKRJR�RRR/R0RRTRR�RRt(R�R�textraRyt	delimiterRR�RURVRlR�t	auth_listR>terr_msgt
authorizedRWRMtnew_job_loadR=((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pytpublish�s�
		


	



,

/






cC@s^d}d|kr!d}d}n0d|kr<d}d}nd}d}|j}|||fS(NutokenuTokenAuthenticationErrorueauthuEauthAuthenticationErroruuseruUserAuthenticationError(RPRl(R�R�RlRURV((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pyRNWs			(
R�R�R�R�R1RKR]R_RlRN(((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pyRJ�s		+	@			�(BR�t
__future__RRRR&R�RR�R4R[tsalt.aclR
t
salt.cryptt
salt.cachetsalt.clienttsalt.exceptionstsalt.payloadtsalt.pillart
salt.statetsalt.runnert	salt.autht
salt.wheeltsalt.miniontsalt.keytsalt.fileservertsalt.utils.argstsalt.utils.atomicfiletsalt.utils.dictupdatetsalt.utils.eventtsalt.utils.filestsalt.utils.gitfstsalt.utils.verifytsalt.utils.minionstsalt.utils.gzip_utiltsalt.utils.jidtsalt.utils.pathtsalt.utils.platformtsalt.utils.stringutilstsalt.utils.usertsalt.utils.versionst
salt.defaultsRRtsalt.extRRQRROtImportErrorRJt	getLoggerR�RRR/R9RERNRnR{R�tobjectR�R�RJ(((s:/usr/lib/python2.7/site-packages/salt/daemons/masterapi.pyt<module>sx


		*				-		���a

Zerion Mini Shell 1.0