%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@�s�dZddlmZmZmZmZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddl
mZmZddlmZddlZddlmZddlmZddlmZdd	lm Z dd
l!m"Z"ddl#m$Z$m%Z%m&Z&m'Z'ddl(Zddl)Zddl*m+Z+ddl,Z,e-Z.yddl/j0j1Z2e3Z.Wne4k
r�nXe-Z5yddl6Z6e3Z5Wne4k
rnXyddl7Z$e3Z8Wne4k
r1e-Z8nXyddl9Ze3Z:Wne4k
rae-Z:nXddlZddl;Zddl<Zddl=Zddl>Zddl?Zddl@ZddlAZddlBZddlCZddlDZddlEZddlFZddlGZddlHZddlIZddlJZddlKZddlZddlLZddlMZddlNZddlOZddlPZddl#Zddl)ZddlQZddlRZddlSZdd
lTmUZUddlVmWZWddlXmYZYddlGmZZZddl[m\Z\ddlMm]Z]m^Z^m_Z_ddl`maZambZbmcZcmdZdmeZemfZfmgZgmhZhmiZiddljZ,ddlkZ,ejlem�Zne3d�Zod�Zpd�Zqere-d�Zsd�Zterd�Zud�Zvdewfd��YZxdexfd��YZydewfd ��YZzd!exfd"��YZ{d#exfd$��YZ|d%e|fd&��YZ}d'exfd(��YZ~d)e{fd*��YZd+�Z�d,e|fd-��YZ�d.eyfd/��YZ�dS(0u
Routines to set up a minion
i(tabsolute_importtprint_functiontwith_statementtunicode_literalsN(trandinttshuffle(tS_IMODE(tcrc32(tsix(t	ipaddress(tparse_host_port(trange(tzmqtZMQDefaultLooptinstall_zmqtZMQ_VERSION_INFO(tRequestContext(tDEFAULT_MINION_OPTS(tDEFAULT_TARGET_DELIM(tenable_sigusr1_handler(ttagify(tOrderedDict(tdefault_signalst$SignalHandlingMultiprocessingProcesstProcessManager(	tCommandExecutionErrortCommandNotFoundErrortSaltInvocationErrortSaltReqTimeoutErrortSaltClientErrortSaltSystemExittSaltDaemonNotRunningt
SaltExceptiontSaltMasterUnresolvableErrorcC�s�i}t}|jdd�dkr@|jdt�r@t}nddl}|tkr~yQ|ddkrtt�n|jjj|dt|d	�t|d
�|d<Wq�t	k
r�|jdd�}|d
r�x
tr�|dk	r|dkr�t�n|d8}nddl}dj
|d|d
�}|jjj�rTtj|�ntdj
|��tj|d
�y9|jjj|dt|d	�t|d
�|d<PWq�t	k
r�q�Xq�Wq{|r�d|d<q{�q�tk
rzd}|jd|�}|dkr|}n|jd�dkrFdj
|�}	ndj
|�}	tj|	�tddd|	��q�Xn
d|d<d|kr�d|kr�|d|dkr�tjd|d|d�q�n|dr�tjd|d�|jjj�}
tjd�tj|
�|d|
kr�|
|ddr�|d
s]|
|ddn|
|dd }|dd!|d"<tjd#|d"�q�tjd$|d�qtjd%|d�nU|d&r|jjj|d&t|d'�t|d
�|d"<tjd#|d"�n|d'rPt|d'�|d'<tjd(|d'�n|d)r�t|d)�|d)<tjd*|d)�nd+j
d,|dd-|d	�|d.<tjd/|d.�|S(0u7
    Resolves the master_ip and master_uri options
    ufile_clienturemoteulocaluuse_master_when_localiNumasteruumaster_portuipv6u	master_ipuretry_dns_countu	retry_dnsiuKMaster hostname: '{0}' not found or not responsive. Retrying in {1} secondsuWARNING: {0}u	127.0.0.1uunknown addressu__roleusyndicuzMaster address: '{0}' could not be resolved. Invalid or unresolveable address. Set 'syndic_master' value in minion config.usMaster address: '{0}' could not be resolved. Invalid or unresolveable address. Set 'master' value in minion config.tcodei*tmsgu'Master ip address changed from %s to %susource_interface_nameu$Custom source interface required: %su6The following interfaces are available on this Minion:uupuinetuinet6uaddressu	source_ipuUsing %s as source IP addressuPThe interface %s is down so it cannot be used as source to connect to the Masteru&%s is not a valid interface. Ignoring.usource_addressusource_ret_portu*Using %d as source port for the ret serverusource_publish_portu*Using %d as source port for the master pubutcp://{ip}:{port}tiptportu
master_uriuMaster URI: %s(tTruetgettFalsetsalt.utils.networkRtutilstnetworkt	dns_checktintRtNoneR!tsalt.logtformattlogtsetuptis_console_configuredterrortprintttimetsleeptwarningttracet
interfacestdebug(toptstfallbacktrett	check_dnstsalttretry_dns_countR#tunknown_strtmasterterrR:taddrs((s//usr/lib/python2.7/site-packages/salt/minion.pytresolve_dns�s�		


		




		




	



	cC�sti}|ddkr0tj|d�|d<n@t|d�\}}i|d6}|rp|ji|d6�n|S(u
    parse host:port values from opts['master'] and return valid:
        master: ip address or hostname as a string
        master_port: (optional) master returner port as integer

    e.g.:
      - master: 'localhost:1234' -> {'master': 'localhost', 'master_port': 1234}
      - master: '127.0.0.1:1234' -> {'master': '127.0.0.1', 'master_port' :1234}
      - master: '[::1]:1234' -> {'master': '::1', 'master_port': 1234}
      - master: 'fe80::a00:27ff:fedc:ba98' -> {'master': 'fe80::a00:27ff:fedc:ba98'}
    umaster_uri_formatuip_onlyumasterumaster_port(R	t
ip_addressR
tupdate(R<R>thostR%((s//usr/lib/python2.7/site-packages/salt/minion.pytprep_ip_port�s
c	K�s`tjj|d�}|jdd�}|dkr<i}n
i|d6}tjj|�sntj||�ntj|�}|r�t|j	�}||dkr�tj
||j	|A|dB�q�nttd�r\|jdd�}|jdd�}|j|ks|j
|kr\g||fD]}|dkr%|^q%r\tj|||�q\n|S(u�
    Given the cache directory, return the directory that process data is
    stored in, creating it if it doesn't exist.
    The following optional Keyword Arguments are handled:

    mode: which is anything os.makedir would accept as mode.

    uid: the uid to set, if not set, or it is None or -1 no changes are
         made. Same applies if the directory is already owned by this
         uid. Must be int. Works only on unix/unix like systems.

    gid: the gid to set, if not set, or it is None or -1 no changes are
         made. Same applies if the directory is already owned by this
         gid. Must be int. Works only on unix/unix like systems.
    uprocumodeuchownuuidi����ugidN(tostpathtjointpopR.tisdirtmakedirststatRtst_modetchmodthasattrtst_uidtst_gidtchown(	tcachedirtkwargstfn_tmodetd_statt	mode_parttuidtgidti((s//usr/lib/python2.7/site-packages/salt/minion.pytget_proc_dirs&	
%+cC�s�tjjj|�}g}i}g}xA|D]9}t|t�r�|jdt�tkr�x[t	j
|�D]J\}	}
|js�|	|jkr�|
||	<qk|jdj
|	|
��qkWq.q.tjjj|gdt�d}|rZ|jstt	j|��|jkr|j|�qgxFt	j
|�D]%\}	}
|jdj
|	|
��q.Wq.|j|�q.W|r�|r�tjjj|�n|jr�t|t�r�x3t	j
|�D]\}	}
|
|dj
|	�<q�Wn||fS(u{
    Detect the args and kwargs that need to be passed to a function call, and
    check them against what was passed.
    u	__kwarg__u{0}={1}t	conditioniu	__pub_{0}(R@R*targstget_function_argspect
isinstancetdictRNR(R&Rt	iteritemstkeywordstappendR0tparse_inputtnexttiterkeysRHtinvalid_kwargs(tfuncRctdatatignore_invalidtargspect_argst_kwargsRmtargtkeytvaltstring_kwarg((s//usr/lib/python2.7/site-packages/salt/minion.pytload_args_and_kwargs?s0
'
"' 
cC�s$d|kr |d}|jd�\}}yktjj|||�}|sUt�n||�|d<t|dtjtf�s�t	�nt
|d<Wnttk
r�tjd|�t
jtjjj�n>t	k
rtjd|d|�t
jtjjj�nXtjd|�ndS(ud
    Evaluate master function if master type is 'func'
    and save it result in opts['master']
    u__master_func_evaluatedumasteru.uFailed to load module %su#%s returned from %s is not a stringu Evaluated master from module: %sN(tsplitR@tloadertraw_modtKeyErrorReRtstring_typestlistt	TypeErrorR&R1R4tsystexittdefaultst	exitcodest
EX_GENERICtinfo(R<tmod_funtmodtfunt
master_mod((s//usr/lib/python2.7/site-packages/salt/minion.pyteval_master_funcss$
		

cC�scidd6dd6dd6dd6}|dkrS|d
k	rSd	j|j|�|�S|j|d
�S(u[
    Centralized master event function which will return event type based on event_map
    u__master_connectedu	connectedu__master_disconnectedudisconnectedu__master_failbackufailbacku__master_aliveualiveu{0}_{1}N(R.R0R'(ttypeRCt	event_map((s//usr/lib/python2.7/site-packages/salt/minion.pytmaster_event�s

cC�sdtjkrdSdS(u:
    Return the proper service name based on platform
    ubsdusalt_minionusalt-minion(R�tplatform(((s//usr/lib/python2.7/site-packages/salt/minion.pytservice_name�st
MinionBasecB�sheZd�Zed�Zed��Zd�Zej	j
deeed��Zd�Z
d�ZRS(cC�s"||_|jdt�|_dS(Nubeacons_leader(R<R'R&tbeacons_leader(tselfR<((s//usr/lib/python2.7/site-packages/salt/minion.pyt__init__�s	cC�s�|r[tjj|j|jd|jd|jdd|jjd��j�|jd<ntjj|j�|_tjj|jd|j�|_	tjj
|j�|_
tjj|j|j	�|_tjj|j|j	|jd	�|_i|_tjj|j|j	|j|j
�|_tjj|j|j	�|_tjj|j�|_|j|j	d<tjj|j|j	�|_d	S(
u�
        Tell the minion to reload the execution modules

        CLI Example:

        .. code-block:: bash

            salt '*' sys.reload_modules
        ugrainsuidusaltenvt	pillarenvu	pillarenvupillarR*usys.reload_modulesN(R@tpillart
get_pillarR<R'tcompile_pillarRzR*tminion_modst	functionstserializerst	returnerstproxyR.tfunction_errorststatestrendertrendtmatcherstgen_modulest	executors(R�tinitial_load((s//usr/lib/python2.7/site-packages/salt/minion.pyR��s*
	


%!'	cC�s�ybt|d�r"|jj�ntjd�dS|jj|kra|jj}tjd�nWn#tk
r�}tjd|�nX|S(NuscheduleuAMinion scheduler not initialized. Scheduled jobs will not be run.u3Overriding loop_interval because of scheduled jobs.u&Exception %s occurred in scheduled job(RTtscheduletevalR1R4t
loop_intervalR;t	Exception(tminionR�texc((s//usr/lib/python2.7/site-packages/salt/minion.pytprocess_schedule�s
cC�sSd|krO|dd|jddt�}|rO|jj||jd�SngS(u|
        Evaluate all of the configured beacons, grab the config again in case
        the pillar or grains changed
        uconfig.mergeubeaconst	omit_optsugrains(R<R&tbeaconstprocess(R�R�tb_conf((s//usr/lib/python2.7/site-packages/salt/minion.pytprocess_beacons�s
 i<c
c�s�|ddkr;tjd�t|_tjjd6��n|j�|ddkr�|ddkr�|ddkr�t	|�q�|dd7kr�t
|d
t�rtjd|d
�|dd	kr�t
|d
�}|dkr�|d
d}t|d
�|}ys|d
}	|d
||	d<g|d
D]}
|
|	dkr1|
^q1|	d)|	|d
<tjd|d
d�Wq�tttfk
r�tjd�q�Xq�tjd�n|dr�tjd�|d|d<nd|d<|drU|ddkrU|d|d<qUn>t
|d
tj�rMd|krM|d
g|d
<n|ddkrttjd|d
�n�|r|r�|d|d
<qUtjd|d
�|d
|dkr|d
}g|dD]}|d
|kr�|^q�|d
<|d
j|�qU|d|d
<n<djt|d
��}
tj|
�tjtjjj�|dr�|ddkr�d}
tj|
�d|d<q�q�d j|d�}
tj|
�tjtjjj�ni|d!6|d"6}t|d#d5�r|j |d#<n|j!d$d�}d}t
|d
t�rt}d5}g|d%<t"j"|d
�|d<|dr�|ddkr�|dr�|dd}t#|�||dd)q�t#|d�nxJ|dD]>}||d
<|j$t%|��|d%jt&|�d&�q�Wx�t'r|dkr1tjj(|d'�Vn|d7}|dkr]tj)d(||�ntj)d)|�x|dD]�}||d
<|j$t%|��|j$t&|��d|kr�t"j"|d�|d<n||_*tj+j,j-j.||�}y|j/�Vt'}PWqxt0k
rq}|}|j1j2d*�rNd+|d
|f}
nd,|d
f}
tj|
�qxqxXqxW|s�||krt|_t"j"|j*d�|j*d
<tjd-�|�qq|j3j4d.�|_5t'|_tjj|d
|f��qWn�|dr"tjd/�nx�t'r�|dkrOtjj(|d'�Vn|d7}|dkr{tj)d(||�ntj)d)|�|j$t%|��|j$t&|��y|j*d0d1krTt'|j*d2<x�d8D]r}|d3kr�t6r�q�n||j*d0<tj+j,j-j.|j*|�}|j/�V|j3j7sBq�n|j*d2=Pq�Wn)tj+j,j-j.|j*|�}|j/�V|j3j4d.�|_5t'|_tjj|d
|f��Wq%t0k
r�}||kr�t|_|�q�q%Xq%Wd5S(9u
        Evaluates and returns a tuple of the current master address and the pub_channel.

        In standard mode, just creates a pub_channel with the given master address.

        With master_type=func evaluates the current master address from the given
        module and then creates a pub_channel.

        With master_type=failover takes the list of masters and loops through them.
        The first one that allows the minion to create a pub_channel is then
        returned. If this function is called outside the minions initialization
        phase (for example from the minions main event-loop when a master connection
        loss was detected), 'failed' should be set to True. The current
        (possibly failed) master will then be removed from the list of masters.
        umaster_typeudisableu-Master is set to disable, skipping connectionustru__roleusyndicufuncufailoverudistributedumasteru*Got list of available master addresses: %siuidiu"Distributed to the master at '%s'.u*Failed to distribute to a specific master.u3master_type = distributed needs more than 1 master.umaster_shuffleu�Use of 'master_shuffle' detected. 'master_shuffle' is deprecated in favor of 'random_master'. Please update your minion config file.u
random_masteru
auth_triesumaster_failbackumaster_failback_intervalumaster_alive_intervalumaster_listu$Syndic setting master_syndic to '%s'uBMoving possibly failed master %s to the end of the list of mastersu
local_mastersuNmaster_type set to 'failover' but 'master' is not of type list but of type {0}u	retry_dnsu�'master_type' set to 'failover' but 'retry_dns' is not 0. Setting 'retry_dns' to 0 to failover to the next master on DNS errors.u0Invalid keyword '{0}' for variable 'master_type'utimeoutusafeuio_loopumaster_triesumaster_uri_listu
master_uriuacceptance_wait_timeu&Connecting to master. Attempt %s of %su4Connecting to master. Attempt %s (infinite attempts)uCould not accessu\Failed to initiate connection with Master %s: check ownership/permissions. Error message: %su@Master %s could not be reached, trying next next master (if any)uQNo master could be reached or all masters denied the minion's connection attempt.R@uGrandom_master is True but there is only one master specified. Ignoring.u	transportudetectudetect_modeuzeromqutcpN(NN(ufailoverudistributed(uzeromqutcp(8R1R8R(t	connectedttornadotgentReturnR.t_discover_mastersR�ReR~R�tlenRR|tAttributeErrorRRR}RiR0R�R4R�R�R@R�R�R�tcriticaltgetattrtio_loopR'tcopyRRHRJRFR&R7R;R<t	transporttclienttAsyncPubChanneltfactorytconnectRtstrerrort
startswithtautht	gen_tokenttokRt
authenticated(R�R<ttimeouttsafetfailedtfailbackt
master_lentsecondary_masterst
master_idxtpreferred_masterstmt
failed_mastertxR#tfactory_kwargsttriestattemptstconntlast_excRCtpub_channelR�ttrans((s//usr/lib/python2.7/site-packages/salt/minion.pyteval_master�s@
	
 

1


"
1







	


	

		#
	





	 	c
	C�s|jdtdkr|jdtk	rtjjj�}i}x�t|jdjdd��D]�}y[|d7}t	j
d|�|j|j��|s�t
j|jdjdd��nPWqbtk
r�}t	jd	|�PqbXqbW|r|jjdi�jd
d�}|dkr4t	jd
|�q	|jdjdi�}x�|j�D]�\}}x�|D]�}	tg|j�D]3\}
}|	jdi�j|
�|kr�|
^q��}|dkr�t|�s�|t|�krm|	d|jd<dSqmWqZWqndS(u�
        Discover master(s) and decide where to connect, if SSDP is around.
        This modifies the configuration on the fly.
        :return:
        umasteru	discoveryuattemptsiiu)Attempting %s time(s) to discover mastersupauseiuSSDP discovery failure: %sumatchuanyualluPSSDP configuration matcher failure: unknown value "%s". Should be "any" or "all"umappingN(uanyuall(R<RR(R@R*tssdptSSDPDiscoveryClientRR'R1R�RHtdiscoverR6R7R�R4titemsR�tbool(
R�tmaster_discovery_clienttmasterstattRDtpolicytmappingtaddrtmappingst
proto_dataRutvaluetcnt((s//usr/lib/python2.7/site-packages/salt/minion.pyR��s6*&
#	!	

0*cC�s�d}|jjd�r�yCt|jd|jd�}||}tjd||�|SWq�tk
r�tjd|jd|jd�tj|td�tdSXn,tj||jjd��|jjd�SdS(u�
        Based on the minion configuration, either return a randomized timer or
        just return the value of the return_retry_timer.
        u+Minion return retry timer set to %s secondsureturn_retry_timer_maxureturn_retry_timeru%s (randomized)ueInvalid value (return_retry_timer: %s or return_retry_timer_max: %s). Both must be positive integers.N(R<R'RR1R;t
ValueErrorR4R(R�R#trandom_retryt	retry_msg((s//usr/lib/python2.7/site-packages/salt/minion.pyt_return_retry_timers 


(t__name__t
__module__R�R(R�tstaticmethodR�R�R�R�t	coroutineR&R�R�R�(((s//usr/lib/python2.7/site-packages/salt/minion.pyR��s	$		�	%tSMinioncB�seZdZd�ZRS(u�
    Create an object that has loaded all of the minion module functions,
    grains, modules, returners etc.  The SMinion allows developers to
    generate all of the salt minion functions and present them with these
    functions for general use.
    c

�s&ddl}|jj|�|d<tt��j|��jjdd�dksh�jjdt�r�t	�t
j�}|j�fd��n�j
dt��jddkr"�jjdt�r"ddl}tjj�jd	d
�}tjj|�stj|d�ntjj|d�}�jd
dk	rQ�jd
}nd}iidg�jd6|6}|jjj|d��-}|jjj||�tj|d�WdQXtjj|d�}	|jjj|	d��4}|jjj�jd
|�tj|	d�WdQXndS(Niugrainsufile_clienturemoteuuse_master_when_localc�s�j�jdt�S(NR�(R�R<R&((R�(s//usr/lib/python2.7/site-packages/salt/minion.pyt<lambda>LsR�uminion_pillar_cacheucachedirupillari�utop.slsusaltenvubaseucacheuiduwbi�u	cache.sls(tsalt.loaderRztgrainstsuperR�R�R<R'R(RR
tcurrenttrun_syncR�R&tsalt.utils.yamlRKRLRMRORPR.R*tfilestfopentyamlt	safe_dumpRS(
R�R<R@R�tpdirtptoptpenvt	cache_toptfp_t	cache_sls((R�s//usr/lib/python2.7/site-packages/salt/minion.pyR�@s6((R�R�t__doc__R�(((s//usr/lib/python2.7/site-packages/salt/minion.pyR�9stMasterMinioncB�s5eZdZeeeeded�Zed�ZRS(u�
    Create a fully loaded minion function object for generic use on the
    master. What makes this class different is that the pillar is
    omitted, otherwise everything else is loaded cleanly.
    cC�s�tjj|dd|dd�|_|jj|�||_tjj|�|jd<i|jd<||_||_	||_
||_|jdt
�dS(Nu	conf_filetignore_config_errorstroleumasterugrainsupillarR�(R@tconfigt
minion_configR<RHt	whitelistRzR�tmk_returnerst	mk_statestmk_rendt
mk_matcherR�R&(R�R<R�R�R�tmatcherR	R((s//usr/lib/python2.7/site-packages/salt/minion.pyR�ks		
	
				cC�s"tjj|j�|_tjj|jd|jd|jd|�|_tjj|j�|_|jr�tjj	|j|j�|_	n|j
r�tjj|j|j|j|j�|_n|jr�tjj
|j|j�|_n|jrtjj|j�|_n|j|jd<dS(u�
        Tell the minion to reload the execution modules

        CLI Example:

        .. code-block:: bash

            salt '*' sys.reload_modules
        R*R	R�usys.reload_modulesN(R@RzR*R<R�R	R�R�R
R�RR�RR�R�R
R�R�(R�R�((s//usr/lib/python2.7/site-packages/salt/minion.pyR��s&
					!		!	N(R�R�RR&R.R�R(R�(((s//usr/lib/python2.7/site-packages/salt/minion.pyRest
MinionManagercB�s�eZdZd�Zd�Zd�Zejjd��Z	dddd�Zd�Zdd�Z
ejjd	��Zd
�Zed��Zd�Zd
�ZRS(u�
    Create a multi minion interface, this creates as many minions as are
    defined in the master option and binds each minion object to a respective
    master.
    cC�s�tt|�j|�|jd|_|jd|_g|_g|_t�t	j
�|_tdd�|_
|jj|j
jitd6�dS(Nuacceptance_wait_timeuacceptance_wait_time_maxtnameuMultiMinionProcessManageruasynchronous(R�RR�R<t	auth_waitt
max_auth_waittminionst	jid_queueRR
R�R�Rtprocess_managertspawn_callbacktrunR&(R�R<((s//usr/lib/python2.7/site-packages/salt/minion.pyR��s		cC�s|j�dS(N(tdestroy(R�((s//usr/lib/python2.7/site-packages/salt/minion.pyt__del__�scC�sutjjj|jd|j�|_tjjjdd|jd|j�|_|jjd�|jj	|j
�dS(NR�uminionR<u(R@R*teventtAsyncEventPublisherR<R�tevent_publishert	get_eventt	subscribetset_event_handlerthandle_event(R�((s//usr/lib/python2.7/site-packages/salt/minion.pyt_bind�s	*cC�s%x|jD]}|j|�q
WdS(N(RR (R�tpackageR�((s//usr/lib/python2.7/site-packages/salt/minion.pyR �sc
C�s"t|||d|d|d|�S(uF
        Helper function to return the correct type of object
        R�tloaded_base_nameR(tMinion(R�R<R�R�R�R#R((s//usr/lib/python2.7/site-packages/salt/minion.pyt_create_minion_object�scC�s#|jsd}tj|�ndS(uQ
        Check the size of self.minions and raise an error if it's empty
        u7Minion unable to successfully connect to a Salt Master.N(RR1R4(R�RD((s//usr/lib/python2.7/site-packages/salt/minion.pyt_check_minions�s	i<cC�s|jd}|jdd
ks7t|jdt�rC|g}nt}x�|D]�}tj|j�}||d<t|d<||d<|r�t}n|j||dtd|jd	d
j	|d�d|j
�}|jj|j|�qPW|jj
||j�dS(uH
        Spawn all the coroutines which will sign in to masters
        umasterumaster_typeufailoverudistributedumultimasterubeacons_leaderuauth_timeoutR�R#usalt.loader.{0}RN(ufailoverudistributed(R<ReR~R&R�tdeepcopyR(R%R�R0RRt_connect_miniont
call_laterR&(R�R�R�R�RCts_optsR�((s//usr/lib/python2.7/site-packages/salt/minion.pyt_spawn_minions�s&
*



			cc�s�d}|jd}t}xhtr�y�|jjdt�rM|jdt�n|jjdt�ru|jdt�n|jd|�V|jdt�|jj	|�PWqt
k
r}t}tjd|jd	�t
j
�}||jkr||j7}ntjj|�Vqtk
rJd
j|jd	�}tj|�Pqtk
r}t}tjd|jd	dt�qXqWd
S(uL
        Create a minion, and asynchronously connect it to a master
        iuacceptance_wait_timeubeacons_before_connecttbefore_connectuscheduler_before_connectR�tstartuLError while bringing up minion for multi-master. Is master at %s responding?umasterusMaster address: '{0}' could not be resolved. Invalid or unresolveable address. Set 'master' value in minion config.u'Unexpected error while connecting to %stexc_infoN(R<R(R&R't
setup_beaconstsetup_schedulertconnect_masterttune_inRRiRR1R4R6RRR�R�R7R!R0R�R�(R�R�tlastRR�R�RDte((s//usr/lib/python2.7/site-packages/salt/minion.pyR(�s@
	

cC�s%|j�|j�|jj�dS(u
        Bind to the masters

        This loop will attempt to create connections to masters it hasn't connected
        to yet, but once the initial connection is made it is up to ZMQ to do the
        reconnect (don't know of an API to get the state here in salt)
        N(R!R+R�R-(R�((s//usr/lib/python2.7/site-packages/salt/minion.pyR2s

cC�s%x|jD]}|jr
tSq
WtS(N(RtrestartR&R((R�R�((s//usr/lib/python2.7/site-packages/salt/minion.pyR5.s	cC�sLxE|jD]:}|jj�|jj|�|jj�|j�q
WdS(N(RRtstop_restartingtsend_signal_to_processest
kill_childrenR(R�tsignumR�((s//usr/lib/python2.7/site-packages/salt/minion.pytstop5s


cC�s"x|jD]}|j�q
WdS(N(RR(R�R�((s//usr/lib/python2.7/site-packages/salt/minion.pyR=sN(R�R�RR�RR!R�R�R�R R.R%R&R+R(R2tpropertyR5R:R(((s//usr/lib/python2.7/site-packages/salt/minion.pyR�s			
		)		R$cB�s9eZdZded-d-d-d�Zd�Zd-ed�Ze	j
jed��Ze	j
jd��Z
d�Zeed-d-d�Zd	�Ze	j
jd
��Zd-d-d-d-ded-d�Ze	j
jd��Zd
�Zed��Zed��Zed��Zdded�Zdded�Zd�Zd�Zd�Zeed�Zd�Zd�Z e	j
jed��Z!d�Z"d�Z#d�Z$d�Z%d�Z&e	j
jd ��Z'd!�Z(d"�Z)ed#�Z*ed$�Z+d%d&�Z,d'�Z-ed(�Z.d)�Z/d*�Z0d+�Z1d,�Z2RS(.u}
    This class instantiates a minion, runs connections for a minion,
    and loads all of the functions into the minion
    i<cC�s�tt|�j|�||_||_d|_g|_tj	j
j�|_||_
t|_t|_t|_|dkr�gn||_i|_|dkr�t�tj�|_n	||_tr�tdkr�tjd�q�ntj	jj�stjj|�|j d<nd|j j!dt�rJtjd�t|j d<n|j j!dt�r|tjd�t|j d<ntj"d	�|j d
r�t#j$d|j d
�}tj"d||j d
�t%j&|�nt'd
d�|_(|jj)|j(j*it+d6�tj	jj�sB|jj)tj,j-|j |j(�nt.j/t.j0�t.j1krvt.j.t.j0|j2�nt.j/t.j3�t.j1kr�t.j.t.j3|j2�ndS(u*
        Pass in the options dict
        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!ugrainsubeacons_before_connectuM'beacons_before_connect' is not supported for proxy minions. Setting to Falseuscheduler_before_connectuO'scheduler_before_connect' is not supported for proxy minions. Setting to FalseuCreating minion process managerurandom_startup_delayiuWMinion sleeping for %s seconds due to configured startup_delay between 0 and %s secondsRuMinionProcessManageruasynchronousN(ii(4R�R$R�R�R�R.t_runningtwin_procR@R*R�tSubprocessListtsubprocess_listR#R(R�R5treadyRtperiodic_callbacksRR
R�R�RRR1R8R�tis_proxyRzR�R<R'R�trandomRR6R7RRRRR&tenginest
start_enginestsignalt	getsignaltSIGINTtSIG_DFLt_handle_signalstSIGTERM(R�R<R�R�R#R�Rt
sleep_time((s//usr/lib/python2.7/site-packages/salt/minion.pyR�Gs\										
	

 
cC�sQt|_|jj�|jj|�|jj�tjd�tj	d�dS(Nii(
R(R<RR6R7R8R6R7R�R�(R�R9tsigframe((s//usr/lib/python2.7/site-packages/salt/minion.pyRJ�s	


c�s�t�_tjd��fd�}�jd|��_�jj|�|rl�jj|�jj	�ny�jj
�Wntk
r��j�nX�jj
�r��jj�}|r�tj|��q�n|r��jtkr�td��ndS(u:
        Block until we are connected to a master
        usync_connect_masterc�st�_�jj�dS(N(R&t_sync_connect_master_successR�R:(tfuture(R�(s//usr/lib/python2.7/site-packages/salt/minion.pyton_connect_master_future_done�s	R�u$Failed to connect to the salt-masterN(R(RNR1R;R1t_connect_master_futuretadd_done_callbackR�R)R:R-tKeyboardInterruptRtdonet	exceptionRtreraiseR(R�R�R�RPtfuture_exception((R�s//usr/lib/python2.7/site-packages/salt/minion.pytsync_connect_master�s"	

cc�s=|j|j|j|j|�V\}|_|j|�VdS(uX
        Return a future which will complete when you are connected to a master
        N(R�R<R�R�R�t_post_master_init(R�R�RC((s//usr/lib/python2.7/site-packages/salt/minion.pyR1�s+c
c�s�|jr|||jd<tjj|j|jd|jd|jdd|jjd��}|j�V|jd<|j�n|js�|j	�nm|jr�|jdr�|j
�\|_|_|_
|_t|d�r�|j|j_|j|j_q�nt|d�sJtjjj|j|j|jd	td
d�g�|_n|jdr�d
|jkr�|jjiid
d6|jdd6td6dd6td6|jjdt�d6d6dt�tjd�n|jjddt�|jddkrY|jddkrY|jrY|jjiidd6|jdd6td6d d6td6i|jdd6td!6d"6td
dd#|jd�6dt�|jd$r7d%|jkr7|jd|jd%dkr7|jjiid&d6|jd'd6td6d d6td6i|jd%dd6d"6td
d(�6dt�q�|jjtd
d(�dt�nK|jjtd
dd#|jd�dt�|jjtd
d(�dt�d)S(*u�
        Function to finish init after connecting to a master

        This is primarily loading modules, pillars, etc. (since they need
        to know which master they connected to)

        If this function is changed, please check ProxyMinion._post_master_init
        to see if those changes need to be propagated.

        Minions and ProxyMinions need significantly different post master setups,
        which is why the differences are not factored out into separate helper
        functions.
        umasterugrainsuidusaltenvR�u	pillarenvupillaruscheduletcleanupR�ualiveumine_enabledumine.updateufunctionu
mine_intervaluminutesujid_includeiu
maxrunningurun_on_startumine_return_jobu
return_jobu__mine_intervaltpersistuAdded mine.update to scheduleru	transportutcpumaster_alive_intervaliu
status.masterusecondsiu	connectedukwargsRCumaster_failbackumaster_listustatus.ping_masterumaster_failback_intervalufailbackN(R�R<R@R�tget_async_pillarR'R�RR@t_setup_coret
_load_modulesR�R�R�R�RTR�R*tScheduleR�tadd_jobR&R(R1R�t
delete_job(R�RCtasync_pillar((s//usr/lib/python2.7/site-packages/salt/minion.pyRY�s~	
	



	
$		(
)
",cC�sIi}x<tj|j�D](\}}|dkr7qn|||<qW|S(uG
        Returns a copy of the opts with key bits stripped out
        ulogger(RRgR<(R�tmod_optsRuRv((s//usr/lib/python2.7/site-packages/salt/minion.pyt_prep_mod_opts0scC�s�t}|s|j}t}nt}|jdd�dkr�tr�tr�tjd|d�t}tj	tj
�}tjt
j��j�d \}}	||	|d}
tjtj
|
|
f�nG|jdd�dkrts�tjd�ntstjd�qnt|d�r)|j}nd}|dkr]tjj||d	|�|d
<ntjj|d	|�|_|jdt�r�tj|�}tjj|d|jd	|d
|jd|�}
n'tjj|d|jd|d	|�}
tjj||
d	|�}i}d|
kr:|
d}|
jd�n|tkr\tjtj
|�ntjj||
d	|�}|r�||_n|
|||fS(ua
        Return the functions and the returners loaded up from the loader
        module
        umodules_max_memoryi����iu1modules_max_memory set, enforcing a maximum of %siu>Unable to enforce modules_max_memory because psutil is missingu@Unable to enforce modules_max_memory because resource is missinguproxyR�ugrainsumultimasterR*R#tnotifyu_errorsN( R&R<R(R't
HAS_PSUTILtHAS_RESOURCER1R;tresourcet	getrlimitt	RLIMIT_AStpsutiltProcessRKtgetpidtmemory_infot	setrlimitR4RTR�R.R@RzR�R*R�R'R�R#R�RNR�(R�t
force_refreshReR�R<topt_intmodules_max_memoryt
old_mem_limittrsstvmst	mem_limitR�R*R�R�terrorsR�((s//usr/lib/python2.7/site-packages/salt/minion.pyR^;sR		$%"'
cC�s�|jdrgtjd�tjj|jdd�}tjj|tj	j
j|��}||d<ntjj
jj|j�}z|j|d|�SWd|j�XdS(Numinion_sign_messagesu+Signing event to be published onto the bus.upki_diru
minion.pemusigR�(R<R1R9RKRLRMR@tcrypttsign_messageR�tmsgpackt	serializeR�R�t
ReqChannelR�tsendtclose(R�tloadR�tminion_privkey_pathtsigtchannel((s//usr/lib/python2.7/site-packages/salt/minion.pyt_send_req_syncys

$
cc�s�|jdrgtjd�tjj|jdd�}tjj|tj	j
j|��}||d<ntjj
jj|j�}z,|j|d|�V}tjj|��Wd|j�XdS(Numinion_sign_messagesu+Signing event to be published onto the bus.upki_diru
minion.pemusigR�(R<R1R9RKRLRMR@RxRyR�RzR{R�R�tAsyncReqChannelR�R}R�R�R�R~(R�RR�R�R�R�R>((s//usr/lib/python2.7/site-packages/salt/minion.pyt_send_req_async�s

$
c
C�sJi|jdd6dd6|d6|jd6}|r?||d<nK|rb|rb||d<||d<n(|r�|r�i|d<||d<nd	S|r�y|j||�WqFtjjk
r�tjd
�tSt	k
r�tjdt
j��tSXnP|d	krd�}	|	}nt
jj|��|j||d
d��Wd	QXtS(uQ
        Fire an event on the master, or drop message if unable to send.
        uidu
_minion_eventucmdupretagutokueventsudatautagNuEfire_master failed: master could not be contacted. Request timed out.ufire_master failed: %scW�stjd�tS(NuEfire_master failed: master could not be contacted. Request timed out.(R1R�R&(t_((s//usr/lib/python2.7/site-packages/salt/minion.pythandle_timeout�s
tcallbackcS�sdS(N(R.(tf((s//usr/lib/python2.7/site-packages/salt/minion.pyR��s(R<R�R�R@t
exceptionsRR1R�R(R�t	tracebackt
format_excR.R�t
stack_contexttExceptionStackContextR�R&(
R�RottagteventstpretagR�tsyncttimeout_handlerRR�((s//usr/lib/python2.7/site-packages/salt/minion.pyt_fire_master�s8








		cc�s*tjr'tjjj|dt�}nd|krXtjd|d|d|d�ntjd|d|d�tj	d|�tj
d|j�|jd	k	r|d|jkr�d	S|jj
|d�t|j�|jd
kr|jjd�qnt|dtj�rp|ddkrp|j�\|_|_|_|_|j|j_|j|j_qpn|jjd
�}|dkrttjjj|j��}xV||krtjd|d�tjjd�Vttjjj|j��}q�Wn|}|jjdt�}|r�t j!j"d�rAd	}nt#t$j%t$j&��/t'd|j(d||j||j)f�}Wd	QXn7t*j+d|j(d||j||j)fd|d�}|r�t#t$j%t$j&��|j,�Wd	QXn
|j,�dj-|j.|d�|_.|j/j0|�d	S(ub
        Override this method if you wish to handle the decoded data
        differently.
        tkeepuuseru(User %s Executing command %s with jid %sufunujidu Executing command %s with jid %suCommand details %suStarted JIDs: %sNuminion_jid_queue_hwmiusys.reload_modulesuprocess_count_maxuFMaximum number of processes reached while executing jid %s, waiting...i
umultiprocessinguwinttargetRcRu	{}-Job-{}(1RtPY2R@R*RotdecodeR&R1R�R;R9RR.RiR�R<RNReR}R^R�R�R�R�R�R'R�trunningR8R�R�R7R�R�R�RRFRHRKRt_targetR�t	threadingtThreadR-R0RR?tadd(R�Rotprocess_count_maxt
process_counttinstancetmultiprocessing_enabledR�((s//usr/lib/python2.7/site-packages/salt/minion.pyt_handle_decoded_payload�s^	$%	-		

cC�s�tjr@tj|jjj�|jjj�|jjj��Stj	�}|j
|jjj��|j
|jjj��|j
|jjj��|SdS(uG
        Return a single context manager for the minion's data
        N(RR�t
contextlibtnestedR�tcontext_dicttcloneR�R�t	ExitStackt
enter_context(R�t	exitstack((s//usr/lib/python2.7/site-packages/salt/minion.pytctxs	cC�sX|s�||�}||_t|d�ss|jd|d�\}}}}||_||_||_||_nt|d�s�tjj	|�|_
nt|d�s�tjjj
d|jdd��}	t|dd	|	�|_q�nd
�}
tjjtjti|d6|d6���1tjj|j��|
|||�WdQXWdQXdS(
Nu	functionsR�ugrainsuserialuproc_dirtuseruuserucachedirR^cS�sPt|dt�s&t|dt�r9tj|||�Stj|||�SdS(Nufun(RettupleR~R$t_thread_multi_returnt_thread_return(tminion_instanceR<Ro((s//usr/lib/python2.7/site-packages/salt/minion.pytrun_func1s&udatauopts(R�RTR^R�R�R�R�R@tpayloadtSerialtserialR*R�tget_uidR'R.Ratproc_dirR�R�tStackContextt	functoolstpartialRR�(tclsR�R<RoR�R�R�R�R�R^R�((s//usr/lib/python2.7/site-packages/salt/minion.pyR�s&	"			$	c!�sZ
|j�tjj|j|d�}tjjjdj	|j
|d��itj�d6}|j|�t
jd|d|d�tjjj|d�� }|j|jj|��WdQXitd6}|d}|jd	�pt|d	g�p|jd	d
g�}	tg|	D]1}
d|jkr|jdj	|
�|�^q�}||jksm|tkrby�t}|jr�|jdjd
t�r�|jdjdg�}
|dkr�||
kr�t}q�n|jdjd
t�r+|jdjdg�}
|dkr+||
kr+t}q+n|r@td��n||jkr{|j|}t||d|�\}}n|}|d|}}d|jjdd<t |	t!j"�r�|	g}	n/t |	t#�s�|	r�tdj	|	���n|jdd�r"|	ddkr"d|	d<nt
j$d|	�xs|	D]k}dj	|�}||jkrutdj	|���n|j||||||���dk	r9Pq9q9Wt �t&j'�r�d}i}x��D]�}t |t(�rt |t(�r|j|�n|sg}n|j)|�t*|dd|dt!j+|�gd �}i|d!6}|j,||�|d"7}q�W||d!<n
�|d!<|jjdjdtj-j.j/�}|tj-j.j/kry t0�fd#�dCD��}Wnt1k
r�t}nX|stj-j.j2}qn||d<|tj-j.j/k|d<Wq)t3k
r�}d%j	|�}t
j4|d&t�d'j	||�|d!<d(|d)<tj-j.j2|d<q)t5k
r}t
j6d*||d+t7j8�d,j	|�|d!<d(|d)<tj-j.j2|d<q)tk
rg}t
j6d-||d+t7j8�d.j	||�|d!<d(|d)<tj-j.j2|d<q)t9k
r�}d/j	|||j:p�d�}t
j;|d+t7j8�||d!<d(|d)<tj-j.j2|d<q)t1k
r^d0}t
j;|d+t�tjj6j<tj=j>|�|d1|�d'j	|t?j@��|d!<d(|d)<tj-j.j2|d<q)Xn�|jd2d3j	|��}|r�|jjA|�||<||d!<n[|jjA|�|d!<|jBd4�d}||jCkr|d!cd5j	|jC|�7<nt|d<tj-j.j2|d<d(|d)<|d|d<|d|d<|d|d6<d7|krp|d7|d7<nd8|kr�t |d8t(�r�|d8|d8<q�t
j;d9�n|jr�|jD|d:|jE��nt |jd!�t!j"�r/	|d;r	d<j|d;|d!f�|d;<q/	|d!|d;<nt
j4d=|�|d;rV
t |d;t!j"�rV
d>|kr|	|d>|d><nd?|kr�	|d?|d?<n|d|d<x�tF|d;jBd<��D]�}y[d@j	|�}||jGkr�	|jG||�n%|jGjA|�} t
j6dA|| �Wq�	t1k
rN
}t
jHdB|d|�q�	Xq�	WndS(Dus
        This method should be used as a threading target, start the actual
        minion side execution.
        ujidu{0}._thread_return {1}upidu!Starting a new job %s with PID %suw+bNusuccessufunumodule_executorsudirect_callu{0}.allow_missing_funcupillaruminion_blackoutuminion_blackout_whitelistusaltutil.refresh_pillarugrainsu�Minion in blackout mode. Set 'minion_blackout' to False in pillar or grains to resume operations. Only saltutil.refresh_pillar allowed in blackout mode.uargiu__context__uretcodeuEWrong executors specification: {0}. String or non-empty list expectedu	sudo_userui����usudouExecutors list %su{0}.executeuExecutor '{0}' is not availableuproguidujobureturnic3�s!|]}�j|t�VqdS(N(R'R&(t.0R�(treturn_data(s//usr/lib/python2.7/site-packages/salt/minion.pys	<genexpr>�suresultu$Command required for '{0}' not foundR.u{0}: {1}unesteduoutu#A command in '%s' had a problem: %stexc_info_on_loglevelu
ERROR: {0}uProblem executing '%s': %suERROR executing '{0}': {1}u(Passed invalid arguments to {0}: {1}
{2}u'The minion function caused an exceptiontjobusys.docu{0}*u.u Possible reasons: '{0}'ufun_argsu	master_idumetadatau6The metadata parameter must be a dictionary. Ignoring.R�uretu,uminion return: %su
ret_configu
ret_kwargsu{0}.returneru#Returner %s could not be loaded: %su The return failed for job %s: %s(uresultusuccess(IR�RKRLRMR�R@R*R�tappendproctitleR0R�RmRHR1R�R�R�twriteR�tdumpsR(R'R�tanyR�R�R&R�R<RRxtpackReRR}R~R9R.ttypest
GeneratorTypeRfRiRt	text_typeR�R�R�tEX_OKtallR�R�RR;RR4tloggingtDEBUGRRR8tfire_exceptionR�tMinionErrorR�R�tmissing_fun_stringRyR�t_return_pubR�tsetR�RU(!R�R�R<RoRZtsdataRR>t
function_nameR�texecutortallow_missing_funcstminion_blackout_violationR	RnRcRYRtfnametindtirettsingleR�t
event_datatretcodetfunc_resultR�R#tdocstmod_nametreturnertreturner_strtreturner_err((R�s//usr/lib/python2.7/site-packages/salt/minion.pyR�<sP
&



4"
	"


	
,





	
	

	




(



	
$  c	�s|j�tjj|j|d�}tjjjdj	|j
|d��itj�d6}|j|�t
jd|d�tjjj|d�� }|j|jj|��WdQX|jdt�}t|d�}|ridg|d	6dg|d
6tg|d6�niid	6id
6id6�x�td|�D]�}	|set�d|d|	<nyt}
|jr�|jd
jdt�r�|jd
jdg�}|d|	dkrC|d|	|krCt}
qCnf|jdjdt�rC|jdjdg�}|d|	dkrC|d|	|krCt}
qCn|
rXtd��n|j|d|	}t||d|	|�\}
}d|jjdd
<|r�|	n|d|	�||
|��d	�<|jjdjd
d�}|dkrIy#t ��fd�d#D��}Wnt!k
r6t}nX|sId}qIn|�d
�<|dk�d�<Wn\t!k
r�}t"j#�}t
j$d|�|r�|�d	|	<q�|�d	|d|	<nX|d�d<|d�d<|d�d<q@Wd|kr|d�d<n|jr;|j%�d|j&��n|dr�d|krb|d�d<nd|kr|d�d<nx}t'|dj(d��D]_}|d �d <y|j)d!j	|���Wq�t!k
r�}t
j*d"|d|�q�Xq�WndS($us
        This method should be used as a threading target, start the actual
        minion side execution.
        ujidu{0}._thread_multi_return {1}upiduStarting a new job with PID %suw+bNumultifunc_orderedufunureturnuretcodeusuccessiupillaruminion_blackoutuminion_blackout_whitelistusaltutil.refresh_pillarugrainsu�Minion in blackout mode. Set 'minion_blackout' to False in pillar or grains to resume operations. Only saltutil.refresh_pillar allowed in blackout mode.uargu__context__c3�s)|]}�d�j|t�VqdS(ureturnN(R'R&(R�R�(RuR>(s//usr/lib/python2.7/site-packages/salt/minion.pys	<genexpr>Wsuresultiu+The minion function caused an exception: %sufun_argsumetadataR�uretu
ret_configu
ret_kwargsu,uidu{0}.returneru The return failed for job %s: %s(uresultusuccess(+R�RKRLRMR�R@R*R�R�R0R�RmRHR1R�R�R�R�R�R�R'R(R�R.RR�R<R&RR�RxR�R�R�R�R�R8R�R�R�RyR�R4(R�R�R<RoRZR�Rtmultifunc_orderedt	num_funcsR�R�R	RnRcRYR�R�R�ttrbR�((RuR>s//usr/lib/python2.7/site-packages/salt/minion.pyR�s�
&

"((	

	
 u_returnc

�s�|jd|jd���|jd|jd��}|jdr�tjj|j��}tjj|�r�ytj|�Wq�tt	fk
r�q�Xq�nt
jd��t
jd|�|dkr�i|d	6|jd
d6�d6|d6|jd�d6|jd
�d
6|jd�d6|jd�d6}d|krP|d|d<ni|d<x�t
j|�D]/\}}	|jd�r�qjn|	|d|<qjWnEi|d	6|jdd6}x't
j|�D]\}}	|	||<q�Wd|kr/t|dt
j�r|d|d<qt
jd|d�nPy|j|j}
Wntttfk
r_n Xt|
t
j�r|
|d<n|jdr�|ddkr�tjjj|j�|d<ntjjj|j|d|�n|jds�dS�fd�}|r<y|j|d|�}Wqstk
r8|�dSXn7t j!j"|��#|j#|d|dd��}WdQXt
jd |�|S(!uP
        Return the data from the executed command to the master server
        ujidu__jid__ufunu__fun__umultiprocessingu!Returning information for job: %suReturn data: %su_syndic_returnucmduuiduiduargutgtutgt_typeu__load__uloadu
__master_id__u	master_idureturnu__uoutu+Invalid outputter %s. This is likely a bug.u
cache_jobsurequpub_retuc�stjd��tS(Nu�The minion failed to return the job information for job %s. This is often due to the master being shut down or overloaded. If the master is running, consider increasing the worker_threads value.(R1R8R&(R�(tjid(s//usr/lib/python2.7/site-packages/salt/minion.pyR��sR�R�cS�sdS(N(R.(R�((s//usr/lib/python2.7/site-packages/salt/minion.pyR��sNuret_val = %s($R'R<RKRLRMR�tisfiletremovetOSErrortIOErrorR1R�R9RRgR�ReR}R4R�t
__outputter__R|R�RR@R*R�tgen_jidR�t
cache_jobsR�RR�R�R�R�(
R�R>tret_cmdR�R�R�RZRRuR�toputR�tret_val((R�s//usr/lib/python2.7/site-packages/salt/minion.pyR��sx






#
	
$c
�s�t|t�s|g}ni}x�|D]�}|jd|jd���|jd|jd��}|jdr�tjj|j��}tjj|�r�ytj	|�Wq�t
tfk
r�q�Xq�ntj
d��|j�i�}	|dkr�|	ss|	ji|jdd6�d6|d6|jd	�d	6|jd
�d
6|jd�d6|jd�d
6id6�nd|kr�|d|	d<nx�tj|�D]/\}
}|
jd�r�q�n||	d|
<q�WnE|	ji|jdd6�x'tj|�D]\}
}||	|
<qWd|kret|dtj�rN|d|	d<q�tjd|d�nPy|j|j}Wntttfk
r�n Xt|tj�r�||	d<n|jdr(tjjj|j|	d|�q(q(Wi|d6ttj|��d
6}	�fd�}
|rYy|j|	d|�}Wq�t k
rU|
�dSXn7t!j"j#|
��#|j$|	d|dd��}WdQXtj%d|�|S(uP
        Return the data from the executed command to the master server
        ujidu__jid__ufunu__fun__umultiprocessingu!Returning information for job: %su_syndic_returnuiduargutgtutgt_typeu__load__uloadureturnu
__master_id__u	master_idu__uoutu+Invalid outputter %s. This is likely a bug.u
cache_jobsucmdc�stjd��tS(Nu�The minion failed to return the job information for job %s. This is often due to the master being shut down or overloaded. If the master is running, consider increasing the worker_threads value.(R1R8R&(R�(R�(s//usr/lib/python2.7/site-packages/salt/minion.pyR�sR�uR�cS�sdS(N(R.(R�((s//usr/lib/python2.7/site-packages/salt/minion.pyR�)sNuret_val = %s(&ReR~R'R<RKRLRMR�R�R�R�R�R1R�t
setdefaultRHRRgR�R}R4R�R�R|R�RR@R*R�R�t
itervaluesR�RR�R�R�R�R9(R�tretsR�R�R�tjidsR>R�RZRRuR�R�R�R�((R�s//usr/lib/python2.7/site-packages/salt/minion.pyt_return_pub_multi�sz




'
	
$cC�s|jdr|jjdd�dkrS|jjdd�dkrStjd�qidd	6|jjd
d�d6}|jdd
kr�d|d<|jdg|d<nH|jddkr�d|d<|jdg|d<nd|d<g|d<|j|�ndS(uX
        Execute a state run based on information set in the minion config file
        ustartup_statesumaster_typeustrudisableufile_clienturemoteupCannot run startup_states when 'master_type' is set to 'disable' and 'file_client' is set to 'remote'. Skipping.urequjidu
ext_job_cacheuuretuslsu	state.slsufunusls_listuargutopu	state.toputop_fileustate.highstateN(R<R'R1R8R�(R�Ro((s//usr/lib/python2.7/site-packages/salt/minion.pyt
_state_run.s

#



cC�swd|jjdi�krsd|jkr:i|jd<n|jdjiidd6idgd6|d6d6�ndS(	u�
        Create a loop that will fire a pillar refresh to inform a master about a change in the grains of this minion
        :param refresh_interval_in_minutes:
        :return: None
        u__update_grainsuscheduleu
event.fireufunctionugrains_refreshuargsuminutesN(R<R'RH(R�trefresh_interval_in_minutes((s//usr/lib/python2.7/site-packages/salt/minion.pyt_refresh_grains_watcherGs
cC�s||jdr9|jdj|jdtj��d�n|jdj|jdtj��t|jddgd��dS(Nuenable_legacy_startup_eventsuMinion {0} started at {1}uiduminion_startustartuminion(R<R�R0R6tasctimeR(R�((s//usr/lib/python2.7/site-packages/salt/minion.pyt_fire_master_minion_startYs



cC�s\tjd|�|j|d|�\|_|_}|_|j|j_|j|j_dS(u6
        Refresh the functions and returners.
        uRefreshing modules. Notify=%sReN(R1R;R^R�R�R�R�(R�RpReR�((s//usr/lib/python2.7/site-packages/salt/minion.pytmodule_refreshms*cC�s<|js
dStjd�tjj|j|j�|_dS(u6
        Refresh the functions and returners.
        NuRefreshing beacons.(R�R1R;R@R�tBeaconR<R�(R�((s//usr/lib/python2.7/site-packages/salt/minion.pytbeacons_refreshws	
cC�s)tjd�tjj|j�|_dS(u&
        Refresh the matchers
        uRefreshing matchers.N(R1R;R@RzR�R<(R�((s//usr/lib/python2.7/site-packages/salt/minion.pytmatchers_refresh�s
cc�s|jr�tjd�tjj|j|jd|jd|jdd|jjd��}z=y|j�V|jd<Wnt	k
r�tj
d�nXWd	|j�Xn|j|�|j
�|j�tjjjd
d|j�}|jitd6d
d�d	S(u$
        Refresh the pillar
        uRefreshing pillarugrainsuidusaltenvR�u	pillarenvupillaruDPillar data could not be refreshed. One or more masters may be down!NuminionR<ucompleteR�u+/salt/minion/minion_pillar_refresh_complete(R�R1R;R@R�R\R<R'R�RR4RR�R�R�R*RRt
fire_eventR&(R�RpRbtevt((s//usr/lib/python2.7/site-packages/salt/minion.pytpillar_refresh�s&	
	






cC�s|jdd�}|jdd�}|jdd�}|jdd�}|jdd�}|dkr||jj||�n�|dkr�|jj||�n}|dkr�|jj|||�nX|d	kr�|jj�n<|d
kr�|jj�n |dkr|jj||�n�|dkr<|jj	|�n�|d
kr^|jj
||�n�|dkr�|jj||�n�|dkr�|jj||�ny|dkr�|jj
|�nZ|dkr�|jj|�n;|dkr�|jj�n|dkr|jj|�ndS(u6
        Refresh the functions and returners.
        ufuncunameuscheduleuwhereupersistudeleteuaddumodifyuenableudisableu
enable_joburun_jobudisable_jobupostpone_jobuskip_jobureloadulistu
save_scheduleuget_next_fire_timeN(R'R.R�RaR`t
modify_jobtenable_scheduletdisable_schedulet
enable_jobtrun_jobtdisable_jobtpostpone_jobtskip_jobtreloadR~t
save_scheduletget_next_fire_time(R�R�RoRnRR�twhereR[((s//usr/lib/python2.7/site-packages/salt/minion.pytmanage_schedule�sBcC�s�|js
dS|jdd�}|jdd�}|jdd�}|jdd�}|jdd�}|dkr�|jj||�n3|dkr�|jj||�n|d	kr�|jj|�n�|d
kr�|jj�n�|dkr|jj�n�|dkr!|jj	|�n�|d
kr@|jj
|�n||dkrb|jj||�nZ|dkr~|jj�n>|dkr�|jj
||�n|dkr�|jj�ndS(u 
        Manage Beacons
        Nufuncunameubeacon_datauinclude_pillaruinclude_optsuaddumodifyudeleteuenableudisableu
enable_beaconudisable_beaconulistulist_availableuvalidate_beaconureset(R�R'R.R�t
add_beacont
modify_beacont
delete_beacontenable_beaconstdisable_beaconst
enable_beacontdisable_beacontlist_beaconstlist_available_beaconstvalidate_beacontreset(R�R�RoRnRtbeacon_datatinclude_pillartinclude_opts((s//usr/lib/python2.7/site-packages/salt/minion.pytmanage_beacons�s:	cC�sk|jdd�}|dkr"tS|jdt�}|jdt�}ddljj}|j|||�S(u
        Set the salt-minion main process environment according to
        the data contained in the minion event data
        uenvironufalse_unsetsu	clear_alliN(R'R.R(tsalt.modules.environtmodulestenvirontsetenv(R�R�RoRtfalse_unsetst	clear_alltmod_environ((s//usr/lib/python2.7/site-packages/salt/minion.pytenviron_setenv�scC�s�|jdkrt|_nd|jtkrMtjd|jj|jj�dS|jtkrtjd|jj|jj�dSy)tjd|jjt	j
jj��WnPt
k
r�}tjt	j
jj�r�tjp�tjd|jjd|�nXdS(u�
        Set the minion running flag and issue the appropriate warnings if
        the minion cannot be started or is already running
        u7This %s was scheduled to stop. Not running %s.tune_in()Nu4This %s is already running. Not running %s.tune_in()u%s is starting as user '%s'u)Failed to get the user who is starting %sR.(R<R.R&R(R1R4t	__class__R�R�R@R*R�tget_userR�R�t
is_windowsR�R�tERROR(R�RD((s//usr/lib/python2.7/site-packages/salt/minion.pyt	_pre_tune�s, !cC�swtjjjj|j�}|j|d<z=y|j|�}|SWntk
rct	j
d�dSXWd|j�XdS(u.
        Send mine data to the master
        utoku#Unable to send mine data to master.N(
R@R�R�R|R�R<R�R}RR1R8R.R~(R�R�RoR�R>((s//usr/lib/python2.7/site-packages/salt/minion.pyt
_mine_send	s


	cc�s�	|jstjj��ntjjjj|�\}}t	j
d|jd|�|jd�r�|j
d|jdt�d|jdt��n	|jd�r�|jd|jdt��Vn�|jd	�r�|j�n�|jd
�r�|j�n�|jd�r|j||�n�|jd�r>|j||�na|jd
�r�|jdt�su|j|jdkr�	|jdt�|jd|_q�	n|jd�r�|j||�n�|jd�r�|j||�n�|jd�r=|jr�	t	j
d|d�|j|d|d|d|ddt�q�	nb|jtdd��sm|jtdd��r4|jtdd��r�|d|jdkr�tjj��n|jtdd��rA|d|jddkrtdj|d|jd���qA|d|jddkrAtdj|d���qAn|jr�	t|_t	jd|jd�|jd d!kr|jd"d#kr.id$d%6|jd&d'6td(6d)d*6td+6i|jdd6td,6d-6}|jj d.tdd/d0|jd�d1|�q.q1|jd"d#krC|jj!d.tdd/��nt	jd2�t"|d3�r�|j#j$dQ�t"|j#d4�r�|j#j&j'�nt"|j#d5�r�|j#j(�n|`#nyA|j)d6|jd7td8|jtdd���V\}|_#Wnt*k
rnX|jr||jd<t	jd9|jd�|jj+d:�|jd:<|j,�\|_-|_.|_/|_0|j-|j_-|j#j$|j1�|j2�t	jd;�|jd"d#kr.id$d%6|jd&d'6td(6d)d*6td+6i|jdd6td,6d-6}|jj d.tdd/d0|jd�d1|�|jd<rd|jkr|jd|jddkr�id=d%6|jd>d'6td(6d)d*6td+6i|jddd6d-6}|jj d.tdd�d1|�q|jj!d.tdd�d?t�qq.q1t|_3|j4j5�q�	nk|jtdd,��r |jr�	|jd d!kr�	t	jd@|jd�t|_|jd"d#krid$d%6|jd&d'6td(6d)d*6td+6i|jdd6td,6d-6}|jj d.tdd/d0|jd�d1|�qq�	n|jdA�r�|d:jtdd/d0dB��r�|dCr�t	j
dD|d:j6tdd/d0dB��d)�q�n|j7|dEdFdt�n�|jdG�r�|jr�	t	j
dH|�|j||dt�q�	n�|jdI�r`	t8|dJ�}t	j
dK|tj9j:j;j|�|dL�|dLtj9j:j;t8|dJ�<n?|jdM�r�	|jr�	t	j
dN�|jdO|dP�q�	ndQS(RuO
        Handle an event from the epull_sock (all local minion events)
        u)Minion of '%s' is handling event tag '%s'umasterumodule_refreshRpu
force_refreshReunotifyupillar_refreshubeacons_refreshumatchers_refreshumanage_scheduleumanage_beaconsugrains_refreshugrainsuenviron_setenvu_minion_mineufire_masteruForwarding master event tag=%sutagudataueventsupretagR�R�udisconnectedufailbackumaster_listiu,Bad master '{0}' when mine failback is '{1}'uAlready connected to '{0}'uConnection to master %s lostumaster_typeufailoveru	transportutcpu
status.masterufunctionumaster_alive_intervalusecondsujid_includeiu
maxrunningu
return_jobu	connectedukwargsRualiveRCR�u1Trying to tune in to next master from master-listupub_channeluauthucloseR<R�R�u,Re-initialising subsystems for new master %suscheduleu$Minion is ready to receive requests!umaster_failbackustatus.ping_masterumaster_failback_intervalR[u&Connection to master %s re-establishedu__schedule_returnuureturnuConnected to master %sR�u_returnu_salt_erroru"Forwarding salt error event tag=%susalt/auth/credsukeyu#Updating auth data for %s: %s -> %sucredsu__beacons_returnuFiring beacons to masterR�ubeaconsN(<R@R�R�R�R@R*Rt	SaltEventtunpackR1R;R<R�R�R'R(R�R�R�RRtgrains_cacheR&R"R(R�R�R�R R0R�R�R�RaRTR�ton_recvR.R�t
invalidateR~R�RtoptionR^R�R�R�R�t_handle_payloadR�R5R�R:RyR�R�Rxt	AsyncAutht	creds_map(R�R"R�RoR�RCRu((s//usr/lib/python2.7/site-packages/salt/minion.pyR .	s&			

	20/			(

			)
	
$

(
+		("
-	#$	
cC�s4tj�|jj�|jr0|jj�ndS(u<
        Clean up subprocesses and spawned threads.
        N(tmultiprocessingtactive_childrenR?RZR�tcleanup_subprocesses(R�((s//usr/lib/python2.7/site-packages/salt/minion.pyR4�	s

	cC�s�|js�|j�\|_|_|_|_tjj|j	�|_
|j�|_tj
j|j	�|_|jr�tjj|j	|j�|_ntjjjd|j	jdd��}t|j	dd|�|_|j	d|_t|_ndS(ua
        Set up the core minion attributes.
        This is safe to call multiple times.
        R�uuserucachedirR^ugrainsN(R@R^R�R�R�R�R@R�R�R<R�RdRcRzR�R�R�R�R*R�R�R'R.RaR�R+R&(R�R^((s//usr/lib/python2.7/site-packages/salt/minion.pyR]�	s	$	!'c�s��js
dS�j��jd}d�jkr�tjj�j�j��_�fd�}|rp|�n�jd|�ndS(uR
        Set up the beacons.
        This is safe to call multiple times.
        Nu
loop_intervalubeaconsc�s�d}y�j�j�}Wn$tk
rBtjddt�nX|r�tjj	j
dd�jdt�}|j
i|d6d�|j�ndS(NuThe beacon errored: R.uminionR<tlistenubeaconsu__beacons_return(R.R�R�R�R1R�R&R@R*RRR<R(R�R(R�R(R�(s//usr/lib/python2.7/site-packages/salt/minion.pythandle_beacons
s
		(	R�R]R<RAR@R�R�R�tadd_periodic_callback(R�R,R�R6((R�s//usr/lib/python2.7/site-packages/salt/minion.pyR/
s	


c
�s=�j��jd�d�jkr9d�jkrEi�jd<nt�d�s�tjjj�j�j�j	d�jdt
dd�g��_nyE�jdr�tjd�jd��j
t�jd��nWn#tk
r}tjd	|�nX��fd
�}|r&|�n�jd|�ndS(uT
        Set up the scheduler.
        This is safe to call multiple times.
        u
loop_intervaluscheduleR*RZR�ualiveugrains_refresh_everyu;Enabling the grains refresher. Will run every %d minute(s).u[Exception occurred in attempt to initialize grain refresh routine during minion tune-in: %sc�s�j���dS(N(R�((R�R�(s//usr/lib/python2.7/site-packages/salt/minion.pythandle_scheduleT
sN(R]R<RARTR@R*R�R_R�R�R�R1R;R�tabsR�R4R7(R�R,R�R8((R�R�s//usr/lib/python2.7/site-packages/salt/minion.pyR02
s4

		
!
icC�sH||jkrtStjj||d�|j|<|j|j�tS(u�
        Add a periodic callback to the event loop and call it's start method.
        If a callback by the given name exists this method returns False
        i�(RAR(R�tiolooptPeriodicCallbackR-R&(R�Rtmethodtinterval((s//usr/lib/python2.7/site-packages/salt/minion.pyR7]
s	cC�s3|jj|d�}|dkr%tS|j�tS(u~
        Remove a periodic callback.
        If a callback by the given name does not exist this method returns False
        N(RARNR.R(R:R&(R�RR�((s//usr/lib/python2.7/site-packages/salt/minion.pytremove_periodic_callbackj
s

c�s�j�tjd�jd�|r��jjdt�rO�jdt�n�jjdt�rw�jdt�n�j	�n�j
r��j�tjd�nt
�tr�tjjj�n�j��j��j��jd�j��jjdd	�d
}|d	krX�j
rX�fd�}�jd��jd||�nt�d
�r��jdk	r��jj�j�n(�jjd�dkr�tjd�n|ry'�jj��jr��j �nWqt!t"fk
r�j �qXndS(uk
        Lock onto the publisher. This is the main event loop for the minion
        :rtype : None
        uMinion '%s' trying to tune inuidubeacons_before_connectR,uscheduler_before_connectu$Minion is ready to receive requests!ucleanupu
ping_intervalii<c�s]y/�fd�}�jdddtd|�Wn'tk
rXtjddtj�nXdS(Nc�s��jjdt�r�tjd��jjdd�}tjd|�y�jdt��Wq�tk
rtj	d�q�XndS(Nu
auth_safemodeu5** Master Ping failed. Attempting to restart minion**urandom_reauth_delayiu delaying random_reauth_delay %ssuservice.restartu�ping_interval reached without response from the master, but service.restart could not be run to restart the minion daemon. ping_interval requires that the minion is running under an init system.(
R<R'R(R1R4R�R�R�R|R8(R�tdelay(R�(s//usr/lib/python2.7/site-packages/salt/minion.pytping_timeout_handler�
s

upinguminion_pingR�R�uAttempt to ping master failed.texc_on_loglevel(R�R(R�R1R8R�R�(R@(R�(s//usr/lib/python2.7/site-packages/salt/minion.pytping_master�
s
 
upingupub_channelumaster_typeudisableu;No connection to master found. Scheduled jobs will not run.N(#R'R1R;R<R'R(R/R&R0RXR�R�R�RtHAS_WIN_FUNCTIONSR@R*t
win_functionstenable_ctrl_logoff_handlerR�R7R4R>RTR�R.R,R/R4R�R-R5RRStRuntimeError(R�R-t
ping_intervalRB((R�s//usr/lib/python2.7/site-packages/salt/minion.pyR2v
sD

	





	cC�sn|dk	rj|ddkrj|j|d�rC|j|d�qj|jdrjtjd|d�qjndS(Nuencuaesuloadu
zmq_filteringu8Broadcast message received not for this minion, Load: %s(R.t_target_loadR�R<R1R9(R�R�((s//usr/lib/python2.7/site-packages/salt/minion.pyR/�
s
cC�s�d|ks0d|ks0d|ks0d|kr4tSd|kr�|jjdj|d�d�}|dkrrtS|dd
kr�|jd
t�}||dd|�s�tSq�||d�s�tSn|jd|d�s�tStS(Nutgtujidufunuargutgt_typeu{0}_match.matchugrainu
grain_pcreupillaru	delimitert	delimiteruglob_match.match(ugrainu
grain_pcreupillar(R(R�R'R0R.RR&(R�Rt
match_funcRI((s//usr/lib/python2.7/site-packages/salt/minion.pyRH�
s $	"cC�s�|jtkrdSt|_t|d�r4|`nt|d�r�|jdk	r�|jjd�t|jd�r�|jj�n|`nt|d�r�x'tj	|j
�D]}|j�q�WndS(u&
        Tear down the minion
        Nuscheduleupub_channelucloseuperiodic_callbacks(R<R(RTR�R�R.R,R~RR�RAR:(R�tcb((s//usr/lib/python2.7/site-packages/salt/minion.pyR�
s			cC�s|j�dS(N(R(R�((s//usr/lib/python2.7/site-packages/salt/minion.pyR�
sN(3R�R�RR&R.R�RJR(RXR�R�R�R1RYRdR^R�R�R�R�R�tclassmethodR�R�R�R�R�R�R�R�R�R�R�R�RRR"R'R(R R4R]R/R0R7R>R2R/RHRR(((s//usr/lib/python2.7/site-packages/salt/minion.pyR$BsXT	
	c	>	'M	 �pUV			
					'	$	
	#	�	
	"+
	K			tSyndiccB�sbeZdZd�Zd�Zd�Zd�Zd�Zd�Ze	j
jd��Zd�Z
RS(	u�
    Make a Syndic minion, this minion will use the minion keys on the
    master to authenticate with a higher level master.
    cK�s�|jd�|_t|_t|d<d|d<tt|�j||�tjj	|�|_
t�|_i|_
g|_d|_dS(Nu	interfaceu
auth_safemodeiu
loop_interval(R't_syndic_interfaceR&t_syndicR�RMR�R@R�RtmminionR�tjid_forward_cacheR�t
raw_eventsR.t
pub_future(R�R<RY((s//usr/lib/python2.7/site-packages/salt/minion.pyR�s	

		cC�sbt|jd|jd��d|d<|jdd�|jjdd�kr^|j|�ndS(ub
        Override this method if you wish to handle the decoded data
        differently.
        utoutimeoutiu	master_idiN(R-R'R<t
syndic_cmd(R�Ro((s//usr/lib/python2.7/site-packages/salt/minion.pyR�s''cC�s�d|krd|d<ni}x+dD]#}||kr&||||<q&q&Wd�}tjj|��X|jj|d|d|d|d|d	|d
|dd|jd
d�|�WdQXdS(uM
        Take the now clear load and forward it on to the client cmd
        utgt_typeuglobu	master_iduusercW�stjd|d�tS(NuUnable to forward pub data: %si(R1R8R&(Rc((s//usr/lib/python2.7/site-packages/salt/minion.pyR�0sutgtufunuarguretujidutoR�R�cS�sdS(N(R.(R�((s//usr/lib/python2.7/site-packages/salt/minion.pyR�=sN(u	master_iduuser(R�R�R�tlocalt	pub_asyncR�(R�RoRYtfieldR�((s//usr/lib/python2.7/site-packages/salt/minion.pyRT s&

	
	cC�s�|jdr?|jdj|jdtj��ddt�n|jdj|jdtj��t|jddgd�dt�dS(Nuenable_legacy_startup_eventsuSyndic {0} started at {1}uidusyndic_startR�ustartusyndic(R<R�R0R6R�R(R(R�((s//usr/lib/python2.7/site-packages/salt/minion.pytfire_master_syndic_start@s



cC�s<tjj|jdd|j�|_|jj|j�dS(u�
        Executes the tune_in sequence but omits extra logging and the
        management of the event bus assuming that these are handled outside
        the tune_in sequence
        u_minion_conf_fileR�N(	R@R�tget_local_clientR<R�RUR�R,t_process_cmd_socket(R�((s//usr/lib/python2.7/site-packages/salt/minion.pyttune_in_no_blockVs	cC�sA|dk	r=|ddkr=tjd�|j|d�ndS(NuencuaesuHandling payloaduload(R.R1R9R�(R�R�((s//usr/lib/python2.7/site-packages/salt/minion.pyRZcs
cc�s�t|d�rJ|jjd�t|jd�rA|jj�n|`n|jd|j�V\}|_|jr�||jd<|jj|j�t	j
d�ntjj
|��dS(Nupub_channelucloseR<umasteru$Minion is ready to receive requests!(RTR�R,R.R~R�R<R�RZR1R�R�R�R�(R�RC((s//usr/lib/python2.7/site-packages/salt/minion.pyt	reconnectks		
cC�sNtt|�j�t|d�r+|`nt|d�rJ|jj�ndS(u-
        Tear down the syndic minion
        ulocaluforward_eventsN(R�RMRRTRUtforward_eventsR:(R�((s//usr/lib/python2.7/site-packages/salt/minion.pyR~s
	(R�R�RR�R�RTRXR[RZR�R�R�R\R(((s//usr/lib/python2.7/site-packages/salt/minion.pyRMs	
		 		
	t
SyndicManagercB�s�eZdZdZdZdd�Zd�Zej	j
d��Zd�Zdddd�Z
dd�Zdd�Zd	�Zd
�Zd�Zd�Zd
�ZRS(u�
    Make a MultiMaster syndic minion, this minion will handle relaying jobs and returns from
    all minions connected to it to the list of masters it is connected to.

    Modes (controlled by `syndic_mode`:
        sync: This mode will synchronize all events and publishes from higher level masters
        cluster: This mode will only sync job publishes and returns

    Note: jobs will be returned best-effort to the requesting master. This also means
    (since we are using zmq) that if a job was fired and the master disconnects
    between the publish and return, that the return will end up in a zmq buffer
    in this Syndic headed to that original master.

    In addition, since these classes all seem to use a mix of blocking and non-blocking
    calls (with varying timeouts along the way) this daemon does not handle failure well,
    it will (under most circumstances) stall the daemon for ~15s trying to forward events
    to the down master
    icC�s�d|d<tt|�j|�tjj|�|_|jjdd�|_	|jjdd�|_
|jd|_|jd|_t
j�|_t�|_|dkr�t�tj�|_n	||_g|_i|_g|_i|_dS(	Niu
loop_intervalusyndic_modeusyncusyndic_failoverurandomuacceptance_wait_timeuacceptance_wait_time_max(R�R^R�R@R�RRPR<R'tsyndic_modetsyndic_failoverRRR�tEventt_has_masterR�RQR.RR
R�R�RRtjob_retstdelayedtpub_futures(R�R<R�((s//usr/lib/python2.7/site-packages/salt/minion.pyR��s"
				cC�s{t�|_|jd}t|t�s4|g}nx@|D]8}tj|j�}||d<|j|�|j|<q;WdS(uI
        Spawn all the coroutines which will sign in the syndics
        umasterN(Rt_syndicsR<ReR~R�t_connect_syndic(R�R�RCR*((s//usr/lib/python2.7/site-packages/salt/minion.pyt_spawn_syndics�s


cc�sdd}|d}t}x5trMtjd|d�ybt|d|jdtd|j�}|jd|�V|j�|j	�tj
d	|d�PWqtk
r}t}tjd
|d�t
j
�}||jkr�||j7}ntjj|�Vqttfk
r�qtk
rIt}tjd|ddt�qXqWtjj|��d
S(uL
        Create a syndic, and asynchronously connect it to a master
        iuacceptance_wait_timeu"Syndic attempting to connect to %sumasterR�R�R�R�u#Syndic successfully connected to %suPError while bringing up syndic for multi-syndic. Is the master at %s responding?u'Unexpected error while connecting to %sR.N(R(R&R1R;RMtSYNDIC_CONNECT_TIMEOUTR�R1R[RXR�RR4R6RRR�R�R7RSt
SystemExitR�R�R�(R�R<R3RR�tsyndicR�((s//usr/lib/python2.7/site-packages/salt/minion.pyRg�sH
			


cC�sP|j|j�r<|j|j�}|j�|j|<ntjd|�dS(uL
        Mark a master as dead. This will start the sign-in routine
        uAAttempting to mark %s as dead, although it is already marked deadN(RfRTtresultR\R1R�(R�RCRk((s//usr/lib/python2.7/site-packages/salt/minion.pyt_mark_master_deadscC�s�|dkri}nt}x�|j|�D]�\}}|j�sP|j�ritjd||�q+ny&t|j�|�||�t	}Wq+t
k
r�tjd||�|j|�q+Xq+W|s�tjd|�ndS(ud
        Wrapper to call a given func on a syndic, best effort to get the one you asked for
        u5Unable to call %s on %s, that syndic is not connectedu*Unable to call %s on %s, trying another...u!Unable to call %s on any masters!N(
R.R(titer_master_optionsRTRUR1R4R�RlR&RRmR�(R�RnRcRYt	master_idt
successfulRCt
syndic_future((s//usr/lib/python2.7/site-packages/salt/minion.pyt_call_syndics&	



c	C�s8d}x+|j|�D]\}}|j�s;|j�rTtjd||�qn|jj|d�\}}|dk	r�|j�s�||krtSqq�|j�r�tjd||�|j	|�|j|=|j
j|�qq�nt|j
�|�|dd|j�dt�}||f|j|<tSWtS(	ul
        Wrapper to call the '_return_pub_multi' a syndic, best effort to get the one you asked for
        u_return_pub_multiu5Unable to call %s on %s, that syndic is not connectedu*Unable to call %s on %s, trying another...u_syndic_returnR�R�N(NN(RnRTRUR1R4ReR'R.R(RmRdtextendR�RlR�R&(R�tvaluesRoRnRCRqRORo((s//usr/lib/python2.7/site-packages/salt/minion.pyt_return_pub_syndic.s8



		cc�s�t|jj��}|jddkr5t|�n||jkrV|jd�}n
|j|�x5tr�||j|fV|s�Pn|jd�}qfWdS(uA
        Iterate (in order) over your options for master
        usyndic_failoverurandomiN(R~RftkeysR<RRNR�R&(R�RoR�((s//usr/lib/python2.7/site-packages/salt/minion.pyRnXs

	cC�si|_g|_dS(N(RcRR(R�((s//usr/lib/python2.7/site-packages/salt/minion.pyt_reset_event_aggregationjs	cC�s2|jjj|j�}|jj||j�dS(N(RURRt_process_eventR�t
add_futuretreconnect_event_bus(R�t	somethingRO((s//usr/lib/python2.7/site-packages/salt/minion.pyRznscC�s�|j�tjj|jdd|j�|_|jjjd�t	j
d|jd�i|_g|_|j
�|jjj|j�}|jj||j�tjj|j|jdd�|_|jj�t�|jj�dS(	uU
        Lock onto the publisher. This is the main event loop for the syndic
        u_minion_conf_fileR�uu$SyndicManager '%s' trying to tune inuidusyndic_event_forward_timeouti�N(RhR@R�RYR<R�RURRR1R;RcRRRwRRxRyRzR�R:R;t_forward_eventsR]R-R(R�RO((s//usr/lib/python2.7/site-packages/salt/minion.pyR2ss
			

c	C�s�|jjj||jjj�\}}tjd|�|jd�}t|�dkrk|ddkrktj	j
j|d�rk|ddkrkd	|krkd
|kr�dS|jdkr�|j
dd
�|jj
dd�kr�tjd�dS|j
d�}|jj|i�j|i�}|s
|j
d�|d<|d
|d<i|d<dj|jd�}|d
|jkr
|dj|jj||d
��|jj|d
�t|j�|jdkr
tt|j��}|jd
�t|�|_q
q
n|dk	r&||d<ni}	x+dD]#}
|
|kr3||
|	|
<q3q3W|	||d<n?|jdkr�d|kr�|jji|d6|d6�q�ndS(NuGot event %su/iiujobiiuretureturnujiduclusteru	master_idiu7Return received with matching master_id, not forwardingufunu__fun__u__jid__u__load__u{0}.get_loadumaster_job_cacheusyndic_jid_forward_cache_hwmu
__master_id__uretcodeusuccessuidusyncudatautag(ureturnuretcodeusuccess(RURR*R�R1R9RyR�R@R*R�tis_jidR_R'R<R;RcR�R0RQRHRPR�R�tsortedR~RNR�R.RRRi(R�trawtmtagRot	tag_partsRCtjdicttfstrttmpR>Ru((s//usr/lib/python2.7/site-packages/salt/minion.pyRx�sH'")6
!




cC�stjd�|jrs|j}g|_|jddi|d6t|jddd�d6|j�d	6td
6�n|jr�|j	|j�}|r�g|_q�nxdt
tj|j
��D]J}t
tj|j
|��}|j	|d|�}|r�|j
|=q�q�WdS(NuForwarding eventsu_fire_masterRYueventsuidtbaseusyndicupretagutimeoutusyncRo(R1R9RRRrRR<R�R(RdRuR~RRlRcR�(R�R�tresRCRt((s//usr/lib/python2.7/site-packages/salt/minion.pyR|�s$
			

	N((R�R�RRitSYNDIC_EVENT_TIMEOUTR.R�RhR�R�R�RgRmRrRuRnRwRzR2RxR|(((s//usr/lib/python2.7/site-packages/salt/minion.pyR^�s	
4	*				4tProxyMinionManagercB�s eZdZdddd�ZRS(uA
    Create the multi-minion interface but for proxy minions
    c
C�s"t|||d|d|d|�S(uF
        Helper function to return the correct type of object
        R�R#R(tProxyMinion(R�R<R�R�R�R#R((s//usr/lib/python2.7/site-packages/salt/minion.pyR%�sN(R�R�RR.R%(((s//usr/lib/python2.7/site-packages/salt/minion.pyR��scC�sstjj|�}y|d}Wn:tk
r\d}d|ddd}tj|�nX|d|}||S(Nu	metaproxyuproxyu&No metaproxy key found in opts for id uidu. u#Defaulting to standard proxy minionu.(R@Rzt	metaproxyR|R1R9(R<tfn_nameR�tmetaproxy_nameterrmsgtmetaproxy_fn((s//usr/lib/python2.7/site-packages/salt/minion.pyt_metaproxy_call�s
R�cB�sweZdZejjd��Zd�Zd�Zejjd��Z	e
d��Ze
d��Ze
d��Z
RS(u�
    This class instantiates a 'proxy' minion--a minion that does not manipulate
    the host it runs on, but instead manipulates a device that cannot run a minion.
    cC�st|jd�}|||�S(u�
        Function to finish init after connecting to a master

        This is primarily loading modules, pillars, etc. (since they need
        to know which master they connected to)

        If this function is changed, please check Minion._post_master_init
        to see if those changes need to be propagated.

        ProxyMinions need a significantly different post master setup,
        which is why the differences are not factored out into separate helper
        functions.
        upost_master_init(R�R<(R�RCtmp_call((s//usr/lib/python2.7/site-packages/salt/minion.pyRY
scC�st|jd�}|||�S(uQ
        Verify that the publication is valid and applies to this minion
        utarget_load(R�R<(R�RR�((s//usr/lib/python2.7/site-packages/salt/minion.pyRH
scC�st|jd�}|||�S(Nuhandle_payload(R�R<(R�R�R�((s//usr/lib/python2.7/site-packages/salt/minion.pyR/
scC�st|jd�}|||�S(Nuhandle_decoded_payload(R�R<(R�RoR�((s//usr/lib/python2.7/site-packages/salt/minion.pyR� 
scC�s%t|d�}||||||�S(Nutarget(R�(R�R�R<RoR�R�((s//usr/lib/python2.7/site-packages/salt/minion.pyR�%
scC�s"t|d�}|||||�S(Nu
thread_return(R�(R�R�R<RoR�((s//usr/lib/python2.7/site-packages/salt/minion.pyR�+
scC�s"t|d�}|||||�S(Nuthread_multi_return(R�(R�R�R<RoR�((s//usr/lib/python2.7/site-packages/salt/minion.pyR�0
s(R�R�RR�R�R�RYRHR/R�RLR�R�R�(((s//usr/lib/python2.7/site-packages/salt/minion.pyR��s		tSProxyMinioncB�seZdZed�ZRS(u
    Create an object that has loaded all of the minion module functions,
    grains, modules, returners etc.  The SProxyMinion allows developers to
    generate all of the salt minion functions and present them with these
    functions for general use.
    c	C�s�tjj|j�|jd<tjj|j|jd|jdd|jdd|jjd��j�|jd<d|jdkr�d|jkr�d	jd
|jd�}t	j
|�t|_t
dtjjjd|��nd|jkr
|jdd|jd<ntjj|j�|_tjj|jd
|j�|_tjj|jd|jdtd
|j�|_tjj|j|jd
|j�|_tjj|j�|_|j|jd<tjj|j|jd
|j�|_|jdd}|jdd|jd�|j|jjd<|j|jjd<|j|jjd<|jd|jjd<tjj|jd
|j�|_|j|jjd<|jj�dj|�|jks�dj|�|jkr#dj|�d}t	j
|�t|_t
dtjjjd|��n|jjdj|�d���|_|j|d}||j�tjj|jd
|j�|jd<|jddd �|jd|_t|_d!S("u�
        Tell the minion to reload the execution modules

        CLI Example:

        .. code-block:: bash

            salt '*' sys.reload_modules
        ugrainsuidtsaltenvusaltenvR�u	pillarenvupillaruproxyu�No "proxy" configuration key found in pillar or opts dictionaries for id {id}. Check your pillar/options configuration and contents. Salt-proxy aborted.tidR"R#R�R*Reusys.reload_modulesu	proxytypeusaltutil.sync_allu	__proxy__u__salt__u__ret__u
__pillar__u	__utils__u{0}.initu{0}.shutdownu>Proxymodule {0} is missing an init() or a shutdown() or both. u,Check your proxymodule.  Salt-proxy aborted.u{0}.module_executorscS�sgS(N((((s//usr/lib/python2.7/site-packages/salt/minion.pyR��
su.initusaltutil.sync_grainsubaseN(R@RzR�R<R�R�R'R�R0R1R4R(R<RR�R�R�R�R*R�R�R�R�R�R�R�treload_modulestmodule_executorsR+R&R@(R�R�R�tfq_proxynamet
proxy_init_fn((s//usr/lib/python2.7/site-packages/salt/minion.pyR�=
sZ
	


""	
	!!0''!

	!'
%(R�R�RR(R�(((s//usr/lib/python2.7/site-packages/salt/minion.pyR�6
s(�Rt
__future__RRRRR�RKR�R�R6R�RFRCR�R�R�R�R2RRRQRtsalt.serializers.msgpackR@tbinasciiRtsalt.extRtsalt._compatR	R)R
tsalt.ext.six.movesRtsalt.utils.zeromqRR
RRtsalt.transport.clienttsalt.defaults.exitcodestsalt.utils.ctxRR�R(Rftsalt.utils.psutil_compatR*t
psutil_compatRkR&tImportErrorRgRhtzmq.utils.monitortHAS_ZMQ_MONITORtsalt.utils.win_functionsRCtsalt.clientt
salt.cryptR�tsalt.beaconstsalt.enginestsalt.payloadtsalt.pillart
salt.syspathstsalt.utils.argstsalt.utils.contexttsalt.utils.datatsalt.utils.errortsalt.utils.eventtsalt.utils.filestsalt.utils.jidtsalt.utils.miniontsalt.utils.minionstsalt.utils.platformtsalt.utils.processtsalt.utils.scheduletsalt.utils.ssdptsalt.utils.usertsalt.cli.daemonstsalt.log.setuptsalt.utils.dictupdatetsalt.configRt
salt.defaultsRtsalt.utils.debugRRtsalt.utils.odictRRRRtsalt.exceptionsRRRRRRRR R!ttornado.genttornado.ioloopt	getLoggerR�R1RFRJRaR.RxR�R�R�tobjectR�R�RRR$RMR^R�R�R�R�(((s//usr/lib/python2.7/site-packages/salt/minion.pyt<module>s�""









@
m		34		��,=����������P	:

Zerion Mini Shell 1.0