%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@s�dZddlmZmZmZd
ZdZd�Zdddde	dddddd	�
Z
ddde	dddddd
�	Ze	dddddd�ZdS(u
Control concurrency of steps within state execution using zookeeper
===================================================================

:depends: kazoo
:configuration: See :py:mod:`salt.modules.zookeeper` for setup instructions.


This module allows you to "wrap" a state's execution with concurrency control.
This is useful to protect against all hosts executing highstate simultaneously
if your services don't all HUP restart. The common way of protecting against this
is to run in batch mode, but that doesn't protect from another person running
the same batch command (and thereby having 2x the number of nodes deploying at once).

This module will bock while acquiring a slot, meaning that however the command gets
called it will coordinate with zookeeper to ensure that no more than max_concurrency
steps are executing with a single path.

.. code-block:: yaml

    acquire_lock:
      zk_concurrency.lock:
        - name: /trafficeserver
        - zk_hosts: 'zookeeper:2181'
        - max_concurrency: 4
        - prereq:
            - service: trafficserver

    trafficserver:
      service.running:
        - watch:
          - file: /etc/trafficserver/records.config

    /etc/trafficserver/records.config:
      file.managed:
        - source: salt://records.config

    release_lock:
      zk_concurrency.unlock:
        - name: /trafficserver
        - require:
            - service: trafficserver

This example would allow the file state to change, but would limit the
concurrency of the trafficserver service restart to 4.
i(tabsolute_importtprint_functiontunicode_literalsuzk_concurrency.lockuzk_concurrency.unlockuzk_concurrency.party_membersuzk_concurrencycC@std�tD��stStS(Ncs@s|]}|tkVqdS(N(t__salt__(t.0tfunc((s>/usr/lib/python2.7/site-packages/salt/states/zk_concurrency.pys	<genexpr>?s(talltREQUIRED_FUNCStFalset__virtualname__(((s>/usr/lib/python2.7/site-packages/salt/states/zk_concurrency.pyt__virtual__>sicC@s�i|d6id6td6dd6}i|d6|d6|d6|	d	6|
d
6}tdrmd|d<d|d<|S|dkr�td
}ntd||d|d|d|d||�}
|
r�t|d<d|d<n
d|d<|S(uX
    Block state execution until you are able to get the lock (or hit the timeout)

    unameuchangesuresultuucommentuprofileuschemeuusernameupasswordudefault_aclutestuAttempt to acquire lockuiduzk_concurrency.lockt
identifiertmax_concurrencyttimeouttephemeral_leaseu
lock acquireduUnable to acquire lockN(Rt__opts__tNonet
__grains__RtTrue(tnametzk_hostsRRR
Rtprofiletschemetusernametpasswordtdefault_acltrettconn_kwargstlocked((s>/usr/lib/python2.7/site-packages/salt/states/zk_concurrency.pytlockEs0






	


c

C@s�i|d6id6td6dd6}
i|d6|d6|d6|d	6|	d
6}tdrmd|
d<d|
d<|
S|dkr�td
}ntd|d|d|d|d||�}|r�t|
d<ndj|�|
d<|
S(u&
    Remove lease from semaphore.
    unameuchangesuresultuucommentuprofileuschemeuusernameupasswordudefault_aclutestuReleased lock if it is hereuiduzk_concurrency.unlockRRRRu!Unable to find lease for path {0}N(RRRRRRtformat(
RRRRRRRRRRRRtunlocked((s>/usr/lib/python2.7/site-packages/salt/states/zk_concurrency.pytunlockss,






	
c	
C@sGi|d6id6td6dd6}	i|d6|d6|d6|d	6|d
6}
tdrmd|	d<d|	d<|	Std
|||d||
�}t|t�s�tdj|���nt|�}||ks�|r#tdr�dnt	|	d<|s
dj||�|	d<qCdj||�|	d<n t|	d<dj||�|	d<|	S(ui
    Ensure that there are `min_nodes` in the party at `name`, optionally blocking if not available.
    unameuchangesuresultuucommentuprofileuschemeuusernameupasswordudefault_aclutestuAttempt to ensure min_partyuzk_concurrency.party_memberstblockinguCError from zk_concurrency.party_members, return was not a list: {0}u$Currently {0} nodes, which is >= {1}uRBlocked until {0} nodes were available. Unblocked after {1} nodes became availableu#Currently {0} nodes, which is < {1}N(
RRRRt
isinstancetlistt	ExceptionRtlenR(
RRt	min_nodesR!RRRRRRRtnodest	num_nodes((s>/usr/lib/python2.7/site-packages/salt/states/zk_concurrency.pyt	min_party�s,





N(uzk_concurrency.lockuzk_concurrency.unlockuzk_concurrency.party_members(
t__doc__t
__future__RRRRR	R
RRRR R)(((s>/usr/lib/python2.7/site-packages/salt/states/zk_concurrency.pyt<module>/s>	%%

Zerion Mini Shell 1.0