%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/modjk_worker.pyo

�
���^c@@s�dZddlmZmZmZd�Zddd�Zddd�Zddd�Zddd	�Z	ddd
�Z
ddd�ZdS(
u`
Manage modjk workers
====================

Send commands to a :strong:`modjk` load balancer via the peer system.

This module can be used with the :ref:`prereq <requisites-prereq>`
requisite to remove/add the worker from the load balancer before
deploying/restarting service.

Mandatory Settings:

- The minion needs to have permission to publish the :strong:`modjk.*`
  functions (see :ref:`here <peer>` for information on configuring
  peer publishing permissions)

- The modjk load balancer must be configured as stated in the :strong:`modjk`
  execution module :mod:`documentation <salt.modules.modjk>`
i(tabsolute_importtprint_functiontunicode_literalscC@stS(u(
    Check if we have peer access ?
    (tTrue(((s</usr/lib/python2.7/site-packages/salt/states/modjk_worker.pyt__virtual__sudefaultuglobc
C@sitd6dd6gd6}dj|�}|||g}td||||�}	g}
g}x5|	D]-}|j|�|	|se|
j|�qeqeW|	s�dj|�|d<|St|
�dkr�d	|d<|
|d<|St|d<d
|d<||d<|SdS(u3
    Send a command to the modjk loadbalancer
    The minion need to be able to publish the commands to the load balancer

    cmd:
        worker_stop - won't get any traffic from the lbn
        worker_activate - activate the worker
        worker_disable - will get traffic only for current sessions
    ucodeuOKumsguminionsu	modjk.{0}upublish.publishu-no servers answered the published command {0}iu"the following minions return Falseu%the commad was published successfullyN(tFalsetformatt__salt__tappendtlenR(
tcmdtworkertlbnttargettprofilettgt_typetrettfunctargstresponseterrorstminionstminion((s</usr/lib/python2.7/site-packages/salt/states/modjk_worker.pyt
_send_commands2









c	C@s�itd6gd6gd6}||g}td|d||�}|sTt|d<|SxT|D]L}||s|dj|�q[||d|kr[|dj|�q[q[W|S(u�
    Check if the worker is in `activation` state in the targeted load balancers

    The function will return the following dictionary:
        result - False if no server returned from the published command
        errors - list of servers that couldn't find the worker
        wrong_state - list of servers that the worker was in the wrong state
                      (not activation)
    uresultuerrorsuwrong_stateupublish.publishumodjk.worker_statusu
activation(RRRR(	R
Rt
activationRRRRtstatustbalancer((s</usr/lib/python2.7/site-packages/salt/states/modjk_worker.pyt_worker_statusSs 



c
C@sGi|d6td6id6dd6}idd6dd	6d
d6}t||||||�}|ds{t|d<d|d<|S|d
r�t|d<dj||d
�|d<|S|ds�d|d<|Sdj||d�|d<i|d|6|d<tdrd|d<|St||||||�}	|	d|d<|	d|d<|S(uB
    Wrapper function for the stop/disable/activate functions
    unameuresultuchangesuucommentuSTPuworker_stopuDISuworker_disableuACTuworker_activateu=no servers answered the published command modjk.worker_statusuerrorsu:the following balancers could not find the worker {0}: {1}uwrong_stateuBthe worker is in the desired activation state on all the balancersu0the action {0} will be sent to the balancers {1}utestumsgucodeN(RRRRt__opts__tNoneR(
tnameRR
tactionRRRt
action_mapRR((s</usr/lib/python2.7/site-packages/salt/states/modjk_worker.pyt_talk2modjk|s@











cC@st|||d||�S(u

    .. versionchanged:: 2017.7.0
        The ``expr_form`` argument has been renamed to ``tgt_type``, earlier
        releases must use ``expr_form``.

    Stop the named worker from the lbn load balancers at the targeted minions
    The worker won't get any traffic from the lbn

    Example:

    .. code-block:: yaml

        disable-before-deploy:
          modjk_worker.stop:
            - name: {{ grains['id'] }}
            - lbn: application
            - target: 'roles:balancer'
            - tgt_type: grain
    uworker_stop(R!(RRR
RR((s</usr/lib/python2.7/site-packages/salt/states/modjk_worker.pytstop�scC@st|||d||�S(u�
    .. versionchanged:: 2017.7.0
        The ``expr_form`` argument has been renamed to ``tgt_type``, earlier
        releases must use ``expr_form``.

    Activate the named worker from the lbn load balancers at the targeted
    minions

    Example:

    .. code-block:: yaml

        disable-before-deploy:
          modjk_worker.activate:
            - name: {{ grains['id'] }}
            - lbn: application
            - target: 'roles:balancer'
            - tgt_type: grain
    uworker_activate(R!(RRR
RR((s</usr/lib/python2.7/site-packages/salt/states/modjk_worker.pytactivate�scC@st|||d||�S(u8
    .. versionchanged:: 2017.7.0
        The ``expr_form`` argument has been renamed to ``tgt_type``, earlier
        releases must use ``expr_form``.

    Disable the named worker from the lbn load balancers at the targeted
    minions. The worker will get traffic only for current sessions and won't
    get new ones.

    Example:

    .. code-block:: yaml

        disable-before-deploy:
          modjk_worker.disable:
            - name: {{ grains['id'] }}
            - lbn: application
            - target: 'roles:balancer'
            - tgt_type: grain
    uworker_disable(R!(RRR
RR((s</usr/lib/python2.7/site-packages/salt/states/modjk_worker.pytdisable�sN(t__doc__t
__future__RRRRRRR!R"R#R$(((s</usr/lib/python2.7/site-packages/salt/states/modjk_worker.pyt<module>s	2%2

Zerion Mini Shell 1.0