%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlmZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Zddl!m"Z"ddl#m$Z$m%Z%ddl&m'Z'ddlm(Z(m)Z)m*Z*m+Z+m,Z,ddl-Z(ddl.Z(ddl/Z(yddl0Z(e1Z2Wne3k
re4Z2nXddl5Z5ddl6Z5ddl7Z5ydd	l8m9Z9e1Z:WnOe3k
r�e4Z:ydd
l;m<Z<Wn!e3k
r�dd
l=m<Z<nXnXej>e?�Z@eAeAd�ZBdejCjDjEfd
��YZFdejCjGjHjIejCjDjJfd��YZKdejCjGjHjLejCjMjNfd��YZOd�ZPdejCjMjQfd��YZRdejCjSfd��YZTdeUfd��YZVdeUfd��YZWdS(u
Zeromq transport classes
i(tabsolute_importtprint_functiontunicode_literalsN(trandint(tsix(tSaltReqTimeoutErrort
SaltException(t	ipaddress(tzmqtZMQDefaultLooptinstall_zmqtZMQ_VERSION_INFOtLIBZMQ_VERSION_INFO(tRSA(t
PKCS1_OAEPcC@s`ddlm}djd||�d|�}|s:|r\tdkr2tdkr2|r�|r�d
jd||�d|d||�d|�}qY|r�|r�d
jd||�d||�d|�}qY|rY|rYtj|�jdkr�dn	|d�}djd|d|d||�d|�}qYq\tj	d�tj	d�tj	d�n|S(uR
    Return the ZeroMQ URI to connect the Minion to the Master.
    It supports different source IP / port, given the ZeroMQ syntax:
    // Connecting using a IP address and bind to an IP address
    rc = zmq_connect(socket, "tcp://192.168.1.17:5555;192.168.1.1:5555"); assert (rc == 0);
    Source: http://api.zeromq.org/4-1:zmq-tcp
    i(t
ip_bracketutcp://{master_ip}:{master_port}t	master_iptmaster_portiiiiu9tcp://{source_ip}:{source_port};{master_ip}:{master_port}t	source_iptsource_portu-tcp://{source_ip}:0;{master_ip}:{master_port}u0.0.0.0u::u6tcp://{ip_any}:{source_port};{master_ip}:{master_port}tip_anyuAUnable to connect to the Master using a specific source IP / portu9Consider upgrading to pyzmq >= 16.0.1 and libzmq >= 4.1.6uVSpecific source IP / port for connecting to master returner port: configuraion ignored(iii(iii(
tsalt.utils.zeromqRtformatRRRt
ip_addresstversiontlogtwarning(RRRRRt
master_uriR((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyt_get_master_uriFs,		
	
*	

tAsyncZeroMQReqChannelcB@s�eZdZej�Zd�Zd�Zed��Z	d�Z
d�Zd�Zd�Z
ed��Zd	�Zejjdd
dd��Zejjd
ded
��Zejjd
dd��Zejjd
ded��ZRS(uZ
    Encapsulate sending routines to ZeroMQ.

    ZMQ Channels default to 'crypt=aes'
    cK@sB|jd�}|dkr1t�tj�}n||jkrVtj�|j|<n|j|}|j||�}|j|�}|dkrt	j
d|�tj|�}|j
||�||_|||<d|_tj�|_t	jdt|�|tj��n/|j�|jd7_WdQXt	j
d|�|S(uA
        Only create one instance of channel per __key()
        uio_loopu-Initializing new AsyncZeroMQReqChannel for %siuCInserted key into loop_instance_map id %s for key %s and process %sNu%Re-using AsyncZeroMQReqChannel for %s(tgettNoneR
R	tcurrenttinstance_maptweakreftWeakValueDictionaryt_AsyncZeroMQReqChannel__keyRtdebugtobjectt__new__t__singleton_init__t
_instance_keyt	_refcountt	threadingtRLockt_refcount_lockttracetidtostgetpid(tclstoptstkwargstio_looptloop_instance_maptkeytobj((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyR'ys.
	
		
cC@s�|j}|j|tj|j|��}||t|�<x�|jD]�}|dkr\qDn|dkr�t||t|jd|j|j	fdi|j
d6��qDnt||tj|j||��qDW|S(	Nu_io_loopu	_refcountu_refcount_lockumessage_clienttargsR4uio_loop(u_io_loopu	_refcountu_refcount_lock(t	__class__R'tcopytdeepcopyR3R/t__dict__tsetattrtAsyncReqMessageClientPoolRt_io_loop(tselftmemoR2tresultR7((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyt__deepcopy__�s	!	'cK@s9|d|d|jd|jd��|jdd�fS(Nupki_diruidu
master_uriucryptuaes(R(R2R3R4((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyt__key�scK@sdS(N((RAR3R4((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyt__init__�scK@st|�|_d|_|jdd�|_d|krM|d|jd<n|jd�|_|jdkr�t�tj	�|_n|jdkr�t
jj|jd|j�|_nt
jd|j�t|jd	|j|jfd
i|jd6�|_t|_dS(Nuzeromqucryptuaesu
master_uriuio_loopuclearR5uCConnecting the Minion to the Master URI (for the return server): %sR9R4(tdictR3tttypeRtcryptR@RR
R	R tsaltt	AsyncAuthtauthRR%RR?tmessage_clienttFalset_closing(RAR3R4((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyR(�s 	$cC@s�|jr
dS|jdkrU|j�|jd8_WdQXtjd|jj�dStjd|jj�t|_t|d�r�|j	j
�n|j|jjkr�|jj|j}|j
|kr�||j
=n|s�|jj|j=q�ndS(u�
        Since the message_client creates sockets and assigns them to the IOLoop we have to
        specifically destroy them, since we aren't the only ones with references to the FDs
        Niu2This is not the last %s instance. Not closing yet.uClosing %s instanceumessage_client(ROR*R-RR%R:t__name__tTruethasattrRMtcloseR@R!R)(RAR6((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyRS�s&	

	
cC@s\|j�d|_WdQXy|j�Wn.tjk
rW}|jtjkrX�qXnXdS(Ni(R-R*RStsocketterrorterrnotEBADF(RAtexc((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyt__del__�s
cC@sxd|jkr|jdSd|jkrht|jd|jdd|jjd�d|jjd��Std��dS(	Nu
master_uriu	master_ipumaster_portRu	source_ipRusource_ret_portu5ReqChannel: missing master_uri/master_ip in self.opts(R3RRR(RA((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyRs

cC@si|jd6|d6S(Nuencuload(RI(RAtload((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyt
_package_loads
ii<cc@s]|jjs|jj�Vn|jj|j|jjj|��d|d|�V}|jj�}d|kr�|jj�V|jj|j|jjj|��d|d|�V}nt	r�|j
|dtj�}n"t
j|�}|j|d�}tjj|j|�}	|	j||�}
tjrGtjjj|
�}
ntjj|
��dS(Nttimeoutttriesukey(RLt
authenticatedtauthenticateRMtsendR[t	crypticletdumpstget_keystHAS_M2tprivate_decryptR
tpkcs1_oaep_paddingRtnewtdecryptRJRIt	CrypticleR3tloadsRtPY3t	transporttframetdecode_embedded_strsttornadotgentReturn(RARZtdictkeyR]R\tretR7taestciphertpcrypttdata((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyt!crypted_transfer_decode_dictentrys.	
	

	c#@s�tjj�����fd��}�jjsD�jj�Vny|�V}Wn/tjjk
r��jj�V|�V}nXtjj	|��dS(u�
        Send a load across the wire, with encryption

        In case of authentication errors, try to renegotiate authentication
        and retry the method.

        Indeed, we can fail too early in case of a master restart during a
        minion state execution call

        :param dict load: A load to send across the wire
        :param int tries: The number of times to make before failure
        :param int timeout: The number of seconds on a response before failing
        c3@s��jj�j�jjj���d�d��V}|rX�jjj|��}ntjr��r�t	j
jj|�}nt
jj|��dS(NR\R](RMR`R[RLRaRbRjRRkRJRlRmRnRoRpRq(Rw(RZtrawRAR\R](s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyt_do_transferIs	
N(
RoRpt	coroutineRLR^R_RJRItAuthenticationErrorRq(RARZR]R\RyRzRs((RZRyRAR\R]s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyt_crypted_transfer:s'cc@s>|jj|j|�d|d|�V}tjj|��dS(u
        Send a load across the wire in cleartext

        :param dict load: A load to send across the wire
        :param int tries: The number of times to make before failure
        :param int timeout: The number of seconds on a response before failing
        R\R]N(RMR`R[RoRpRq(RARZR]R\Rs((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyt_uncrypted_transferfs
		
cc@sf|jdkr.|j|d|d|�V}n"|j|d|d|d|�V}tjj|��dS(u^
        Send a request, return a future which will complete when we send the message
        uclearR]R\RyN(RIR~R}RoRpRq(RARZR]R\RyRs((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyR`ws"N(RPt
__module__t__doc__R"tWeakKeyDictionaryR!R'RDtclassmethodR$RFR(RSRYtpropertyRR[RoRpR{RRxRNR}R~R`(((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyRos&	#					"				+		tAsyncZeroMQPubChannelcB@s�eZdZd�Zd�Zd�Zd�Zejj	d��Z
ed��Zejj	d��Z
ed��Zd	�ZRS(
uw
    A transport channel backed by ZeroMQ for a Salt Publisher to use to
    publish commands to connected minions
    cK@s�||_d|_|jd�|_|jdkrLt�tj�|_ntj	t
jjj
|jd��j�|_t
jj|jd|j�|_t
jj|j�|_tj�|_|jjtj�|_|jdrY|jjtjd�|jjd�dkr.|jjtjd	�qo|jjtjt
jjj
|j��n|jjtjd
�|jjtjt
jjj
|jd��ttd�r!|jjtj |jd�|jjtj!|jd
�|jjtj"|jd�|jjtj#|jd�n|jd}|jdr�t$|jd|jd|jd�}t%j&d|jd|jd|jd|�nt%j&d|�|jjtj'|�ttd�rt%j&d|jd|jd�|jjtj(|jd�n|jdt)ks2d|jdkrZttd�rZ|jjtj*d�nt+r�|jdr�t,|j�|_-|j-j.|j�ndS(Nuzeromquio_loopuidR5u
zmq_filteringt	broadcastu__roleusyndictsyndictu
TCP_KEEPALIVEu
tcp_keepaliveutcp_keepalive_idleutcp_keepalive_cntutcp_keepalive_intvlu
recon_defaulturecon_randomizeu	recon_maxu?Generated random reconnect delay between '%sms' and '%sms' (%s)u#Setting zmq_reconnect_ivl to '%sms'uRECONNECT_IVL_MAXu'Setting zmq_reconnect_ivl_max to '%sms'uipv6u:u	master_ipuIPV4ONLYiuzmq_monitor(/R3RHRR5RR
R	R thashlibtsha1RJtutilststringutilstto_bytest	hexdigestthexidRIRKRLtpayloadtSerialtserialRtContexttcontextRTtSUBt_sockett
setsockoptt	SUBSCRIBEtIDENTITYRRt
TCP_KEEPALIVEtTCP_KEEPALIVE_IDLEtTCP_KEEPALIVE_CNTtTCP_KEEPALIVE_INTVLRRR%t
RECONNECT_IVLtRECONNECT_IVL_MAXRQtIPV4ONLYtHAS_ZMQ_MONITORtZeroMQSocketMonitort_monitort
start_io_loop(RAR3R4trecon_delay((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyRF�sf		.!
	,				




	5cC@s�t|d�r7|jdk	r7|jj�d|_nt|d�r�tdkr�|jjj|jj�|jjj	d�q�|jj	d�n"t|d�r�|j
j	d�nt|d�r�|jjt
kr�|jj�ndS(	Nu_monitoru_streamiiiu_socketucontext(iii(RRR�RtstopRt_streamR5tremove_handlerRTRSR�R�tclosedRNtterm(RA((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyRS�s
!cC@s9tjjjddj|jj�dd�|j�dS(NuSodiumuECalling {0}.destroy() is deprecated. Please call {0}.close() instead.t
stackleveli(RJR�tversionst
warn_untilRR:RPRS(RA((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pytdestroy�scC@s|j�dS(N(RS(RA((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyRY�scc@sZ|jjs|jj�Vn|jjd|_tjd|j�|jj	|j�dS(Nupublish_portuCConnecting the Minion to the Master publish port, using the URI: %s(
RLR^R_tcredstpublish_portRR%t
master_pubR�tconnect(RA((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyR��s
cC@s;t|jd|jd|jjd�d|jjd��S(u0
        Return the master publish port
        u	master_ipRu	source_ipRusource_publish_port(RR3R�R(RA((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyR�s
	cc@s&t|�}|dkr1|jj|d�}n�|dkr�tjjj|d�}|jjd�dkr�|d|j	fks�|jjd�dkr�|d
kr�t
jd|�tj
jd	��n|jj|d�}ntdjt|����|j|�V}tj
j|��d	S(u�
        Take the zmq messages, decrypt/decode them into a payload

        :param list messages: A list of messages to be decoded
        iiiu__roleusyndicu	broadcastu(Publish received for not this minion: %suAInvalid number of messages ({0}) in zeromq pubmessage from masterN(u	broadcastusyndic(tlenR�RjRJR�R�tto_strR3RR�RR%RoRpRqRt	ExceptionRt_decode_payload(RAtmessagestmessages_lenR�tmessage_targetRs((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyt_decode_messages
s-$	cC@s=t|d�s6tjjj|jd|j�|_n|jS(uI
        Return the current zmqstream, creating one if necessary
        u_streamR5(RRRt	eventloopt	zmqstreamt	ZMQStreamR�R5R�(RA((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pytstream%s'c@sJ�dkr�jjd�Stjj��fd��}�jj|�S(u�
        Register a callback for received messages (that we didn't initiate)

        :param func callback: A function which should be called when data is received
        c3@s-�j|�V}|dk	r)�|�ndS(N(R�R(R�R�(tcallbackRA(s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyt
wrap_callback7sN(RR�ton_recvRoRpR{(RAR�R�((R�RAs9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyR�.s(RPRR�RFRSR�RYRoRpR{R�R�R�R�R�R�(((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyR��s	Q			
	tZeroMQReqServerChannelcB@seeZd�Zd�Zd�Zd�Zd�Zd�Zej	j
d��Zd�Zd�Z
RS(	cC@s&tjjjj||�t|_dS(N(RJRltservertReqServerChannelRFRNRO(RAR3((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyRFBscC@s|j�tjjjd�tj|jd�|_dj	|j�|_
|jjtj�|_
|jdtkr�ttd�r�|j
jtjd�n|j
jtj|jjdd��|j�|jjtj�|_|jjd	d
�dkr$dj	|jjd
d��|_n(dj	tjj|jdd��|_tjd�|j
j|j
�|jj|j�x�tr|j
js�|jjr�Pny tjtj |j
|j�Wq�tj!k
r�}|j"t"j#kr�q�n|�q�t$t%fk
rPq�Xq�WdS(uA
        Multiprocessing target for the zmq queue device
        uMWorkerQueueuworker_threadsutcp://{interface}:{ret_port}uipv6uIPV4ONLYiuzmq_backlogi�uipc_modeuutcputcp://127.0.0.1:{0}utcp_master_workersi�u	ipc://{0}usock_diruworkers.ipcu*Setting up the master communication serverN(&t&_ZeroMQReqServerChannel__setup_signalsRJR�tprocesstappendproctitleRR�R3R�RturiRTtROUTERtclientsRQRRR�R�tBACKLOGRt_start_zmq_monitortDEALERtworkerstw_uriR0tpathtjoinRtinfotbindR�tdevicetQUEUEtZMQErrorRVtEINTRtKeyboardInterruptt
SystemExit(RARX((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyt
zmq_deviceFs:
"%
"
	 	cC@su|jr
dStjdtj��t|_t|dd�dk	r]|jj	�d|_nt|dd�dk	r�|j
j	�d|_
nt|d�r�|jj
tkr�|jj�nt|d�r�|jj
tkr�|jj�nt|d�r|jj�nt|d�r@|jj
tkr@|jj�nt|d	�rq|jj
tkrq|jj�ndS(
u4
        Cleanly shutdown the router socket
        Nu$MWorkerQueue under PID %s is closingu_monitoru
_w_monitoruclientsuworkersustreamu_socketucontext(RORR�R0R1RQtgetattrRR�R�t
_w_monitorRRR�R�RNRSR�R�R�R�R�(RA((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyRSps(		

!!!!cC@s0tjjjjj||�|j|j�dS(u�
        Pre-fork we need to create the zmq router device

        :param func process_manager: An instance of salt.utils.process.ProcessManager
        N(RJRltmixinsRLtAESReqServerMixintpre_forktadd_processR�(RAtprocess_manager((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyR��scC@sntrj|jdrjtjd�ddl}t|j�|_|jd|jj	�j
�tjd�ndS(uM
        Starts ZMQ monitor for debugging purposes.
        :return:
        uzmq_monitoruStarting ZMQ monitoriNttargetu$ZMQ monitor has been started started(R�R3RR%R+R�R�R�tThreadt
start_polltstart(RAR+((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyR��s
cC@s-||_||_tjd�|_|jjtj�|_|j�|j	j
dd�dkr�dj|j	j
dd��|_n(djt
jj|j	d	d
��|_tjd|j�|jj|j�tjjjjj|||�tjjj|jd|j�|_|jj|j�d
S(ud
        After forking we need to create all of the local sockets to listen to the
        router

        :param func payload_handler: A function to called to handle incoming payloads as
                                     they are picked up off the wire
        :param IOLoop io_loop: An instance of a Tornado IOLoop, to handle event scheduling
        iuipc_modeuutcputcp://127.0.0.1:{0}utcp_master_workersi�u	ipc://{0}usock_diruworkers.ipcuWorker binding to socket %sR5N(tpayload_handlerR5RR�R�RTtREPR�R�R3RRR�R0R�R�RR�R�RJRlR�RLR�t	post_forkR�R�R�R�ton_recv_streamthandle_message(RAR�R5((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyR��s			
"$c
	c@svy)|jj|d�}|j|�}Wnytk
r�}t|�j}|dkrftjd�ntjd||�|j	|jj
d��tjj
��nXt|t�s�t|jd�t�rtjd||jd��|j	|jj
d��tjj
��nyg|djd	d
�}td�|kr{tjd|�|j	|jj
d
��tjj
��nWnRtk
r�tjd|�|j	|jj
dj|���tjj
��nX|ddkr:|jdi�jd�dkr:|j	|jj
|j|d���tjj
��ny|j|�V\}}WnBtk
r�}|j	d�tjddt�tjj
��nX|jdd�}	|	dkr�|j	|jj
|��n�|	dkr|j	|jj
|jj
|���n\|	dkrF|j	|jj
|j||d|d���ntjd|	�|j	d�tjj
��dS( u
        Handle incoming messages from underlying TCP streams

        :stream ZMQStream stream: A ZeroMQ stream.
        See http://zeromq.github.io/pyzmq/api/generated/zmq.eventloop.zmqstream.html

        :param dict payload: A payload to process
        iuAuthenticationErroru�Minion failed to auth to master. Since the payload is encrypted, it is not known which minion failed to authenticate. It is likely that this is a transient failure due to the master rotating its public key.uBad load from minion: %s: %subad loaduloadu@payload and load must be a dict. Payload was: %s and load was %supayload and load must be a dictuiduuu+Payload contains an id with a null byte: %su!bad load: id contains a null byteu"Payload contains non-string id: %su bad load: id {0} is not a stringuencuclearucmdu_authu&Some exception handling minion payloadu-Some exception handling a payload from miniontexc_infoufunusendu
send_clearusend_privateukeyutgtuUnknown req_fun %su&Server-side exception handling payloadN(R�RjR�R�ttypeRPRR%RUR`RbRoRpRqt
isinstanceRGRtstrt	TypeErrorRt_authR�RQRat_encrypt_private(
RAR�R�RXtexc_typetid_Rstreq_optstetreq_fun((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyR��s\

)
"1&
(
cC@s0tjtj|j�tjtj|j�dS(N(tsignaltSIGINTt_handle_signalstSIGTERM(RA((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyt__setup_signalsscC@s�dj|jj�}|tjkr1|d7}n|tjkrM|d7}n|d7}tj|�|j�t	j
tjj
j�dS(Nu{0} received a uSIGINTuSIGTERMu	. Exiting(RR:RPR�R�R�RR%RStsystexitRJtdefaultst	exitcodestEX_OK(RAtsignumtsigframetmsg((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyR�s




(RPRRFR�RSR�R�R�RoRpR{R�R�R�(((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyR�?s		*					 M	cC@s�ttd�r�|r�d|kr;|jtj|d�nd|kra|jtj|d�nd|kr�|jtj|d�nd|kr�|jtj|d�q�ndS(u�
    Ensure that TCP keepalives are set as specified in "opts".

    Warning: Failure to set TCP keepalives on the salt-master can result in
    not detecting the loss of a minion when the connection is lost or when
    it's host has been terminated without first closing the socket.
    Salt's Presence System depends on this connection status to know if a minion
    is "present".

    Warning: Failure to set TCP keepalives on minions can result in frequent or
    unexpected disconnects!
    u
TCP_KEEPALIVEu
tcp_keepaliveutcp_keepalive_idleutcp_keepalive_cntutcp_keepalive_intvlN(RRRR�R�R�R�R�(t
zmq_socketR3((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyt_set_tcp_keepalive s
tZeroMQPubServerChannelcB@sneZdZej�Zd�Zd�Zd	d�Z	d	d�Z
ed��Zd�Z
d�Zd�ZRS(
uD
    Encapsulate synchronous operations for a publisher channel
    cC@s@||_tjj|j�|_tjjj|j�|_dS(N(	R3RJR�R�R�R�tminionst	CkMinionst	ckminions(RAR3((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyRFGs	cC@stjjd�S(Ni(RoRptsleep(RA((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyR�Lsc
C@s	tjjj|jj�|rHtjjj|�tjjj	|�nt
jd�}|jt
j
�}t||j�y&|jt
j|jjdd��WnUtk
r�|jt
j|jjdd��|jt
j|jjdd��nX|jdtkr/tt
d�r/|jt
jd�n|jt
j|jjdd��|jt
jd�d	j|j�}|jt
j�}|jt
jd�|jjd
d�dkr�d
j|jjdd��}n%djtjj|jdd��}tjj j!|�tj"d|�|j#|�tj"d|�tjj$j%d��|j#|�WdQXy+x$tr�y�tj&d|�|j'�}tj&dt(|��tj)j*|�}t+j,r�tj-j.j/|�}n|d}	tj0d�|jdr)d|kr�x�|dD]y}
tj0d|�tjj1j2t3j4tjj1j2|
��j5��}|j6|dt
j7�|j6|	�tj0d�qW|jjd �r&tj0d!�|j6d"dt
j7�|j6|	�tj0d#�q&qStj0d$|�|j6d%dt
j7�|j6|	�tj0d&�n*tj0d'|�|j6|	�tj0d(�Wqkt
j8k
r�}|j9t9j:kr�qkn|�qkXqkWWnt;k
r�tj0d)�nX|j<t=kr�|j>�n|j<t=kr�|j>�n|j<t=kr|j?�ndS(*uK
        Bind to the interface specified in the configuration file
        iupub_hwmi�uipv6uIPV4ONLYiuzmq_backlogi����u tcp://{interface}:{publish_port}uipc_modeuutcputcp://127.0.0.1:{0}utcp_master_publish_pulli�u	ipc://{0}usock_dirupublish_pull.ipcu!Starting the Salt Publisher on %suStarting the Salt Puller on %siNu*Publish daemon getting data from puller %su(Publish daemon received payload. size=%dupayloadu%Accepted unpacked package from pulleru
zmq_filteringu	topic_lstu'Sending filtered data over publisher %stflagsuFiltered data has been sentu
order_mastersuSending filtered data to syndicR�u%Filtered data has been sent to syndicu*Sending broadcasted data over publisher %sR�uBroadcasted data has been sentu-Sending ZMQ-unfiltered data over publisher %suUnfiltered data has been sentu5Publish daemon caught Keyboard interupt, tearing down(@RJR�R�R�R:RPRtsetupt!set_multiprocessing_logging_queuetsetup_multiprocessing_loggingRR�RTtPUBRR3R�tHWMRtAttributeErrortSNDHWMtRCVHWMRQRRR�R�tLINGERRtPULLR0R�R�tzeromqtcheck_ipc_path_max_lenR�R�tfilest	set_umaskR%trecvR�R�t	unpackageRRkRlRmRnR.R�R�R�R�R�R`tSNDMORER�RVR�R�R�RNRSR�(
RAt	log_queueR�tpub_socktpub_urit	pull_socktpull_uritpackagetunpacked_packageR�ttopicthtopicRX((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyt_publish_daemonOs�&
"&""
		


3







cC@s|j|jd|�dS(u.
        Do anything necessary pre-fork. Since this is on the master side this will
        primarily be used to create IPC channels and create our daemon process to
        do the actual publishing

        :param func process_manager: A ProcessManager, from salt.utils.process.ProcessManager
        R4N(R�R%(RAR�R4((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyR��scC@s&y|jjSWntk
r!nXdS(u�
        This thread's zmq publisher socket. This socket is stored on the class
        so that multiple instantiations in the same thread will re-use a single
        zmq socket.
        N(t
_sock_datatsockR(RA((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyR�s
cC@s�|jr|j�ntjj�}|jtj�|j_|jj	tj
d�|jjdd�dkr�dj
|jjdd��}n%dj
tjj|jd	d
��}tjd|�|jj|�|jjS(u�
        Create and connect this thread's zmq socket. If a publisher socket
        already exists "pub_close" is called before creating and connecting a
        new socket.
        i����uipc_modeuutcputcp://127.0.0.1:{0}utcp_master_publish_pulli�u	ipc://{0}usock_dirupublish_pull.ipcuConnecting to pub server: %s(Rt	pub_closeRR�tinstanceRTtPUSHR&R'R�RR3RRR0R�R�RR%R�(RAtctxR ((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pytpub_connect�s	
cC@s9t|jd�r5|jjj�t|jd�ndS(un
        Disconnect an existing publisher socket and remove it from the local
        thread's cache.
        usockN(RRR&R'RStdelattr(RA((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyR(�sc	C@s�idd6}tjj|jtjjjddj�}|j|�|d<|jdr�t	j
j|jdd�}tj
d�tjj||d�|d	<ni|jj|�d
6}|ddkr�|d
|d<ndddg}|jdrO|d|krO|jj|d
d|d�}|d}tj
d|�||d<n|jj|�}tj
d|jdd�t|��|js�|j�n|jj|�tj
d�dS(u�
        Publish "load" to minions. This send the load to the publisher daemon
        process with does the actual sending to minions.

        :param dict load: A load to be sent across the wire to minions
        uaesuencusecretuloadusign_pub_messagesupki_diru
master.pemuSigning data packetusigupayloadutgt_typeulistutgtu	topic_lstupcreuglobu
zmq_filteringttgt_typeuminionsuPublish Side Match: %su1Sending payload to publish daemon. jid=%s size=%dujiduSent payload to publish daemon.N(RJRIRiR3tmastertSMastertsecretstvalueRbR0R�R�RR%tsign_messageR�Rt
check_minionsRRR�RR,R`(	RARZR�Ratmaster_pem_pathtint_payloadt
match_targetst_rest	match_ids((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pytpublish�s2
,

 


	
N(RPRR�R+tlocalR&RFR�RR%R�R�RR,R(R:(((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyR@s		n
			R?cB@sAeZdZddd�Zd�Zd�Zd�Zd�ZRS(ul
    Wrapper class of AsyncReqMessageClientPool to avoid blocking waiting while writing data to socket.
    cC@s2tt|�jt|d|d|�t|_dS(NR9R4(tsuperR?RFtAsyncReqMessageClientRNRO(RAR3R9R4((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyRF!s%cC@sA|jr
dSt|_x|jD]}|j�q Wg|_dS(N(RORQtmessage_clientsRS(RARM((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyRS%s		cO@s,t|jdd��}|dj||�S(NR7cS@s
t|j�S(N(R�t
send_queue(tx((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyt<lambda>/si(tsortedR>R`(RAR9R4R>((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyR`.scC@s9tjjjddj|jj�dd�|j�dS(NuSodiumuECalling {0}.destroy() is deprecated. Please call {0}.close() instead.R�i(RJR�R�R�RR:RPRS(RA((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyR�2scC@s|j�dS(N(RS(RA((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyRY=sN(	RPRR�RRFRSR`R�RY(((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyR?s				R=cB@s�eZdZddd�Zd�Zd�Zd�Zd�Ze	j
jd��Zd�Z
d	�Zdd
dded�ZRS(
u�
    This class wraps the underlying zeromq REQ socket and gives a future-based
    interface to sending and recieving messages. This works around the primary
    limitation of serialized send/recv on the underlying socket by queueing the
    message sends in this class. In the future if we decide to attempt to multiplex
    we can manage a pool of REQ/REP sockets-- but for now we'll just do them in serial
    icC@s�||_||_||_|dkr;t�tj�n	||_tj	j
|j�|_tj
�|_|j�g|_i|_i|_t|_dS(u�
        Create an asynchronous message client

        :param dict opts: The salt opts dictionary
        :param str addr: The interface IP address to bind to
        :param int linger: The number of seconds to linger on a ZMQ socket. See
                           http://api.zeromq.org/2-1:zmq-setsockopt [ZMQ_LINGER]
        :param IOLoop io_loop: A Tornado IOLoop event scheduler [tornado.ioloop.IOLoop]
        N(R3taddrtlingerRR
R	R R5RJR�R�R�RR�R�t_init_socketR?tsend_future_maptsend_timeout_mapRNRO(RAR3RCRDR5((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyRFJs
			
	
			cC@s�|jr
dSt|_t|d�r�|jdk	r�tdkr�|jjr_|jjj�n|jjj	|jj�d|j_|jj�n|jj�d|_d|_n|j
jtkr�|j
j
�ndS(Nustreamiii(iii(RORQRRR�RRRTRSR5R�R�R�RNR�(RA((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyRSks		
	cC@s9tjjjddj|jj�dd�|j�dS(NuSodiumuECalling {0}.destroy() is deprecated. Please call {0}.close() instead.R�i(RJR�R�R�RR:RPRS(RA((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyR��scC@s|j�dS(N(RS(RA((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyRY�scC@sMt|d�r8|jj�|jj�|`|`n|jjtj�|_ttd�rx|jjtjd�nt	|j|j
�|jjd�r�ttd�r�|jjtj
d�q�ttd�r�|jjtjd�q�n|j|j_tjd	|j�|jj|j�tjjj|jd
|j�|_dS(NustreamuRECONNECT_IVL_MAXi�utcp://[uIPV6iuIPV4ONLYiuTrying to connect to: %sR5(RRR�RSRTR�RtREQR�R�RR3RCt
startswithtIPV6R�RDRR%R�R�R�R�R5(RA((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyRE�s&

		c#@sx�t�j�dkr��jd}�jj|d���dkrV�jd=qn��fd�}�jj|��jj|�y�V}Wn:tk
r�}t	j
d|��j��jd=qnX�jd=�jj|d��j
|�qWdS(Nic@s6�j�s2�jj|d�}�j|�ndS(Ni(tdoneR�Rjt
set_result(RRw(tfutureRA(s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pytmark_future�suRe-init ZMQ socket: %s(R�R?RFRRR�R�R`R�RR%REtpoptremove_message_timeout(RAtmessageRNRsterr((RMRAs9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyt_internal_send_recv�s&




cC@sK||jkrdS|jj|d�}|dk	rG|jj|�ndS(N(RGRORR5tremove_timeout(RARQR\((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyRP�s
cC@s�|jj|d�}|dk	r�|j|=|j|jkr�|jd7_tjd|j|j�|j|d|j	d|jd|�q�|j
td��ndS(u�
        Handle a message timeout by removing it from the sending queue
        and informing the caller

        :raises: SaltReqTimeoutError
        iu&SaltReqTimeoutError, retrying. (%s/%s)R\R]RMuMessage timed outN(RFRORRGtattemptsR]RR%R`R\t
set_exceptionR(RARQRM((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyttimeout_message�s
		
ic	@s|dkrKtjj�}||_d|_||_�jj|�}n�dk	ry��fd�}|j	|�n|�j
|<�jjd�t
kr�d}n|dk	r��jj|�j|�}|�j|<nt�j�dkr	�jj�j�n�jj|�|S(uY
        Return a future which will be completed when the message has a response
        ic@s#|j�}�jj�|�dS(N(RCR5tadd_callback(RMtresponse(R�RA(s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyt
handle_future�sudetect_modeiN(RRot
concurrenttFutureR]RUR\R�Rbtadd_done_callbackRFR3RRQR5t
call_laterRWRGR�R?tspawn_callbackRStappend(	RARQR\R]RMR�RyRZtsend_timeout((R�RAs9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyR`�s&			
	N(RPRR�RRFRSR�RYRERoRpR{RSRPRWRNR`(((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyR=Bs!						R�cB@sJeZdZd�Zd�Zd�Zed��Zd�Z	d�Z
RS(cC@s(||_|jj�|_d|_dS(u�
        Create ZMQ monitor sockets

        More information:
            http://api.zeromq.org/4-0:zmq-socket-monitor
        N(R�tget_monitor_sockett_monitor_socketRt_monitor_stream(RART((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyRFs	cC@sEtjd�tjjj|jd|�|_|jj|j	�dS(NuEvent monitor start!R5(
RR.RR�R�R�RcRdR�tmonitor_callback(RAR5((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyR�s
!cC@svtjd�yEx>|jdk	rP|jj�rP|jj�}|j|�qWWnttj	j
fk
rqnXdS(NuEvent monitor start!(RR.RcRtpolltrecv_multipartReRRRUtContextTerminated(RAR((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyR�s
!cC@sjtjdkrci}x?tt�D]1}|jd�r"tt|�}|||<q"q"W|t_ntjS(NuEVENT_(R�t_ZeroMQSocketMonitor__EVENT_MAPRtdirRRIR�(RAt	event_maptnameR2((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyRk'scC@s^tjjj|�}|j|d|d<tjd|�|dtjkrZ|j�ndS(NueventudescriptionuZeroMQ event: %s(	RR�tmonitortparse_monitor_messageRkRR%tEVENT_MONITOR_STOPPEDR�(RARtevt((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyRe2s
cC@sk|jdkrdS|jj�d|_d|_|jdk	rZ|jj�d|_ntjd�dS(NuEvent monitor done!(R�Rtdisable_monitorRcRdRSRR.(RA((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyR�9s
		
N(RPRRRiRFR�R�R�RkReR�(((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyR�	s				(XR�t
__future__RRRR0R�R;RVR�RTR�tloggingR"R+trandomRt	salt.authRJt
salt.crypttsalt.log.setuptsalt.utils.eventtsalt.utils.filestsalt.utils.minionstsalt.utils.processtsalt.utils.stringutilstsalt.utils.verifyRtsalt.utils.versionstsalt.payloadtsalt.transport.clienttsalt.transport.servertsalt.transport.mixins.authtsalt.extRtsalt.exceptionsRRtsalt._compatRRR	R
RRt	zmq.errortzmq.eventloop.iolooptzmq.eventloop.zmqstreamtzmq.utils.monitorRQR�tImportErrorRNRottornado.genttornado.concurrenttM2CryptoR
RdtCryptodome.CipherRt
Crypto.Ciphert	getLoggerRPRRRRltclientt
ReqChannelRR�RLtAESPubClientMixintAsyncPubChannelR�R�R�R�R�RtPubServerChannelRtMessageClientPoolR?R&R=R�(((s9/usr/lib/python2.7/site-packages/salt/transport/zeromq.pyt<module>s�(





&�.��	 �%�

Zerion Mini Shell 1.0