%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@s"dZddlmZmZmZy@ddlmZmZddlm	Z	ddl
mZeZ
Wnek
r{eZ
nXe
rddlZddlZddljjZeje�ZiZdadadZdZdd�Zdd	�Zd
�Z d�Z!d�Z"d
dd�Z#ndS(u
Provides RAET LaneStack interface for interprocess communications in Salt Raet
to a remote yard, default name for remote is 'manor' .

Usages are for RAETChannels and RAETEvents
This provides a single module global LaneStack to be shared by all users in
the same process. This combines into one stack the channel and event bus.

The module attributes:
    lane_rx_msgs
        is a dict of deques keyed by the destination share name
        recipients each value deque holds messages that were addressed
        to that share name

    lane_stack
        is the shared LaneStack object

    lane_estate_name
        is the motivating master estate name when applicable

    lane_yard_name
        is the motivating master yard name when applicable

    Because RaetChannels are created on demand
    they do not have access to the master estate that motivated their creation
    the module globals lane_estate_name and lane_yard_name are provided to setup
    so that channels using the routing information for the master that motivated the jobber
    when a channel is not used in a jobber context then a LaneStack is created
    on demand.

Example usage:

import raetlane

raetlane.prep()

track = nacling.uuid(18)
src = (None, 'localyardname', track)
dst = ('remotestackname', 'remoteyardname', 'remotesharename')
route = {'src': src, 'dst': dst}
msg = {'route': route, 'body': {}}

raetlane.transmit(msg)
raetlane.service()

msg = raetlane.wait(share=track, timeout=5.0)
if not msg:
   raise ValueError("Timed out out waiting for response")
i(tabsolute_importtprint_functiontunicode_literals(traetingtnacling(t	LaneStack(t
RemoteYardNumanorcC@s tstd|d|�ndS(u�
        required items in opts are keys
            'id'
            '__role'
            'sock_dir'

        ryn is the remote yard name to communicate with
        each use much call raetlane.prep() to ensure lanestack is setup
        toptstrynN(t
lane_stackt_setup(RR((s7/usr/lib/python2.7/site-packages/salt/utils/raetlane.pytprepPs
c
C@s�|jd�}|s;d}tj|d�t|��n|jd�}|tjkr�dj|�}tj|d�t|��n|tjtjj	tjtjj
gkr�d}nm|tjtjjtjtjjgkr�dj||�}n,dj|�}tj|d�t|��d	t
jd
d�}td|d
|d|d�atjjjt_tjdtjtj�tdtd|d
|d|d�atjt�tjdtjtjtj�dS(uW
        Setup the LaneStack lane_stack and RemoteYard lane_remote_yard global
        uidu)Missing role required to setup LaneStack.u
u__roleu/Invalid application kind = '{0}' for LaneStack.umasteru{0}_{1}u1Unsupported application kind '{0}' for LaneStack.u	lanestacktsizeitnametlanenametsockdirpathusock_diru4Created new LaneStack and local Yard named %s at %s
tstacktdirpathu1Added to LaneStack %s remote Yard named %s at %s
N(tgettlogterrort
ValueErrortkindst
APPL_KINDStformattAPPL_KIND_NAMESt	applKindstmastertsyndictminiontcallerRtuuidRR	RtPackKindtpacktvaluetPktdebugR
thaRtremote_yardt	addRemote(RRtroletemsgtkindRR
((s7/usr/lib/python2.7/site-packages/salt/utils/raetlane.pyR
]sF	


cC@stj|tj�dS(u*
        Sends msg to remote_yard
        N(R	ttransmitR&tuid(tmsg((s7/usr/lib/python2.7/site-packages/salt/utils/raetlane.pyR+�scC@sItj�x8tjrDtjj�\}}|t|ddd<q
WdS(u�
        Service the lane_stack and move any received messages into their associated
        deques in rx_msgs keyed by the destination share in the msg route dict
        urouteudstiN(R	t
serviceAlltrxMsgstpoplefttrx_msgs(R-tsender((s7/usr/lib/python2.7/site-packages/salt/utils/raetlane.pytservice�s
cC@s2t�|tkr.t|r.t|j�SndS(uy
        Returns first message from deque at key given by share in rx_msgs if any
        otherwise returns None
        N(R3R1R0tNone(tshare((s7/usr/lib/python2.7/site-packages/salt/utils/raetlane.pytreceive�s

gg{�G�z�?cC@sftj�}xStrat|�}|r+|Stj|�|dkrtj�||krdSqWdS(u�
        Blocks until receives a msg addressed to share or timeout
        Return msg or None if timed out
        Delay is sleep time between services
        gN(ttimetTrueR6tsleepR4(R5ttimeouttdelaytstartR-((s7/usr/lib/python2.7/site-packages/salt/utils/raetlane.pytwait�s	
"($t__doc__t
__future__RRRtraetRRtraet.lane.stackingRtraet.lane.yardingRR8tHAS_RAETtImportErrortFalseR7tloggingtsalt.utils.kindstutilsRt	getLoggert__name__RR1R4R	R&tmaster_estate_nametmaster_yard_nameRR
R+R3R6R=(((s7/usr/lib/python2.7/site-packages/salt/utils/raetlane.pyt<module>2s0



0		
	

Zerion Mini Shell 1.0