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

�
���^c@�sdZddlmZmZmZmZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlmZddlmZddlmZmZmZmZddlZ ddl!Zddl"Zddl#Zddl$Zddl%Zddl&Zddl'Zddl(Zddl)Zddl*Zddl+Zddl,Zddl-Zddl.Zddl/Zddl0Zddl1Zddl2Zddl3Zddl4Zddl5Zddl6Zddl7Zddl8Zddl9Zddl:Zddl;Zddl<Zddl=Zddl>Zddl?Zddl@ZddlAZddlBZddlCZddlDZddlZddlEmFZFddlGmHZHdd	lImJZJdd
lKmLZLmMZMmNZNddl6mOZOddlPmQZQyddlRZReSZTWneUk
r�eVZTnXyddlWZWeSZXWneUk
r�eVZXnXdd
lYmZZZddl[m\Z\ej]e^�Z_de`fd��YZadejbjcjdfd��YZedejbjcjdfd��YZfdeafd��YZgdejbjcjdfd��YZhdejbjcjdfd��YZidejbjcjdfd��YZjde`fd��YZkdekfd ��YZld!ekfd"��YZmd#ejfd$��YZndS(%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_importtwith_statementtprint_functiontunicode_literalsN(tsix(trange(tzmqtZMQDefaultLooptinstall_zmqtZMQ_VERSION_INFO(tDEFAULT_INTERVAL(tDEFAULT_TARGET_DELIM(titer_transport_opts(tenable_sigusr1_handlertenable_sigusr2_handlert
inspect_stack(ttagify(tOrderedDict(tStackContext(tRequestContexttSMastercB�s8eZdZiZd�Zd�Zd�Zd�ZRS(uN
    Create a simple salt-master, this will generate the top-level master
    cC�s4||_tjj|j�|_|j�|_dS(um
        Create a salt master server instance

        :param dict opts: The salt options dictionary
        N(toptstsalttcryptt
MasterKeyst
master_keyt_SMaster__prep_keytkey(tselfR((s//usr/lib/python2.7/site-packages/salt/master.pyt__init__ks	cC�s8|d|_|d|_|d|_|dt_dS(Nuoptsu
master_keyukeyusecrets(RRRRtsecrets(Rtstate((s//usr/lib/python2.7/site-packages/salt/master.pyt__setstate__zs


cC�s,i|jd6|jd6|jd6tjd6S(Nuoptsu
master_keyukeyusecrets(RRRRR(R((s//usr/lib/python2.7/site-packages/salt/master.pyt__getstate__�s


cC�stjjj|j�S(u�
        A key needs to be placed in the filesystem with permissions 0400 so
        clients are required to run as root.
        (Rtdaemonst	masterapitaccess_keysR(R((s//usr/lib/python2.7/site-packages/salt/master.pyt
__prep_key�s(t__name__t
__module__t__doc__RRR R!R(((s//usr/lib/python2.7/site-packages/salt/master.pyRes			tMaintenancecB�sheZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�ZRS(uP
    A generalized maintenance process which performs maintenance routines.
    cK�sftt|�j|�||_t|jd�|_ttj��|_tj	j
|j�|_dS(u[
        Create a maintenance instance

        :param dict opts: The salt options
        u
loop_intervalN(tsuperR)RRtintt
loop_intervalttimetrotateRtpayloadtSerialtserial(RRtkwargs((s//usr/lib/python2.7/site-packages/salt/master.pyR�s
	cC�s2t|_|j|dd|dd|d�dS(Nuoptst	log_queueu	log_queuetlog_queue_levelulog_queue_level(tTruet	_is_childR(RR((s//usr/lib/python2.7/site-packages/salt/master.pyR �s
	

cC�s"i|jd6|jd6|jd6S(Nuoptsu	log_queueulog_queue_level(RR3R4(R((s//usr/lib/python2.7/site-packages/salt/master.pyR!�s

cC�sFt|j�}t|d<tjj|�}tjj|ji�|_tjj	j
|j|j�d|j�|_	tjjj
|j�|_tjjj|j|jddt�|_tjjj|j�|_t|_|jjdt�rBt}x2t|j�D]!\}}|dkrt}qqW|sBt|_qBndS(u<
        Some things need to be init'd after the fork has completed
        The easiest example is that one of these module types creates a thread
        in the parent process, then once the fork happens you'll start getting
        errors like "WARNING: Mixing fork() and threads detected; memory leaked."
        uquiett	returnersusock_dirtlistenupresence_eventsutcpN(tdictRR5RtrunnertRunnerClienttloaderR7tutilstscheduletScheduletfunctions_dicttminionst	CkMinionst	ckminionsteventtget_master_eventtFalseR"R#tinit_git_pillart
git_pillartpresence_eventstgetR(Rtroptst
runner_clientttcp_onlyt	transportt_((s//usr/lib/python2.7/site-packages/salt/master.pyt_post_fork_init�s$
+	
cC�stjjj|jj�|j�ttj��}t	�}x�t
rttj��}|||jkr�tjj
j|j�tjj
j|j�tjj
j|j�n|j�|j�|j�|j|�|j|�tjjj|j�|}tj|j�qAWdS(u�
        This is the general passive maintenance process controller for the Salt
        master.

        This is where any data that needs to be cleanly maintained from the
        master is maintained.
        N(RR=tprocesstappendproctitlet	__class__R&RPR+R-tsetR5R,R"R#tclean_old_jobsRtclean_expired_tokenstclean_pub_auththandle_git_pillarthandle_schedulethandle_key_cachethandle_presencethandle_key_rotatetverifytcheck_max_open_filestsleep(Rtlasttold_presenttnow((s//usr/lib/python2.7/site-packages/salt/master.pytrun�s$
		




cC�sp|jddkrlg}|jddkr5d}nd}xxtjtjj|jd|��D]Q}|jd	�ratjjtjj|jd||��ra|j|�qaqaWtj	d
�t
jrtj
jjtjj|jd|d���}|jj||�WdQXqltj
jjtjj|jd|d�d
d��}|jj||�WdQXndS(u`
        Evaluate accepted keys and create a msgpack file
        which contains a list
        u	key_cacheuschedu	transportuzeromqutcpuminionsuacceptedupki_diru.uWriting master key cacheu
.key_cacheNtmodeuwb(uzeromqutcp(Rtostlistdirtpathtjoint
startswithtisfiletappendtlogtdebugRtPY2RR=t
atomicfiletatomic_openR1tdump(Rtkeystacctfn_t
cache_file((s//usr/lib/python2.7/site-packages/salt/master.pyRZ�s	,;
	17c	C�s�t}tjj|jdd�}y�tj|�}tjjj	�rtj
|tj�rt}tj
|tjtjB�n%|jdkr�t}n
tjd�tj|�Wntjk
r�nX|jjd�r||j|jdkrt}qn|r�tjd�x�tjtj�D]l\}}|dj��(tjjj|d��|d_Wd	QX|jj itd
j!|�6dd�q'W||_|jjd
�r�tj"d�tjj#j$|j�q�nd	S(u-
        Rotate the AES key rotation
        ucachediru.dfni�u6Found dropfile with incorrect permissions, ignoring...upublish_sessionuRotating master AES keyusecretureloadNurotate_{0}_keyttagukeyuping_on_rotateu1Pinging all connected minions due to key rotation(%RFReRgRhRtstatRR=tplatformt
is_windowstaccesstW_OKR5tchmodtS_IRUSRtS_IWUSRtst_modeRlterrortremoveRJR.tinfoRt	iteritemsRRtget_locktstringutilstto_bytestvalueRDt
fire_eventtformatRmtmastertping_all_connected_minions(RRbt	to_rotatetdfntstatst
secret_keyt
secret_map((s//usr/lib/python2.7/site-packages/salt/master.pyR\s4(	

)*	
cC�sOy"x|jD]}|j�q
WWn&tk
rJ}tjddt�nXdS(u#
        Update git pillar
        u*Exception caught while updating git_pillartexc_infoN(RHt
fetch_remotest	ExceptionRlR�R5(Rtpillartexc((s//usr/lib/python2.7/site-packages/salt/master.pyRX7scC�soy8|jj�|jj|jkr7|jj|_nWn#tk
r]}tjd|�nX|jj�dS(u(
        Evaluate the scheduler
        u&Exception %s occurred in scheduled jobN(R>tevalR,R�RlR�tcleanup_subprocesses(RR�((s//usr/lib/python2.7/site-packages/salt/master.pyRYBs
cC�s�|jr�|jjdd�r�|jj�}|j|�}|j|�}|sW|r�it|�d6t|�d6}|jj|tdd��nit|�d6}|jj|tdd��|j	�|j
|�ndS(	u1
        Fire presence events if enabled
        ttimeoutiunewulostuchangeupresenceupresentN(RIRDtconnect_pullRCt
connected_idst
differencetlistR�Rtcleartupdate(RRatpresenttnewtlosttdata((s//usr/lib/python2.7/site-packages/salt/master.pyR[Ps
(
R&R'R(RR R!RPRcRZR\RXRYR[(((s//usr/lib/python2.7/site-packages/salt/master.pyR)�s				#	 		(		tFileserverUpdatecB�sDeZdZd�Zd�Zd�Zd�Zd�Zd�ZRS(uH
    A process from which to update any dynamic fileserver backends
    cK�sZtt|�j|�||_i|_ddl}|jj|j�|_|j�dS(Ni(	R*R�RRtupdate_threadstsalt.fileservert
fileservert
Fileservertfill_buckets(RRR2R((s//usr/lib/python2.7/site-packages/salt/master.pyRis		cC�s(t|_|j|dd|d�dS(NuoptsR3u	log_queue(R5R6R(RR((s//usr/lib/python2.7/site-packages/salt/master.pyR us	
cC�si|jd6|jd6S(Nuoptsu	log_queue(RR3(R((s//usr/lib/python2.7/site-packages/salt/master.pyR!|s
c	C�sx|jj�}i|_xY|jj�D]H}dj|�}y|jj|}Wn$tk
rwtjd|�q(nX||krx�t	j
||�D]b\}}|s�t}tjd|�n|jj|t
��}|j||fg�j|�q�Wq(y dj|�}|j|}Wn*tk
rMt}tjd||�nXd|jj|t
��||f<q(WdS(u�
        Get the configured backends and the intervals for any backend which
        supports them, and set up the update "buckets". There will be one
        bucket for each thing being updated at a given interval.
        u
{0}.updateu/No update function for the %s filserver backendu<An update_interval of 0 is not supported, falling back to %su{0}_update_intervaluQ%s key missing from configuration. Falling back to default interval of %d secondsN(R�tupdate_intervalstbucketstbackendsR�tserverstKeyErrorRlRmRR�R
t
setdefaultRRkRtwarningtNone(	RR�tbackendtfstrtupdate_functid_tintervalti_ptrtinterval_key((s//usr/lib/python2.7/site-packages/salt/master.pyR��s:	
 
&
c�sW��fd�}tj�}|�x+trR|�|j��WdQX|�q(WdS(uV
        Threading target which handles all updates for a given wait interval
        c�s�tjd��x�tj��D]�\}}|\}}yI|r`tjd||�|f}ntjd|�d}||�Wq tk
r�}tjd|�q Xq Wtjd���dS(NuEPerforming fileserver updates for items with an update interval of %du:Updating %s fileserver cache for the following targets: %suUpdating %s fileserver cacheu5Uncaught exception while updating %s fileserver cacheuXCompleted fileserver updates for items with an update interval of %d, waiting %d seconds((RlRmRR�R�t	exception(R�tupdate_argstbackend_nameR�targsR�(R�R�(s//usr/lib/python2.7/site-packages/salt/master.pyt
_do_update�s*
N(t	threadingt	ConditionR5twait(RR�R�R�t	condition((R�R�s//usr/lib/python2.7/site-packages/salt/master.pytupdate_fileserver�s	cC�s�tjjj|jj�tjjj|j	�xQ|j
D]F}tjd|j
d||j
|f�|j|<|j|j�q9Wxtr�tjd�q�WdS(u*
        Start the update threads
        ttargetR�i<N(RR=RQRRRSR&R"R#tclean_fsbackendRR�R�tThreadR�R�tstartR5R-R_(RR�((s//usr/lib/python2.7/site-packages/salt/master.pyRc�s			(	R&R'R(RR R!R�R�Rc(((s//usr/lib/python2.7/site-packages/salt/master.pyR�es				5	)tMastercB�s;eZdZd�Zd�Zd�Zd�Zd�ZRS(u 
    The salt master server
    cC�s6tr"tdkr"tjd�ntj||�dS(u]
        Create a salt master server instance

        :param dict: The salt options
        iiu�You have a version of ZMQ less than ZMQ 3.2! There are known connection keep-alive issues with ZMQ < 3.2 which may result in loss of contact with minions. Please upgrade your ZMQ!N(ii(RR	RlR�RR(RR((s//usr/lib/python2.7/site-packages/salt/master.pyR�s
cC�sts
dStjtj�\}}|tjkr:|}ntjd||�|jd}||kr�tjd|||�|}n||krtjd|�tjtj||f�y/tjtj�\}}tjd||�Wqt	k
rtj
d|�qXndS(Nu:Current values for max open files soft/hard setting: %s/%sumax_open_filesu�The value for the 'max_open_files' setting, %s, is higher than the highest value the user running salt is allowed to set (%s). Defaulting to %s.u"Raising max open files value to %su5New values for max open files soft/hard values: %s/%su~Failed to raise max open files setting to %s. If this value is too low, the salt-master will most likely fail to run properly.(tHAS_RESOURCEtresourcet	getrlimitt
RLIMIT_NOFILEt
RLIM_INFINITYRlR�Rt	setrlimitt
ValueErrortcritical(Rtmof_stmof_htmof_c((s//usr/lib/python2.7/site-packages/salt/master.pyt__set_max_open_filess4	


	
c
C�sjg}g}ytjd�Wn)tk
rH}|jdj|��nX|jjdt�r�ddl}|j	j
|j�}|js�|jdjdj|jd���q�y|j
�Wq�|jjk
r�}|jd	j|��q�Xn|jds|jd
�n|jdr�tjjtjj|jdd��r�yC|jjjd
��(tjtjj|jdd��WdQXWq�tk
r�q�Xn|jjdt�r�yOg|jjdg�D]/}d|kr�t|dtj�r�|^q�}Wn$tk
r+g}|jd�nX|r�z�tj|j�}	ddl}x�|D]�}
|
g|	d<yM|jjj|	|
dd|jj j!d|jj j"d|jj j#�}WqZ|jjk
r�}|j|j$�qZXqZWWd~	Xq�n|s|rfx|D]}t%j&|�qWx|D]}t%j'|�q)Wt%j'd�t(j)|j*j+j,�ndS(uv
        Run pre flight checks. If anything in this method fails then the master
        should not start up.
        u/u%Cannot change to root directory ({0})ufileserver_verify_configiNuDFailed to load fileserver backends, the configured backends are: {0}u, ufileserver_backendu{0}u%No fileserver backends are configuredupillar_cacheucachediri?ugit_pillar_verify_configu
ext_pillarugitu�Invalid ext_pillar configuration. It is likely that the external pillar type was not specified for one or more external pillars.tper_remote_overridestper_remote_onlytglobal_onlyu)Master failed pre flight checks, exiting
(-RetchdirtOSErrorRkR�RRJR5R�R�R�R�Rhtinitt
exceptionstFileserverConfigErrorRgtisdirR=tfilest	set_umasktmkdirt
isinstanceRtstring_typest	TypeErrortcopytdeepcopytsalt.pillar.git_pillartgitfst	GitPillarR�RHtPER_REMOTE_OVERRIDEStPER_REMOTE_ONLYtGLOBAL_ONLYtstrerrorRlR�R�tsystexittdefaultst	exitcodest
EX_GENERIC(
Rterrorstcritical_errorsterrRR�R�txtgit_pillarstnew_optstrepoRHR�((s//usr/lib/python2.7/site-packages/salt/master.pyt_pre_flight3st	
6-
'







cC�s!|j�tjdtjjj��t�t�|j	�tjj
jtj
tj��Jitjtjtjjjtjjj���d6tjjjd6tjd<tjd�tjj
jdd�|_g}tjd�tjjj�}x_t|j�D]N\}}tj j!j"j#|�}|j$|jd	i|d
6�|j%|�qWtjd�|jj&tjj'j(d|jf�|jj)d
�rFt*|jdt+�rt,}x+|jdD]}d
|kr�t-}Pq�q�W|sC|jdj%iid
6�qCqFd
|jdkrFtjd�i|jdd
<qFntj.j/|j|j�tjd�|jj&t0d|jf�|jj)d�r�tjd�|jj&tjj'j1d|jf�n|jj)dg�}x�|D]�}	tjd|	�ydj2|	j3d�d �}
|	j3d�d}t4|
t5�t6�|gd�}|j7|�}|jj&|d|jf�Wq�t8k
r�tj9d|	�q�Xq�Wt:r�d|jkr�tjd�|jj&t;d|jdf�n|jdrItjd�|jj&tjj<j=d|jf�tj>d�t?j@d�ntjd�i}
tjjAjB�r�||
d
<tjjjC�|
d<tj|
d <n|jj&tDd|j|jE|jFfd	|
d!d"�|jj&tGd|jf�|jd#r�tjjHjIjJ�rp|jj&tjjHjId$|jd#d%d&|jd'd(i|jd#j)d)i�d)6�jK�q�tj9d*�tLjMjNdkr�tj9d+�q�nWd,QXtjOtj
�tjPkr�tjtj
|jQ�ntjOtj�tjPkrtjtj|jQ�n|jjK�d,S(-u6
        Turn on the master server components
        u$salt-master is starting as user '%s'usecretureloaduaesuCreating master process managert
wait_for_killiu!Creating master publisher processR2u	log_queueu'Creating master event publisher processR�ureactoruenginesuEnabling the reactor engineu#Creating master maintenance processuevent_returnu$Creating master event return processu
ext_processesu"Creating ext_processes process: %su.i����u(Error creating ext_processes process: %suhaliteuCreating master halite processu	con_cacheu Creating master concache processu-Sleeping for two seconds to let concache restiu&Creating master request server processulog_queue_levelusecretstnameu	ReqServeru	discoverytportuportt	listen_ipu	interfacetanswerumappingu6Unable to load SSDP: asynchronous IO is not available.uRYou are using Python 2, please install "trollius" module to enable SSDP discovery.N(RR�RlR�RR=tusertget_userR
Rt_Master__set_max_open_filesRQtdefault_signalstsignaltSIGINTtSIGTERMtmultiprocessingtArraytctypestc_charR�R�Rt	Crypticletgenerate_key_stringRRtProcessManagertprocess_managertsetupt!get_multiprocessing_logging_queueRRRNtservertPubServerChanneltfactorytpre_forkRktadd_processRDtEventPublisherRJR�R�RFR5tenginest
start_enginesR)tEventReturnRhtsplitt
__import__tglobalstlocalst__getattribute__R�R�t
HAS_HALITEtHaliteR�tConnectedCacheRmR-R_RxRyt!get_multiprocessing_logging_levelt	ReqServerRRR�tssdptSSDPDiscoveryServertis_availableRcR�tversion_infotmajort	getsignaltSIG_DFLt_handle_signals(Rtpub_channelsR3RORtchantrinetitemt	ext_procstproctmodtclst_tmpR2((s//usr/lib/python2.7/site-packages/salt/master.pyR��s�




%!


(
! 

#

%


		


*
cC�sH|jj�|jj|�|jj�tjd�tjd�dS(Nii(Rtstop_restartingtsend_signal_to_processest
kill_childrenR-R_R�R�(Rtsignumtsigframe((s//usr/lib/python2.7/site-packages/salt/master.pyR(s



(R&R'R(RR�R�R�R((((s//usr/lib/python2.7/site-packages/salt/master.pyR��s		-	S	�RcB�s2eZdZd�Zd�Zd�Zd�ZRS(u"
    Manage the Halite server
    cK�s#tt|�j|�||_dS(uY
        Create a halite instance

        :param dict hopts: The halite options
        N(R*RRthopts(RR7R2((s//usr/lib/python2.7/site-packages/salt/master.pyRscC�s2t|_|j|dd|dd|d�dS(NuhoptsR3u	log_queueR4ulog_queue_level(R5R6R(RR((s//usr/lib/python2.7/site-packages/salt/master.pyR "s
	

cC�s"i|jd6|jd6|jd6S(Nuhoptsu	log_queueulog_queue_level(R7R3R4(R((s//usr/lib/python2.7/site-packages/salt/master.pyR!*s

cC�s-tjjj|jj�tj|j�dS(u!
        Fire up halite!
        N(	RR=RQRRRSR&thaliteR�R7(R((s//usr/lib/python2.7/site-packages/salt/master.pyRc1s(R&R'R(RR R!Rc(((s//usr/lib/python2.7/site-packages/salt/master.pyRs
			R cB�s_eZdZd	d�Zd�Zd�Zd�Zd�Zd�Z	e
jd�Zd�Z
RS(
uZ
    Starts up the master request server, minions send results to this
    interface.
    cK�s>tt|�j|�||_||_||_||_dS(u
        Create a request server

        :param dict opts: The salt options dictionary
        :key dict: The user starting the server and the AES key
        :mkey dict: The user starting the server and the RSA key

        :rtype: ReqServer
        :returns: Request server
        N(R*R RRRRR(RRRtmkeyRR2((s//usr/lib/python2.7/site-packages/salt/master.pyR>s
			cC�sJt|_|j|d|d|dd|dd|dd|d	�dS(
NuoptsukeyumkeyRusecretsR3u	log_queueR4ulog_queue_level(R5R6R(RR((s//usr/lib/python2.7/site-packages/salt/master.pyR Ss	


cC�s@i|jd6|jd6|jd6|jd6|jd6|jd6S(Nuoptsukeyumkeyusecretsu	log_queueulog_queue_level(RRRRR3R4(R((s//usr/lib/python2.7/site-packages/salt/master.pyR!^s




cC�s*|j|�tt|�j||�dS(N(tdestroyR*R R((RR5R6((s//usr/lib/python2.7/site-packages/salt/master.pyR(hs
c
C�s�|jdk	r(tjjj|j�n|jdk	rPtjjj|j�ntjjj|j�|j	dk	r�|j	t
_	ntjj
|jdd�}tjj|�r"yVtjjj�r�tj|tj�r�tj|tjtjB�ntj|�Wq"tjk
rq"Xntjjjdddd�|_g}t}xgt|j�D]V\}}tj j!j"j#|�}|j$|j�|j%|�|dkr_t&}q_q_Wi}tjjj�r3|j|d<|j|d	<|r3t'j(r3t)|jd
�dkr3tj*d�d|jd
<q3ntjjj+t,j-t,j.��rxjt/t)|jd
��D]O}dj0|�}	|jj1t2d
|j|j3|j4||	fd|d|	�qlWWdQX|jj5�dS(u(
        Binds the reply server
        ucachediru.dfnR�uReqServer_ProcessManagerR�iutcpu	log_queueulog_queue_leveluworker_threadsuDTCP transport supports only 1 worker on Windows when using Python 2.uMWorker-{0}R�R2N(6R3R�RRlRt!set_multiprocessing_logging_queueR4t!set_multiprocessing_logging_leveltsetup_multiprocessing_loggingRRReRgRhRRjR=RxRyRzR{R|RwR}R~R�R�RQR
RR5RRNRtReqServerChannelRRRkRFRRnR+R�RRRRRR�RtMWorkerRRRc(
RR�treq_channelsRMRNRR*R2tindR�((s//usr/lib/python2.7/site-packages/salt/master.pyt__bindlsX(



(
 	cC�s|j�dS(u(
        Start up the ReqServer
        N(t_ReqServer__bind(R((s//usr/lib/python2.7/site-packages/salt/master.pyRc�scC�s@t|d�r<|jj�|jj|�|jj�ndS(Nuprocess_manager(thasattrRR2R3R4(RR5((s//usr/lib/python2.7/site-packages/salt/master.pyR:�s
cC�s|j�dS(N(R:(R((s//usr/lib/python2.7/site-packages/salt/master.pyt__del__�sN(R&R'R(R�RR R!R(RCRcRRR:RE(((s//usr/lib/python2.7/site-packages/salt/master.pyR 9s		
		?	R?cB�steZdZd�Zd�Zd�Zd�Zd�Zej	j
d��Zd�Zd�Z
d	�Zd
�ZRS(ud
    The worker multiprocess instance to manage the backend operations for the
    salt master.
    cK�s~||d<||_tt|�j|�||_||_||_||_d|_t	j
d��|_tj�|_
dS(u.
        Create a salt master worker process

        :param dict opts: The salt options
        :param dict mkey: The user running the salt master and the AES key
        :param dict key: The user running the salt master and the RSA key

        :rtype: MWorker
        :return: Master worker
        unameicS�sidd6dd6S(Niumeanuruns((((s//usr/lib/python2.7/site-packages/salt/master.pyt<lambda>�sN(R�R*R?RRR@R9Rtk_mtimetcollectionstdefaultdictR�R-t
stat_clock(RRR9RR@R�R2((s//usr/lib/python2.7/site-packages/salt/master.pyR�s
						cC�s�t|_tt|�jd|dd|d�|d|_|d|_|d|_|d|_|d	|_	|d
t
_dS(NR3u	log_queueR4ulog_queue_leveluoptsureq_channelsumkeyukeyuk_mtimeusecrets(R5R6R*R?RRR@R9RRGRR(RR((s//usr/lib/python2.7/site-packages/salt/master.pyR �s	





cC�sTi|jd6|jd6|jd6|jd6|jd6tjd6|jd6|jd6S(	Nuoptsureq_channelsumkeyukeyuk_mtimeusecretsu	log_queueulog_queue_level(	RR@R9RRGRRR3R4(R((s//usr/lib/python2.7/site-packages/salt/master.pyR!�s






cC�sDx$t|dd�D]}|j�qWtt|�j||�dS(Nureq_channels((tgetattrtcloseR*R?R((RR5R6tchannel((s//usr/lib/python2.7/site-packages/salt/master.pyR(�scC�s|t�t�|_|jj�x*|jD]}|j|jd|j�q*Wy|jj�Wntt	fk
rwnXdS(u(
        Bind to the local port
        tio_loopN(
RRRNtmake_currentR@t	post_forkt_handle_payloadR�tKeyboardInterruptt
SystemExit(Rtreq_channel((s//usr/lib/python2.7/site-packages/salt/master.pyRBs
cC�sN|d}|d}i|jd6|jd6||�}tjj|��dS(u�
        The _handle_payload method is the key method used to figure out what
        needs to be done with communication to the server

        Example cleartext payload generated for 'salt myminion test.ping':

        {'enc': 'clear',
         'load': {'arg': [],
                  'cmd': 'publish',
                  'fun': 'test.ping',
                  'jid': '',
                  'key': 'alsdkjfa.,maljf-==adflkjadflkjalkjadfadflkajdflkj',
                  'kwargs': {'show_jid': False, 'show_timeout': False},
                  'ret': '',
                  'tgt': 'myminion',
                  'tgt_type': 'glob',
                  'user': 'root'}}

        :param dict payload: The payload route to the appropriate handler
        uenculoaduaesuclearN(t_handle_aest
_handle_clearttornadotgentReturn(RR/Rtloadtret((s//usr/lib/python2.7/site-packages/salt/master.pyRQs



cC�s�tj�}||}|j|d|j|dd||j|d|j|d<||j|jdkr�|jjji||jd6|jd6|jd6t|jd��t	j
d��|_||_nd	S(
uK
        Calculate the master stats and fire events with stat info
        umeanurunsiumaster_stats_event_iterutimeuworkerustatscS�sidd6dd6S(Niumeanuruns((((s//usr/lib/python2.7/site-packages/salt/master.pyRF6sN(R-R�RJRt	aes_funcsRDR�R�RRHRI(RR�tcmdtendtduration((s//usr/lib/python2.7/site-packages/salt/master.pyt_post_stats,s
BDcC�s�tjd|d�|d}|jj|�}|sGiidd6fS|jdrztj�}|j|dcd7<n||�idd6f}|jdr�|j||�n|S(u�
        Process a cleartext command

        :param dict load: Cleartext payload
        :return: The result of passing the load to a function in ClearFuncs corresponding to
                 the command specified in the load's 'cmd' key.
        u&Clear payload received with command %sucmdu
send_clearufunumaster_statsurunsi(Rlttracetclear_funcst
get_methodRR-R�R`(RRZR]tmethodR�R[((s//usr/lib/python2.7/site-packages/salt/master.pyRV9s


c�s	d|kr tjd|�iS|d}tjd|d��jj|�}|sgiidd6fS�jdr�tj�}�j|dcd7<n�fd	�}tt	j
ti|d
6�jd6���||�}WdQX�jdr�j||�n|S(
u�
        Process a command sent via an AES key

        :param str load: Encrypted payload
        :return: The result of passing the load to a function in AESFuncs corresponding to
                 the command specified in the load's 'cmd' key.
        ucmduReceived malformed command %su$AES payload received with command %susendufunumaster_statsurunsic�s�jj|d|�S(Nucmd(R\trun_func(R�(R(s//usr/lib/python2.7/site-packages/salt/master.pyRebsudatauoptsN(
RlR�RaR\RcRR-R�Rt	functoolstpartialRR`(RR�R]RdR�ReR[((Rs//usr/lib/python2.7/site-packages/salt/master.pyRUNs&



cC�s^tjjj|j�t|j|j�|_t	|j�|_
tjjj�|j
�dS(u'
        Start a Master Worker
        N(RR=RQRRR�t
ClearFuncsRRRbtAESFuncsR\Rt
reinit_cryptot_MWorker__bind(R((s//usr/lib/python2.7/site-packages/salt/master.pyRcns(R&R'R(RR R!R(RkRWRXt	coroutineRQR`RVRURc(((s//usr/lib/python2.7/site-packages/salt/master.pyR?�s	"	
				
		 tTransportMethodscB�seZdZdZd�ZRS(u�
    Expose methods to the transport layer, methods with their names found in
    the class attribute 'expose_methods' will be exposed to the transport layer
    via 'get_method'.
    cC�s[||jkrGyt||�SWqWtk
rCtjd|�qWXntjd|�dS(uM
        Get a method which should be exposed to the transport layer
        u Requested method not exposed: %sN(texpose_methodsRKtAttributeErrorRlR�(RR�((s//usr/lib/python2.7/site-packages/salt/master.pyRc�s
((R&R'R(RnRc(((s//usr/lib/python2.7/site-packages/salt/master.pyRm|sRicB�s�eZdZd5Zd�Zd�Zd�Zd �Zd!�Zd"�Z	d#�Z
e
Zd$�Zd%�Z
d&�Zd'�Zd(�Zd)�Zd*�Zd+�Zd,�Zd-�Zd.�Zd/�Zd0�Zd1�Zd2�Zd3�Zd4�ZRS(6uQ
    Set up functions that are available when the load is encrypted with AES
    u
verify_minionu_master_topsu
_ext_nodesu_master_optsu	_mine_getu_mineu_mine_deleteu_mine_flushu
_file_recvu_pillaru
_minion_eventu_handle_minion_eventu_returnu_syndic_returnu
minion_runnerupub_retu
minion_pubuminion_publishurevoke_authu_serve_fileu
_file_findu
_file_hashu_file_hash_and_statu
_file_listu_file_list_emptydirsu	_dir_listu
_symlink_listu
_file_envscC�s�||_tjjj|j|jddt�|_tjj|�|_tjj	j
|�|_tjj
|jd�|_tjj|jdtdtdt�|_|j�tjjj|�|_dS(u�
        Create a new AESFuncs

        :param dict opts: The salt options

        :rtype: AESFuncs
        :returns: Instance for handling AES operations
        usock_dirR8u	conf_filetstatestrendtignore_config_errorsN(RRR=RDRERFR/R0R1RARBRCtclienttget_local_clienttlocaltminiontMasterMinionR5tmminiont_AESFuncs__setup_fileserverR"R#tRemoteFuncs(RR((s//usr/lib/python2.7/site-packages/salt/master.pyR�s		+		
cC�s�ddl}|jj|j�|_|jj|_|jj|_|jj	|_
|jj|_|jj
|_|jj|_|jj|_|jj|_|jj|_dS(uK
        Set the local file objects from the file server interface
        iN(R�R�R�Rtfs_t
serve_filet_serve_filet
_find_filet
_file_findt	file_hasht
_file_hashtfile_hash_and_statt_file_hash_and_statt	file_listt
_file_listtfile_list_emptydirst_file_list_emptydirstdir_listt	_dir_listtsymlink_listt
_symlink_listt	file_envst
_file_envs(RR((s//usr/lib/python2.7/site-packages/salt/master.pyt__setup_fileserver�scC�s
tjjj|j|�stStjj|jdd|�}ytj	j
|�}WnVttfk
r~t
jd|�tStttfk
r�}t
jd||�nXy#tj	j||�dkr�tSWn#tk
r�}t
jd|�nXt
jd|�tS(ui
        Take a minion id and a string signed with the minion private key
        The string needs to verify as 'salt' with the minion public key

        :param str id_: A minion ID
        :param str token: A string signed with the minion private key

        :rtype: bool
        :return: Boolean indicating whether or not the token can be verified.
        upki_diruminionsuzSalt minion claiming to be %s attempted to communicate with master, but key could not be read and verification was denied.u"Unable to load public key "%s": %sRuUnable to decrypt token: %sudSalt minion claiming to be %s has attempted to communicate with the master and could not be verified(RR=R]tvalid_idRRFReRgRhRtget_rsa_pub_keytIOErrorR�RlR�R�t
IndexErrorR�R�tpublic_decryptR5(RR�ttokentpub_pathtpubR�((s//usr/lib/python2.7/site-packages/salt/master.pyt__verify_minion�s*cC�s|j||�S(ui
        Take a minion id and a string signed with the minion private key
        The string needs to verify as 'salt' with the minion public key

        :param str id_: A minion ID
        :param str token: A string signed with the minion private key

        :rtype: bool
        :return: Boolean indicating whether or not the token can be verified.
        (t_AESFuncs__verify_minion(RR�R�((s//usr/lib/python2.7/site-packages/salt/master.pyt
verify_minion�sc�s�d|jkrtSt|jdt�s-tSt�fd�dD��rMtS�djd	�rdtS|j�d�d�s�tjd
�d�tS�j	d�g}xc|jdD]T}t
j|�d�r�t|jd|t�r|j
|jd|�qq�q�Wd�dkrq�djd��d<g}x%�dD]}|j|j��qGW|�d<n|jj|�d�d�d�jdd
�dt�S(u

        Verify that the passed information authorized a minion to execute

        :param dict clear_load: A publication load from a minion

        :rtype: bool
        :return: A boolean indicating if the minion is allowed to publish the command in the load
        upeerc3�s|]}|�kVqdS(N((t.0R(t
clear_load(s//usr/lib/python2.7/site-packages/salt/master.pys	<genexpr>
sufunuargutgturetutokuidupublish.uOMinion id %s is not who it says it is and is attempting to issue a peer commandu,utgt_typeuglobtpublish_validate(ufunuargutgturetutokuid(RRFR�R9tanyRiR�RlR�tpoptretmatchR�textendRRkRCt
auth_checkRJR5(RR�tpermsR�targ_targ((R�s//usr/lib/python2.7/site-packages/salt/master.pyt__verify_minion_publish�s@

"
	c�s�t�fd�|D��r tSd�krQtjd�dt�dd�tS|j�d�d�s�tjd�d�tSd�kr��jd�n�S(u�
        A utility function to perform common verification steps.

        :param dict load: A payload received from a minion
        :param list verify_keys: A list of strings that should be present in a
        given load

        :rtype: bool
        :rtype: dict
        :return: The original load (except for the token) if the load can be
        verified. False if the load is invalid.
        c3�s|]}|�kVqdS(N((R�R(RZ(s//usr/lib/python2.7/site-packages/salt/master.pys	<genexpr>@sutoku7Received incomplete call from %s for '%s', missing '%s'uiduco_nameu&Minion id %s is not who it says it is!(R�RFRlR�RR�R�R�(RRZtverify_keys((RZs//usr/lib/python2.7/site-packages/salt/master.pyt
__verify_load3s
cC�s8|j|d�}|tkr"iS|jj|dt�S(u�
        Return the results from an external node classifier if one is
        specified

        :param dict load: A payload received from a minion
        :return: The results from an external node classifier
        uidutoktskip_verify(uidutok(t_AESFuncs__verify_loadRFR#t_master_topsR5(RRZ((s//usr/lib/python2.7/site-packages/salt/master.pyR�Ss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(u�
        Return the master options to the minion

        :param dict load: A payload received from a minion

        :rtype: dict
        :return: The master options
        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�RRJ(RRZtmoptst
file_rootstenvstsaltenv((s//usr/lib/python2.7/site-packages/salt/master.pyt_master_optscs2	

cC�s<|j|d�}|tkr"iS|jj|dt�SdS(u�
        Gathers the data from the specified minions' mine

        :param dict load: A payload received from a minion

        :rtype: dict
        :return: Mine data from the specified minions
        uidutgtufunutokR�N(uidutgtufunutok(R�RFR#t	_mine_getR5(RRZ((s//usr/lib/python2.7/site-packages/salt/master.pyR��s	cC�s8|j|d�}|tkr"iS|jj|dt�S(u�
        Store the mine data

        :param dict load: A payload received from a minion

        :rtype: bool
        :return: True if the data has been stored in the mine
        uidudatautokR�(uidudatautok(R�RFR#t_mineR5(RRZ((s//usr/lib/python2.7/site-packages/salt/master.pyR��s	cC�s6|j|d�}|tkr"iS|jj|�SdS(u
        Allow the minion to delete a specific function from its own mine

        :param dict load: A payload received from a minion

        :rtype: bool
        :return: Boolean indicating whether or not the given function was deleted from the mine
        uidufunutokN(uidufunutok(R�RFR#t_mine_delete(RRZ((s//usr/lib/python2.7/site-packages/salt/master.pyR��s	cC�s<|j|d�}|tkr"iS|jj|dt�SdS(u�
        Allow the minion to delete all of its own mine contents

        :param dict load: A payload received from a minion
        uidutokR�N(uidutok(R�RFR#t_mine_flushR5(RRZ((s//usr/lib/python2.7/site-packages/salt/master.pyR��sc	�s�t�fd�dD��r tSt�dt�s7tS|jdsHtStjjj|j�d�sktSd|jd}d�kr��ddkr�t	j
d	�tSt�d
��jdd�|kr�t	j
d|�d�tSd�krt	j
d
�dt
�dd�tS|j�d�d�sMt	jd�d�iS�jd�tjj�d�}tjj|�}tjj|�s�d�dkr�tStjj|jdd�dd|�}tjj|�j|jd�st	jd|�tStjj|�}tjj|�sVytj|�WqVtj
k
rRqVXntjj|�r��ddkr�d}nd}tjjj||��E}�dr�|j�d�n|jtjj j!�d
��WdQXt"S(um
        Allows minions to send files to the master, files are sent to the
        master file cache
        c3�s|]}|�kVqdS(N((R�R(RZ(s//usr/lib/python2.7/site-packages/salt/master.pys	<genexpr>�suidupathulocu	file_recviufile_recv_max_sizeiu#Invalid file pointer: load[loc] < 0udatau�file_recv_max_size limit of %d MB exceeded! %s will be truncated. To successfully push this file, adjust file_recv_max_size to an integer (in MB) large enough to accommodate it.utoku7Received incomplete call from %s for '%s', missing '%s'uco_nameu&Minion id %s is not who it says it is!u../ucachediruminionsufilesudAttempt to write received file outside of master cache directory! Requested path: %s. Access denied.uabuwbN(uidupathuloci(#R�RFR�R�RRR=R]R�RlR�tlenRJRR�R�R�RetsepRhRgtnormpathtisabsRitdirnameR�tmakedirsRjR�tfopentseektwriteR�R�R5(	RRZtfile_recv_max_sizetsep_pathR�tcpathtcdirRdtfp_((RZs//usr/lib/python2.7/site-packages/salt/master.pyt
_file_recv�sn

&
"	
	""	
&c�s�t�fd�dD��r tStjjj|j�d�sCtS�d�dd<tjj|j�d�d�j	d�j	d��d�j	d�d�j	d	i�d
�j	d�d�j	d
��}|j
�}|jj�|jj	dt�r�|j
jjdj�d�di�dd6|d6�|jj	d�tkr�|jji�dd6t�ddd��q�n|S(u�
        Return the pillar data for the minion

        :param dict load: Minion payload

        :rtype: dict
        :return: The pillar data for the minion
        c3�s|]}|�kVqdS(N((R�R(RZ(s//usr/lib/python2.7/site-packages/salt/master.pys	<genexpr>suidugrainsusaltenvuenvtextuexttpillar_overrideupillar_overridet	pillarenvu	pillarenvtextra_minion_datauextra_minion_datauminion_data_cacheuminions/{0}udataupillaruminion_data_cache_eventsuMinion data cache refreshurefreshuminion(uidugrains(R�RFRR=R]R�RR�t
get_pillarRJtcompile_pillarR{tupdate_optsR#tcachetstoreR�R5RDR�R(RRZR�R�((RZs//usr/lib/python2.7/site-packages/salt/master.pyt_pillars0		
4cC�sC|j|d�}|tkr"iS|jj|�|j|�dS(u�
        Receive an event from the minion and fire it on the master event
        interface

        :param dict load: The minion payload
        uidutokN(uidutok(R�RFR#t
_minion_eventt_handle_minion_event(RRZ((s//usr/lib/python2.7/site-packages/salt/master.pyR�4s
c	C�s|d}|jdd�dkr@tjd||dd�nx�|jdg�D]�}|jdi�}d	|krS|jd
�}|s�qSn|d	}y/tjjj|j||d|jd|�Wqt	tj
jfk
r}tjd
|||�qXqSqSWdS(u5
        Act on specific events from minions
        uidutaguu_salt_erroru#Received minion error from [%s]: %sudataumessageueventsuminionsujidRxt	syndic_idu)Could not add minion(s) %s for job %s: %sN(RJRlR�RR=tjobt
store_minionsRRxR�R�tSaltCacheError(RRZR�RDt
event_datatjidRAR�((s//usr/lib/python2.7/site-packages/salt/master.pyR�Cs.

	cC�sb|jdr1d|kr1tjd|d�tSd|krtjd�|jd�}tjj|jddj	|d��}t
jjj
|�}t
jj|||�s�tjd|d�|jd	r�tjd
|d�tStjd�n||d<ny/t
jjj|j|d|jd
|j�Wn't
jjk
r]tjd|�nXdS(uU
        Handle the return data sent from the minions.

        Takes the return, verifies it and fires it on the master event bus.
        Typically, this event is consumed by the Salt CLI waiting on the other
        end of the event bus but could be heard by any listener on the bus.

        :param dict load: The minion payload
        urequire_minion_sign_messagesusiguo_return: Master is requiring minions to sign their messages, but there is no signature in this payload from %s.uidu*Verifying signed event publish from minionupki_diruminions/{0}u0Failed to verify event signature from minion %s.udrop_messages_signature_failuADrop_messages_signature_fail is enabled, dropping message from %suLBut 'drop_message_signature_fail' is disabled, so message is still accepted.RDRxu,Could not store job information for load: %sN(RRlR�RFRaR�ReRgRhR�Rtserializerstmsgpackt	serializeRtverify_signatureR�R=R�t	store_jobRDRxR�R�R�(RRZtsigtthis_minion_pubkeytserialized_load((s//usr/lib/python2.7/site-packages/salt/master.pyt_returnbs0

)

#c
�s-�jd�}t|t�s*�g}nx�|D]��t�fd�dD��rYq1n�jd�r�dj|jd�}|jj|�d�d�ntj	j
|jdd	�d�}tj	j|�s>tj	j|�d
}tj	j|�s
tj
|�ntjjj|d��}|jd�Wd
QXnx�tj�d�D]�\}}i�dd6|d6}	|	j|�d�kr��d|	d<nd�kr��d|	d<nd�kr��d|	d<nd�kr��d|	d<nd�kr�d|	d<n|j|	�qRWq1Wd
S(u�
        Receive a syndic minion return and format it to look like returns from
        individual minions.

        :param dict load: The minion payload
        uloadc3�s|]}|�kVqdS(N((R�R(RZ(s//usr/lib/python2.7/site-packages/salt/master.pys	<genexpr>�sureturnujiduidu
{0}.save_loadumaster_job_cacheucachedirusyndicsiuwuNu	master_idufunuargufun_argsuoutusig(ureturnujiduid(RJR�R�R�R�RRxR7ReRgRhtexistsRR�RR=R�R�R�RR�R�R�(
RRZtloadsR�tsyndic_cache_patht	path_nametwfhRR,R[((RZs//usr/lib/python2.7/site-packages/salt/master.pyt_syndic_return�s>
"# 

cC�s6|j|d�}|tkr"iS|jj|�SdS(u�
        Execute a runner from a minion, return the runner's function data

        :param dict clear_load: The minion payload

        :rtype: dict
        :return: The runner function data
        ufunuarguidutokN(ufunuarguidutok(R�RFR#t
minion_runner(RR�RZ((s//usr/lib/python2.7/site-packages/salt/master.pyR��s	cC�s�|j|d�}|tkr"iStjj|jdd�}tjj|�s`tj|�ntjj|tj	|d��}t
jjj
|d��!}|d|j�ks�iSWdQX|jj|d�S(	u	
        Request the return data from a specific jid, only allowed
        if the requesting minion also initialted the execution.

        :param dict load: The minion payload

        :rtype: dict
        :return: Return data corresponding to a given JID
        ujiduidutokucachedirupublish_authurN(ujiduidutok(R�RFReRgRhRR�R�Rt	text_typeRR=R�R�treadRutget_cache_returns(RRZt
auth_cachetjid_fnR�((s//usr/lib/python2.7/site-packages/salt/master.pytpub_ret�s
	
	"
cC�s'|j|�siS|jj|�SdS(uL
        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:

        .. code-block:: bash

            peer:
                .*:
                    - .*

        This configuration will enable all minions to execute all commands:

        .. code-block:: bash

            peer:
                foo.example.com:
                    - test.*

        The above configuration will only allow the minion foo.example.com to
        execute commands from the test module.

        :param dict clear_load: The minion pay
        N(t _AESFuncs__verify_minion_publishR#t
minion_pub(RR�((s//usr/lib/python2.7/site-packages/salt/master.pyR��scC�s'|j|�siS|jj|�SdS(uD
        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:

        .. code-block:: bash

            peer:
                .*:
                    - .*

        This configuration will enable all minions to execute all commands.
        peer:

        .. code-block:: bash

            foo.example.com:
                - test.*

        The above configuration will only allow the minion foo.example.com to
        execute commands from the test module.

        :param dict clear_load: The minion payload
        N(R�R#tminion_publish(RR�((s//usr/lib/python2.7/site-packages/salt/master.pyR�scC�sc|j|d�}|jjdt�s?tjd|d�|S|tkrO|S|jj|�SdS(u2
        Allow a minion to request revocation of its own key

        :param dict load: The minion payload

        :rtype: dict
        :return: If the load is invalid, it may be returned. No key operation is performed.

        :rtype: bool
        :return: True if key was revoked, False if not
        uidutokuallow_minion_key_revokeuKMinion %s requested key revoke, but allow_minion_key_revoke is set to FalseN(uidutok(R�RRJRFRlR�R#trevoke_auth(RRZ((s//usr/lib/python2.7/site-packages/salt/master.pyR�'scC�sg|jd�r iidd6fSt||�r�yBtj�}t||�|�}tjd|tj�|�Wq�tk
r�d}tjd|dt�q�Xn!tjd|�t	idd6fS|d	kr�|idd6fS|d
krVd|krV|j
d�d
kr3|jddkr3|idd6fS|idd6dd6|dd6fS|idd6fS(u�
        Wrapper for running functions executed with AES encryption

        :param function func: The function to run
        :return: The result of the master function that was called
        u__usendufunu'Master function call %s took %s secondsuuError in function %s:
R�uHReceived function %s which is unavailable on the master, returning Falseu_returnu_pillaruiduveru2upillar_versioniusend_privateupillarukeyutgt(RiRDR-RKRlRaR�R�R5RFRJR(RtfuncRZR�R[((s//usr/lib/python2.7/site-packages/salt/master.pyReAs.
(#(u
verify_minionu_master_topsu
_ext_nodesu_master_optsu	_mine_getu_mineu_mine_deleteu_mine_flushu
_file_recvu_pillaru
_minion_eventu_handle_minion_eventu_returnu_syndic_returnu
minion_runnerupub_retu
minion_pubuminion_publishurevoke_authu_serve_fileu
_file_findu
_file_hashu_file_hash_and_statu
_file_listu_file_list_emptydirsu	_dir_listu
_symlink_listu
_file_envs(R&R'R(RnRRyR�R�R�R�R�t
_ext_nodesR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�Re(((s//usr/lib/python2.7/site-packages/salt/master.pyRi�sB			&	
	4	 		#					S	#			)	-			#	#	RhcB�s�eZdZdZd�Zd�Zd	�Zd
�Zd�Zd�Z	d
�Z
d�Zd�Ze
d��Zed�Zd�Zd�ZRS(u~
    Set up functions that are safe to execute when commands sent to the master
    without encryption and authentication
    upingupublishu	get_tokenumk_tokenuwheelurunnercC�s�||_||_tjjj|j|jddt�|_tjj|jd�|_	tjj
j|�|_tj
j|�|_tjj|jdtdtdt�|_tjj|�|_tjjj||�|_dS(Nusock_dirR8u	conf_fileRpRqRr(RRRR=RDRERFRsRtRuRARBRCtauthtLoadAuthtloadauthRvRwR5RxtwheeltWheeltwheel_R"R#t
LocalFuncs(RRR((s//usr/lib/python2.7/site-packages/salt/master.pyR{s		+		cC�s|j|�\}}}}|jj||d|�}|jd�}|rVi|d6S|jd�}|dkr|jj|jdg�|d|jdi��}	|	s�ii|d6d	j||�d
6d6St|	t�r�d|	kr�|	Sx||D]}
|j	|
d�q�Wn[d|kr\|d}tjj
|�j�rn|jjdd�}qnntjjj�}yG|j	d�}tjj|j�}|j||jdi�|�SWnUtk
r}
tjd||
�ii|
jjd6|
jd
6tj|
�d
6d6SXdS(uJ
        Send a master control function back to the runner system
        Ruerroruusernameuuseru	auth_listufunukwargunameu;Authentication failure of type "{0}" occurred for user {1}.umessageurootu-Exception occurred while introspecting %s: %suargsN(t_prep_auth_infoR�tcheck_authenticationRJRCtrunner_checkR�R�R9R�R�RR�tAuthUsertis_sudoRR=R�R�R:R;tasynchronousR�RlR�RSR&R�RR�(RR�t	auth_typeterr_nameRtsensitive_load_keysR�R�tusernameR�R,tfunRLR�((s//usr/lib/python2.7/site-packages/salt/master.pyR:�sF	


	
cC�s�|j|�\}}}}|jj||d|�}|jd�}|rVi|d6S|jd�}|dkr|jj|jdg�|d|jdi��}	|	s�ii|d6d	j||�d
6d6St|	t�r�d|	kr�|	Sx||D]}
|j	|
d�q�Wn[d|kr\|d}tjj
|�j�rn|jjdd�}qnntjjj�}y�tjjj|j�}|j	d�}t|dd
�}
idj|�d6|d6|
d6|d6}|jj|t|dgd
��|jj|dt|�}|d|d<|d|d<|jj|t|dgd
��i|
d6|d6SWn�tk
r�}tjd||�dj||jj|�|d<t |d<|jj|t|dgd
��i|
d6|d6SXdS(uI
        Send a master control function back to the wheel system
        Ruerroruusernameuuseru	auth_listufunukwargunameu;Authentication failure of type "{0}" occurred for user {1}.umessageuroottprefixuwheelu	wheel.{0}ujidutagunewtfull_returnureturnusuccessuretudatau-Exception occurred while introspecting %s: %su)Exception occurred in wheel {0}: {1}: {2}N(!R�R�R�RJRCtwheel_checkR�R�R9R�R�RR�R�R�RR=R�R�R�tgen_jidRRDR�R�t	call_funcR5R�RlR�RSR&RF(RR�R�RRRR�R�RRR,R�RRvR�R[R�((s//usr/lib/python2.7/site-packages/salt/master.pyR��sb	



""
	

"
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(R�tmk_tokenRlR�(RR�R�((s//usr/lib/python2.7/site-packages/salt/master.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(RFR�tget_tok(RR�((s//usr/lib/python2.7/site-packages/salt/master.pyt	get_tokens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�|�}|jdt��}|jdt��}|jdt
�}|j|�\}	}
}}|	dkrL|jj||	d|�}
n|jj||	�}
|
jdg�}dj|	�}|
jd
�r�tj|�iidd6dd	6d
6S|	dks�|	dkr�|r�|j
j||d|d|d|jd
d�d|ddg�}|s�|	dkri|rid|krid|kritjd|d|d�ntj|�iidd6dd	6d
6S|	dkr�|
jd�}||d<tjd|�q�|	dkr�|jj|�|d<q�n|jjd �s>|s>id!d"6id(d#6|d6d$j|d�d
6d%6Sn|j||�}|d(kruid!d"6id&d
6d%6S|j|||||�}|j|d'|�|j|�id!d"6i|d#d#6|d6|d6d%6S()ut
        This method sends out publications to the minions, it can only be used
        by the LocalClient.
        ukwargsupublisher_acl_blacklistuuserufunuq%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_typeuglobuminionsumissingussh_minionsRu	auth_listu.Authentication failure of type "{0}" occurred.uAuthenticationErroruAuthentication error occurred.uargRAt	whitelistusaltutil.find_jobueauthuusernameu8Auth configuration for eauth "%s" and user "%s" is emptyutokenuMinion tokenized user = "%s"u
order_mastersuclearuencujidu/Master could not resolve minions for target {0}uloaduMaster failed to assign jidtssh_minionsN(RJRtacltPublisherACLRtuser_is_blacklistedtcmd_is_blacklistedRlR�RRCt
check_minionsR�RFR�R�R�R�R�R�Rmt	load_nameR�t	_prep_jidt	_prep_pubt
_send_ssh_pubt	_send_pub(RR�textrat
publisher_aclt	delimitert_resRAtmissingR
R�RRRR�t	auth_listterr_msgt
authorizedRR�R/((s//usr/lib/python2.7/site-packages/salt/master.pytpublish#s�
		

	+




cC�s|g}d}d|kr0d}d}dg}n<d|krWd}d}ddg}nd}d}|j}||||fS(	NutokenuTokenAuthenticationErrorueauthuEauthAuthenticationErroruusernameupassworduuseruUserAuthenticationError(R�R(RR�RRR�R((s//usr/lib/python2.7/site-packages/salt/master.pyR��s	cC�s�|jd�r|dnd}|jdt�}dj|jd�}y#|jj|d|d|�}WnHttfk
r�dj|j	d�d	�}t
j|�i|d
6SX|S(u3
        Return a jid for this publication
        ujidunocacheu{0}.prep_jidumaster_job_cachetnocachet
passed_jiduKFailed to allocate a jid. The requested returner '{0}' could not be loaded.u.iuerrorN(RJR�RFR�RRxR7R�R�RRlR�(RR�RR"R!R�R�tmsg((s//usr/lib/python2.7/site-packages/salt/master.pyR�s

cC�sIxBt|j�D]1\}}tjjjj|�}|j|�qWdS(uQ
        Take a load and send it across the network to connected minions
        N(RRRRNRRRR (RRZRNRR*((s//usr/lib/python2.7/site-packages/salt/master.pyR�scC�s:t|d�s3tjjjjd|j�|_n|jS(Nu_ssh_clientR�(RDRRstssht	SSHClientRt_ssh_client(R((s//usr/lib/python2.7/site-packages/salt/master.pyt
ssh_client�s$cC�sU|jdtkrQ|tkrQtjd�tjd|jjd|�j�ndS(uK
        Take a load and send it across the network to ssh minions
        uenable_ssh_minionsuSend payload to ssh minionsR�R2N(	RR5RlRmR�R�R'R]R�(RRZR
((s//usr/lib/python2.7/site-packages/salt/master.pyR�s
c
C�s�||d<|jdi�jdt�}|jji|d6|d�i|dd6|dd6|dd6|dd6|dd6|d	d	6|d6|d
6}|jj|t|ddgd��|jd
r�dj|jd
�}t}	yLtj	j
j|jj
|�}
d|
j
kr6tjd|jd
�nWn4ttfk
rmt}	tjd|jd
�nX|	r�y%|jj
||d|d|�Wq�tk
r�tjddt�q�Xq�ny8dj|jd�}|jj
||d||�WnKtk
r(tjd|jd�n$tk
rKtjddt�nXidd6}i|dd6|d	d	6|dd6|dd6|dd6}d|jkr�|jd|d<nd|kr�|d|d<n|tkr�||d<nd|kr|d|d<nd|kr)|d|d<nd|krF|d|d<nd|kr'd|dkr||djd�|d<nd|dkr�|djd�|d<nd|dkr�|djd�|d<nd|dkr�|djd�|d<nd |dkr'|djd �|d <q'nd|krftjd!|d|d|d�|d|d<ntjd"|d|d�tjd#|�|S($u�
        Take a given load and perform the necessary steps
        to prepare a publication.

        TODO: This is really only bound by temporal cohesion
        and thus should be refactored even further.
        ujidukwargsu	delimiteruminionsutgt_typeutgtuuserufunuargumissingunewujobu
ext_job_cacheu
{0}.save_loadu�The specified returner used for the external job cache '%s' does not have a 'minions' kwarg in the returner's save_load function.u_The specified returner used for the external job cache "%s" does not have a save_load function!RAu,The specified returner threw a stack trace:
R�umaster_job_cacheu]The specified returner used for the master job cache "%s" does not have a save_load function!uaesuencuretu	master_iduidutou
ret_configumetadataumodule_executorsu
executor_optsu
ret_kwargsu(User %s Published command %s with jid %su Published command %s with jid %suPublished command details %s(RJRRDR�RRR�R5RR=R�tget_function_argspecRxR7RlR�RoR�RFR�R�Rm(
RRAR�R�RRRtnew_job_loadR�tsave_load_functarg_specR/RZ((s//usr/lib/python2.7/site-packages/salt/master.pyR�s�

&
%
"


	
cC�s|S(u3
        Send the load back to the sender.
        ((RR�((s//usr/lib/python2.7/site-packages/salt/master.pytping]	s(upingupublishu	get_tokenumk_tokenuwheelurunner(R&R'R(RnRR:R�R	RR R�RRtpropertyR'RFRRR,(((s//usr/lib/python2.7/site-packages/salt/master.pyRhks		7	G			n				�t
FloMWorkercB�s)eZdZd�Zd�Zd�ZRS(u6
    Change the run and bind to be ioflo friendly
    cC�stj|||�dS(N(R?R(RRR((s//usr/lib/python2.7/site-packages/salt/master.pyRh	scC�s2tjjj|jj�tjj|j|j	�|_
tjj|j�|_t
jd�|_|jjt
j�|_|jjdd�dkr�dj|jjdd��|_n(djtjj|jd	d
��|_tjd|j�t
j�|_|jj|jt
j�|jj|j�dS(
uR
        Prepare the needed objects and socket for iteration within ioflo
        iuipc_modeuutcputcp://127.0.0.1:{0}utcp_master_workersi�u	ipc://{0}usock_diruworkers.ipcuZMQ Worker binding to socket %sN(RR=RRRRSR&R�RhRRRbRiR\RtContexttcontexttsockettREPRJR�tw_uriReRgRhRlR�tPollertpollertregistertPOLLINtconnect(R((s//usr/lib/python2.7/site-packages/salt/master.pyRn	s 	"cC�s�yu|jjd�}|rt|jj�}|j�|jj|�}|jj|j|��}|jj	|�nWnNt
k
r��n;tk
r�}t|t
j�r�|jtjkr�dSnXdS(u)
        Handle a single request
        iN(R5tpollR1trecvt_update_aesR1R�tdumpsRQtsendRRR�R�RtZMQErrorterrnotEINTR(RtpolledtpackageR/R[R�((s//usr/lib/python2.7/site-packages/salt/master.pythandle_request�	s

$(R&R'R(RRRC(((s//usr/lib/python2.7/site-packages/salt/master.pyR.d	s		(oR(t
__future__RRRRR�RRfReR�R�R-R?RRwtloggingRHRR�tsalt.serializers.msgpackRtsalt.extRtsalt.ext.six.movesRtsalt.utils.zeromqRRRR	ttornado.genRWt
salt.crypttsalt.clienttsalt.client.ssh.clienttsalt.exceptionstsalt.payloadtsalt.pillart
salt.statetsalt.runnert	salt.autht
salt.wheeltsalt.miniontsalt.keytsalt.acltsalt.enginestsalt.daemons.masterapitsalt.defaults.exitcodestsalt.transport.servertsalt.log.setuptsalt.utils.argstsalt.utils.atomicfiletsalt.utils.crypttsalt.utils.eventtsalt.utils.filestsalt.utils.gitfstsalt.utils.gzip_utiltsalt.utils.jidtsalt.utils.jobtsalt.utils.mastertsalt.utils.minionstsalt.utils.platformtsalt.utils.processtsalt.utils.scheduletsalt.utils.ssdptsalt.utils.stringutilstsalt.utils.usertsalt.utils.verifytsalt.configR
t
salt.defaultsRtsalt.transportRtsalt.utils.debugR
RRRtsalt.utils.odictRR�R5R�tImportErrorRFR8Rttornado.stack_contextRtsalt.utils.ctxRt	getLoggerR&RltobjectRR=RQt$SignalHandlingMultiprocessingProcessR)R�R�RR R?RmRiRhR.(((s//usr/lib/python2.7/site-packages/salt/master.pyt<module>s�""





)��� '�������

Zerion Mini Shell 1.0