%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@sjdZddlmZmZmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZ
ddlZ
ddl
Z
ddlZ
ddlZ
ddlZ
ddlZ
ddlZ
ddlZ
ddljjZddlZ
ddlZ
ddlZ
ddlZ
ddlmZddlmZddlm Z ddl!m"Z"yXddl#m$Z$m%Z%dd	l&m'Z'dd
l(m)Z)m*Z*e �r�ddl+Z+nWne,k
r�nXddl-m.Z.ddl/m0Z0m1Z1m2Z2m3Z3ej4e5�Z6d
e7fd��YZ8de7fd��YZ9de9fd��YZ:d�Z;de9fd��YZ<dS(u]
The caller module is used as a front-end to manage direct calls to the salt
minion modules.
i(tabsolute_importtprint_functiontunicode_literalsN(tdaemons(t
LOG_LEVELS(t
is_windows(tMultiprocessingProcess(traetingtnacling(t	LaneStack(t
RemoteYardtYard(tsix(tSaltClientErrortCommandNotFoundErrortCommandExecutionErrortSaltInvocationErrortCallercB@seZdZed��ZRS(uK
    Factory class to create salt-call callers for different transport
    cK@s�d}d|kr|d}n9d|jdi�jdi�krX|ddd}n|d	krqt||�S|dkr�t||�Std��dS(
Nuzeromqu	transportupillarumasterutcpudetecturaetu,Callers are only defined for ZeroMQ and raet(uzeromqutcpudetect(tgettZeroMQCallert
RAETCallert	Exception(toptstkwargstttype((s3/usr/lib/python2.7/site-packages/salt/cli/caller.pytfactoryCs
$

(t__name__t
__module__t__doc__tstaticmethodR(((s3/usr/lib/python2.7/site-packages/salt/cli/caller.pyR?st
BaseCallercB@s;eZdZd�Zd�Zd�Zd�Zd�ZRS(u*
    Base class for caller transports
    cC@s�||_t|jd<tjj|j�|_yC|jjd�r[tjj|�|_ntjj	|�|_Wn(t
k
r�}ttj
|���nXdS(u+
        Pass in command line opts
        ucalleruproxyidN(RtTruetsalttpayloadtSerialtserialRtminiontSProxyMiniontSMinionR
t
SystemExitRt	text_type(tselfRtexc((s3/usr/lib/python2.7/site-packages/salt/cli/caller.pyt__init__\s	
cC@s�i}xKtj|jj�D]4\}}||kr|jrP|j||<qPqqWxXt|�D]J}|j|jjdd��rat	j
jjdj
|||��qaqaWdS(uT
        Pick up the documentation for all of the modules and print it out.
        ufunuu	{0}:
{1}
N(Rt	iteritemsR$t	functionsRtsortedt
startswithRRR tutilststringutilst	print_clitformat(R)tdocstnametfunc((s3/usr/lib/python2.7/site-packages/salt/cli/caller.pyt
print_docsns"	cC@sN|jjjd�p'tjj|j�}tjji|d6d|j�dS(u&
        Print out the grains
        ugrainsulocalN(R$RRR tloadertgrainstoutputtdisplay_output(R)R9((s3/usr/lib/python2.7/site-packages/salt/cli/caller.pytprint_grains{s*c
C@si|jjdt�}y.tjjj|�}z|j�}Wdtjjj|d|jjdd�dt	�X|jdd�}|jd	r�|}d}n|jd
i�}tj
ji|d6d|d
|jd|jdd��|jjdt�rtj
|d�n2|dtjjjkrBtj
tjjj�nWntk
rd}t|��nXdS(u-
        Execute the salt call logic
        uprofiling_enabledNt
stats_pathuprofiling_pathu
/tmp/statststopuoutunesteduprint_metadataureturnulocaltoutRt_retcodeuretcodeiuretcode_passthrough(RRtFalseR R0tprofiletactivate_profiletcalltoutput_profileRR:R;tsystexittdefaultst	exitcodestEX_OKt
EX_GENERICRR'(R)tprofiling_enabledtprtretR?t	print_retterr((s3/usr/lib/python2.7/site-packages/salt/cli/caller.pytrun�s2
		
	c@s&i�|jd}tjjj|j��d<tjjtjj	|jd��d�}||jj
krM|jj
ddj|��}|r�|jj
j|�||<d�d<|�d<�St
jj|jj
j|��|jd	�d
}||jjkr-t
jjdj|jj|��nt
jjd�t
jd
�n|jjd�}|dk	r�tjjj|�}ny�i|d6tj�d6�dd6dd6}|dk	r�||d<ntjj|jj
|tjjj|jdd|jjdg��d|�\}}y>tjjj|d�� }	|	j|jj|��WdQXWn:tk
rrn*tk
r�t
jjdj|��nX|jj
|}
i|d6|d6}|j |�t!|jdg�ptjjj|jjdd��}|jjdd�r>tjjj|jd�|d<nt"|t#j$�r\|g}ny�x�|D]|}
dj|
�}||jj%kr�t&dj|
���n|jj%||j||
||��d<�ddk	rfPqfqfWWn�t'k
r�}t
jjdj|��tjj(j)|
j*�t+j|jdj,�t-j.�}|t-j/krxt0j1�}t
jj|�nt
jtj2j3j4�nXy#t
j5|
j6j7jd d
�}Wn t8k
r�tj2j3j4}nX|d
kr9y t9�fd!�d2D��}Wnt:k
rt;}nX|s9tj2j3j4}q9n|�d <Wn�t<k
r�}d$}t+j|jdj,�t-j.�}|t-j/kr�t
jjt0j1��nt
jj|j||��t
jtj2j3j4�nKt=k
r%}d%}t
jj|j||��t
jtj2j3j4�nXytj>|�Wntt?fk
rPnXt@|jj
|d&�r�|jj
|jA}t"|t#j$�r�|�d<q�n|jd'p�|jjd(tB�d'kp�|jjd)�d*k}|jjdd+�jd,�}|s
|rR|jd-�d-<|�d<|jd�d.<|dk	rR|�d<qRnxY|D]Q}|skqYny+t;�d#<|jjCd/j|���WqYt:k
r�qYXqYW|s�y'�jD�}d0|d<|jE|�Wq"t:k
r�q"Xn0|jd1r"tjjjF|j�d��n�S(3u!
        Call the module
        ufunujiducachedirusys.docu{0}*unesteduoutureturnu.iu Possible reasons: {0}
u
i����umetadataupidu	salt-callutgtuargtno_parseuno_parsetdatauw+bNuMCannot write to process directory. Do you have permissions to write to {0} ?
umodule_executorsu
[direct_call]u
executor_optsu{0}.executeuExecutor '{0}' is not availableu(
Passed invalid arguments: {0}.

Usage:
u	log_leveluretcodec3@s%|]}�dj|t�VqdS(ureturnN(RR(t.0tx(RN(s3/usr/lib/python2.7/site-packages/salt/cli/caller.pys	<genexpr>suresultusuccessuError running '{0}': {1}
u*Command required for '{0}' not found: {1}
u
__outputter__ulocalufile_clientumaster_typeudisableuu,uidufun_argsu{0}.returnerurequ
cache_jobs(uresultusuccess(GRR R0tjidtgen_jidtostpathtjoinR$tget_proc_dirR-R3tmissing_fun_stringRFtstderrtwritetsplittfunction_errorsRGRtNonetargstyamlify_argtgetpidtload_args_and_kwargstparse_inputtfilestfopenR#tdumpst	NameErrortIOErrortupdatetgetattrt
isinstanceRtstring_typest	executorsRt	TypeErrorR1R2RRtlowertloggingtERRORtDEBUGt	tracebackt
format_excRHRIRKtmodulesRt__context__tAttributeErrortallRRRRtremovetOSErrorthasattrt
__outputter__RAt	returnerstcopyt
return_pubt
cache_jobs(R)tfuntproc_fnR4tmod_nametmetadatatsdataRbRtfp_R6RSRpR5tfnameR*tactive_levelttracetretcodetfunc_resulttmsgtoputtis_localR�treturnertmret((RNs3/usr/lib/python2.7/site-packages/salt/cli/caller.pyRD�s
	


&


	

#

	


)






!



#(RRRR+R7R<RQRD(((s3/usr/lib/python2.7/site-packages/salt/cli/caller.pyRXs		
		!RcB@s eZdZd�Zd�ZRS(uT
    Object to wrap the calling of local salt modules for the salt-call command
    cC@stt|�j|�dS(u2
        Pass in the command line options
        N(tsuperRR+(R)R((s3/usr/lib/python2.7/site-packages/salt/cli/caller.pyR+HscC@s�tjjjj|jdd�}idd6|jdd6}x'tj|�D]\}}|||<qLWz|j|�Wd|j	�XdS(u2
        Return the data up to the master
        tusageu	salt_callu_returnucmduidN(
R t	transporttclientt
ReqChannelRRRR,tsendtclose(R)RNtchanneltloadtkeytvalue((s3/usr/lib/python2.7/site-packages/salt/cli/caller.pyR�Ns!(RRRR+R�(((s3/usr/lib/python2.7/site-packages/salt/cli/caller.pyRDs	cC@s tj�}|jd|�dS(u�
    Set up the minion caller. Should be run in its own process.
    This function is intentionally left out of RAETCaller. This will avoid
    needing to pickle the RAETCaller object on Windows.
    tcleanup_protectedsN(RtMinionRD(R�R$((s3/usr/lib/python2.7/site-packages/salt/cli/caller.pytraet_minion_run\sRcB@s2eZdZd�Zd�Zd�Zd�ZRS(u�
    Object to wrap the calling of local salt modules for the salt-call command
    when transport is raet

    There are two operation modes.
    1) Use a preexisting minion
    2) Set up a special caller minion if no preexisting minion
        The special caller minion is a subset whose only function is to perform
        Salt-calls with raet as the transport
        The essentials:
            A RoadStack whose local estate name is of the form "role_kind" where:
               role is the minion id opts['id']
               kind is opts['__role'] which should be 'caller' APPL_KIND_NAMES
               The RoadStack if for communication to/from a master

            A LaneStack with manor yard so that RaetChannels created by the func Jobbers
            can communicate through this manor yard then through the
            RoadStack to/from a master

            A Router to route between the stacks (Road and Lane)

            These are all managed via a FloScript named caller.flo

    cC@s�d|_|ds�|j|�|_|jtj_|jd�tj	tj
jkr�tdt
di|jjgd6�|_|jj�|j|�q�ntt|�j|�dS(u2
        Pass in the command line options
        ulocalu__rolettargetRucleanup_protectedsN(Ratprocesst_setup_caller_stacktstackR R�tjobber_stackRtkindstAPPL_KIND_NAMESt	applKindstcallerRR�thatstartt_wait_callerR�RR+(R)R((s3/usr/lib/python2.7/site-packages/salt/cli/caller.pyR+s	

c
C@sKy%|j�}|jds;|jjj�dtj_n|jdrQ|}n|j	di�}|j
r||j
j�ntjj
i|d6d|j	dd�d|jd|j	d	tjjj��|jj	d
t�r�tj|d	�n2|d	tjjjkr$tjtjjj�nWntk
rF}t|��nXdS(u-
        Execute the salt call logic
        ulocaluprint_metadataureturnR?uoutunestedRR@uretcodeuretcode_passthroughN(RDRR�tserverR�RaR R�R�RR�t	terminateR:R;RHRIRJRARFRGRKRR'(R)RNRORP((s3/usr/lib/python2.7/site-packages/salt/cli/caller.pyRQ�s*

			
	c	
C@s�|jd�}|s;d}tj|d�t|��n|jd�}|tjkr�dj|�}tj|d�t|��n|tjtjj	tjtjj
gkr�dj||�}n,dj|�}tj|d�t|��|d}d	tjd
d�}t
d|d
|d|�}tjjj|_|jtd|ddd
|d|��tjd|j�|S(u�
        Setup and return the LaneStack and Yard used by by channel when global
        not already setup such as in salt-call to communicate to-from the minion

        uidu+Missing role required to setup RAETChannel.u
u__roleu1Invalid application kind = '{0}' for RAETChannel.u{0}_{1}u3Unsupported application kind '{0}' for RAETChannel.usock_dirucallertsizeiR5tlanenametsockdirpathR�umanortdirpathuCreated Caller Jobber Stack %s
(Rtlogterrort
ValueErrorR�t
APPL_KINDSR3R�R�R$R�RtuuidR	RtPackKindtpackR�tPkt	addRemoteR
tdebugR5(	R)RtroletemsgtkindR�R�t	stacknameR�((s3/usr/lib/python2.7/site-packages/salt/cli/caller.pyR��s8
	
cC@sd}|d}|jd�}|sKd}tj|d�t|��n|jd�}|tjkr�dj|�}tj|d�t|��n|tjtjj	tjtjj
gkr�dj||�}n,d	j|�}tj|d�t|��tj|||�\}}t
�r�t}	x�|	s�yHtj|tjtjBtjd
tjd
d
�}
tj|
�t}	Wq2tjk
r�tjd�q2Xq2WnLxItjj|�o�tjj|�o�tjj|�s�tjd�q�Wtjd�d
S(u<
        Returns when RAET Minion Yard is available
        umanorusock_diruidu/Missing role required to setup RAET SaltCaller.u
u__roleu5Invalid application kind = '{0}' for RAET SaltCaller.u{0}_{1}u7Unsupported application kind '{0}' for RAET SaltCaller.ig�������?g�?N(RR�R�R�R�R�R3R�R�R$R�Rt	computeHaRRAt	win32filet
CreateFilet
GENERIC_WRITEtGENERIC_READtFILE_SHARE_READRat
OPEN_EXISTINGtCloseHandleRttimetsleepRXRYtexiststisfiletisdir(R)RtyardnameR�R�R�R�R�R�R�tf((s3/usr/lib/python2.7/site-packages/salt/cli/caller.pyR��sP
		
	

(RRRR+RQR�R�(((s3/usr/lib/python2.7/site-packages/salt/cli/caller.pyRfs
			((=Rt
__future__RRRRXRFR�RsRvR tsalt.loadertsalt.miniontsalt.outputtsalt.payloadtsalt.transporttsalt.transport.clienttsalt.utils.argstsalt.utils.filestsalt.utils.jidtsalt.utils.kindsR0R�tsalt.utils.miniontsalt.utils.profiletsalt.utils.stringutilstsalt.defaults.exitcodestsalt.cliRtsalt.logRtsalt.utils.platformRtsalt.utils.processRtraetRRtraet.lane.stackingR	traet.lane.yardingR
RR�tImportErrortsalt.extRtsalt.exceptionsR
RRRt	getLoggerRR�tobjectRRRR�R(((s3/usr/lib/python2.7/site-packages/salt/cli/caller.pyt<module>sR	
"�	

Zerion Mini Shell 1.0