%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/self/root/lib/python2.7/site-packages/salt/netapi/rest_tornado/
Upload File :
Create Path :
Current File : //proc/self/root/lib/python2.7/site-packages/salt/netapi/rest_tornado/event_processor.pyc

�
���^c@@s�ddlmZmZmZddlZddlZddlmZddlZ	ddl
Z	eje�Z
defd��YZdS(i(tabsolute_importtprint_functiontunicode_literalsN(tsixtSaltInfocB@s_eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�ZRS(
uP
    Class to  handle processing and publishing of "real time" Salt upates.
    cC@s||_i|_i|_dS(ub
        handler is expected to be the server side end of a websocket
        connection.
        N(thandlertjobstminions(tselfR((sL/usr/lib/python2.7/site-packages/salt/netapi/rest_tornado/event_processor.pyt__init__s		cC@s�tjd�i}tjd�x^tj|j�D]J\}}tj|�i}|j|�|ji|d6�|||<q3Wtjd�i|d6}|jjtj	j
j|�td��dS(u7
        Publishes minions as a list of dicts.
        uin publish minionsu
starting loopuidu
ended loopuminionsu

N(
tlogtdebugRt	iteritemsRtupdateRt
write_messagetsalttutilstjsontdumpststr(RRtminiontminion_infotcurr_miniontret((sL/usr/lib/python2.7/site-packages/salt/netapi/rest_tornado/event_processor.pytpublish_minions s





	cC@s@i||6}tjjj|�td�}|jj|�dS(u9
        Publishes the data to the event stream.
        u

N(RRRRRRR(Rtkeytdatatpublish_datatpub((sL/usr/lib/python2.7/site-packages/salt/netapi/rest_tornado/event_processor.pytpublish4s
cC@s�|d}|d}|jd�d}|jj|d�sLi|j|<n|j|}|ji|dd6�tjd|j�|j�dS(	uO
        Associate grains data with a minion and publish minion update
        utagudatau/i����ureturnugrainsu/In process minion grains update with minions=%sN(tsplitRtgettNoneR
R
RR(Rt
event_datattagt
event_infotmidR((sL/usr/lib/python2.7/site-packages/salt/netapi/rest_tornado/event_processor.pytprocess_minion_update<s


c
C@s
|d}|d}|jd�\}}}}}|jj|i�}|jdi�j|i�}|ji|dd6�|ji|dd6�|ji|dd6�tgtj|d�D]\}}|d^q��}	|	r�d|d	<n|jd
|j�dS(u�
        Process a /ret event returned by Salt for a particular minion.
        These events contain the returned results from a particular execution.
        utagudatau/uminionsureturnuretcodeusuccessucompleteustateujobsN(RRt
setdefaultR
tallRRR(
RR!R"R#t_tjidR$tjobRtjob_complete((sL/usr/lib/python2.7/site-packages/salt/netapi/rest_tornado/event_processor.pytprocess_ret_job_eventNs

0
cC@s�d}|d}|d}i}x#|dD]}itd6||<q+Wi|dd6|dd6|d6|dd6|d	d	6|d
d
6dd6}||j|d<|jd
|j�dS(u�
        Creates a new job with properties from the event data
        like jid, function, args, timestamp.

        Also sets the initial state to started.

        Minions that are participating in this job are also noted.

        utagudatauminionsusuccessujidu_stampu
start_timeufunutgtutgt_typeurunningustateujobsN(R tFalseRR(RR!R*R"R#RR$((sL/usr/lib/python2.7/site-packages/salt/netapi/rest_tornado/event_processor.pytprocess_new_job_eventfs 



cC@sv|d}|d}|ddkr>|jj|dd�n*|ddkrh|jj|di�n|j�dS(u�
        Tag: salt/key
        Data:
        {'_stamp': '2014-05-20T22:45:04.345583',
         'act': 'delete',
         'id': 'compute.home',
         'result': True}
        utagudatauactudeleteuiduacceptN(RtpopR R&R(RR!R"R#((sL/usr/lib/python2.7/site-packages/salt/netapi/rest_tornado/event_processor.pytprocess_key_event�s


cC@stjd�t}t|djdg��rNt|djdg��}n)t|j�t|djdg��}x7|D]/}t}tjd|�|jj|d�q~Wt|djdg��r�tjd�t|djdg��}t}nnt|djdg��t|j�rgtjd�t|djdg��t|j�}t}ng}d	j	|�}x(|D] }	tjd
�i|j|	<q�W|rt}t
jj|�}
|
j
idd6|d
6dd6dd6dd6dd6|d6�n|r|j�ndS(ut
        Check if any minions have connected or dropped.
        Send a message to the client if they have.
        uIn presenceudataulostupresentu
Popping %sunewugot new minionsudetected new minionsu,u
Adding minionugrains.itemsufunutgtulistu	expr_typeuclientumodeulocalulocal_asyncuasynchronousutokenN(R
RR-tsetRRtTrueR/R tjoinRtnetapitNetapiClienttrunR(Rt	salt_datattokentoptstchangedtdropped_minionsRtnew_minionsttgtR$tclient((sL/usr/lib/python2.7/site-packages/salt/netapi/rest_tornado/event_processor.pytprocess_presence_events�sH
)

	)
)	

cC@sRtjdtj��tj|d�tj|�|djd�}t|�dkr]dS|ddkr�tjd�|d	d
kr�tjd�|j|�qN|d	dkrNtjd
�|j|�|dddkr�|j|�q�qNnS|ddkr(tjd�|j	|�n&|ddkrN|j
|||�ndS(u1
        Process events and publish data
        u
In process %sutagu/iNiujobu
In job part 1iunewu
In new joburetuIn retudataufunugrains.itemsukeyuIn keyupresence(R
Rt	threadingtcurrent_threadRtlenR.R,R%R0R?(RR7R8R9tparts((sL/usr/lib/python2.7/site-packages/salt/netapi/rest_tornado/event_processor.pytprocess�s*





(t__name__t
__module__t__doc__R	RRR%R,R.R0R?RD(((sL/usr/lib/python2.7/site-packages/salt/netapi/rest_tornado/event_processor.pyR
s								5(t
__future__RRRtloggingR@tsalt.extRtsalt.netapiRtsalt.utils.jsont	getLoggerRER
tobjectR(((sL/usr/lib/python2.7/site-packages/salt/netapi/rest_tornado/event_processor.pyt<module>s

Zerion Mini Shell 1.0