%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@spdZddlmZmZmZddlmZddlmZ	ddl
mZm
ZmZmZmZd�Zd�Zdd	�Zdd
�Zdd�Zdd�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�Z dd�Z!dd�Z"dd�Z#dd�Z$dd�Z%dd�Z&dd�Z'dd�Z(dd�Z)dd�Z*dS(u�
Control Modjk via the Apache Tomcat "Status" worker
(http://tomcat.apache.org/connectors-doc/reference/status.html)

Below is an example of the configuration needed for this module. This
configuration data can be placed either in :ref:`grains
<targeting-grains>` or :ref:`pillar <salt-pillars>`.

If using grains, this can be accomplished :ref:`statically
<static-custom-grains>` or via a :ref:`grain module <writing-grains>`.

If using pillar, the yaml configuration can be placed directly into a pillar
SLS file, making this both the easier and more dynamic method of configuring
this module.

.. code-block:: yaml

    modjk:
      default:
        url: http://localhost/jkstatus
        user: modjk
        pass: secret
        realm: authentication realm for digest passwords
        timeout: 5
      otherVhost:
        url: http://otherVhost/jkstatus
        user: modjk
        pass: secret2
        realm: authentication realm2 for digest passwords
        timeout: 600
i(tabsolute_importtprint_functiontunicode_literals(tsix(t	urlencode(tHTTPBasicAuthHandlertHTTPDigestAuthHandlerturlopentbuild_openertinstall_openercC@stS(u
    Always load
    (tTrue(((s6/usr/lib/python2.7/site-packages/salt/modules/modjk.pyt__virtual__1sc	C@sct�}|jd|d|d|d|�t�}|jd|d|d|d|�t||�S(u+
    returns a authentication handler.
    trealmturitusertpasswd(t_HTTPBasicAuthHandlertadd_passwordt_HTTPDigestAuthHandlert
_build_opener(turlRRRtbasictdigest((s6/usr/lib/python2.7/site-packages/salt/modules/modjk.pyt_auth8s
	"	"udefaultc
C@s�i}tddj|�d�}tddj|�d�}tddj|�d�}tddj|�d�}tddj|�d�}|s�tdj|���n|r�|r�td	|d
|d|d|�}t|�n|d
jt|��7}x~t|d|�j�j�D]^}	|	j	dd�}
|
d|krn||
dcdj|
d�7<q"|
d||
d<q"W|S(u3
    Make the http request and return the data
    u
config.getu
modjk:{0}:urluumodjk:{0}:userumodjk:{0}:passumodjk:{0}:realmumodjk:{0}:timeoutumissing url in profile {0}RRRRu?{0}ttimeoutu=iiu,{0}(
t__salt__tformatt	ExceptionRt_install_openert
_urlencodet_urlopentreadt
splitlinestsplit(toptstprofiletretRRRRRtauthtlinetsplt((s6/usr/lib/python2.7/site-packages/salt/modules/modjk.pyt_do_httpDs$!
%$cC@s@idd6dd6|d6|d6|d6}t||�dd	kS(
u&
    enable/disable/stop a worker
    uupdateucmdupropumimeuwuswuvwauworker.result.typeuOK(R((tworkertlbntvwaR#tcmd((s6/usr/lib/python2.7/site-packages/salt/modules/modjk.pyt_worker_ctlds
cC@s2idd6dd6}t||�djd�dS(u�
    Return the modjk version

    CLI Examples:

    .. code-block:: bash

        salt '*' modjk.version
        salt '*' modjk.version other-profile
    uversionucmdupropumimeuworker.jk_versionu/i����(R(R!(R#R,((s6/usr/lib/python2.7/site-packages/salt/modules/modjk.pytversionss
cC@s!idd6dd6}t||�S(u�
    Get the current running config (not from disk)

    CLI Examples:

    .. code-block:: bash

        salt '*' modjk.get_running
        salt '*' modjk.get_running other-profile
    ulistucmdupropumime(R((R#R,((s6/usr/lib/python2.7/site-packages/salt/modules/modjk.pytget_running�s
cC@s!idd6dd6}t||�S(u�
    Dump the original configuration that was loaded from disk

    CLI Examples:

    .. code-block:: bash

        salt '*' modjk.dump_config
        salt '*' modjk.dump_config other-profile
    udumpucmdupropumime(R((R#R,((s6/usr/lib/python2.7/site-packages/salt/modules/modjk.pytdump_config�s
cC@sdt|�}y|dj|�}Wntk
r7gSXg|j�jd�D]}|rN|^qNS(u�
    Return a list of member workers from the configuration files

    CLI Examples:

    .. code-block:: bash

        salt '*' modjk.list_configured_members loadbalancer1
        salt '*' modjk.list_configured_members loadbalancer1 other-profile
    uworker.{0}.balance_workersu,(R0RtKeyErrortstripR!(R*R#tconfigR$t_f((s6/usr/lib/python2.7/site-packages/salt/modules/modjk.pytlist_configured_members�s
cC@s�t|�}|djd�}g}i}xI|D]A}y'|j|dj|�jd��Wq2tk
rrq2Xq2Wtt|��}x@|D]8}i|dj|�d6|dj|�d6||<q�W|S(u�
    Return a list of member workers and their status

    CLI Examples:

    .. code-block:: bash

        salt '*' modjk.workers
        salt '*' modjk.workers other-profile
    uworker.listu,uworker.{0}.balance_workersuworker.{0}.activationu
activationuworker.{0}.stateustate(R/R!textendRR1tlisttset(R#R3R*tworker_listR$tlbR)((s6/usr/lib/python2.7/site-packages/salt/modules/modjk.pytworkers�s 
!

cC@s�i}t|�}y |dj|�jd�}Wntk
rF|SXxy|D]q}t||�}|ddkr�t|||�n|djd�s�t|||�nt||�||<qNW|S(u�
    Set the all the workers in lbn to recover and activate them if they are not

    CLI Examples:

    .. code-block:: bash

        salt '*' modjk.recover_all loadbalancer1
        salt '*' modjk.recover_all loadbalancer1 other-profile
    uworker.{0}.balance_workersu,u
activationuACTustateuOK(R/RR!R1t
worker_statustworker_activatet
startswithtworker_recover(R*R#R$R3tworkers_R)t
curr_state((s6/usr/lib/python2.7/site-packages/salt/modules/modjk.pytrecover_all�s 

cC@s2idd6dd6|d6}t||�ddkS(u�
    Reset all runtime statistics for the load balancer

    CLI Examples:

    .. code-block:: bash

        salt '*' modjk.reset_stats loadbalancer1
        salt '*' modjk.reset_stats loadbalancer1 other-profile
    uresetucmdupropumimeuwuworker.result.typeuOK(R((R*R#R,((s6/usr/lib/python2.7/site-packages/salt/modules/modjk.pytreset_statss

cC@s5d|d<d|d<||d<t||�ddkS(uj
    Edit the loadbalancer settings

    Note: http://tomcat.apache.org/connectors-doc/reference/status.html
    Data Parameters for the standard Update Action

    CLI Examples:

    .. code-block:: bash

        salt '*' modjk.lb_edit loadbalancer1 "{'vlr': 1, 'vlt': 60}"
        salt '*' modjk.lb_edit loadbalancer1 "{'vlr': 1, 'vlt': 60}" other-profile
    uupdateucmdupropumimeuwuworker.result.typeuOK(R((R*tsettingsR#((s6/usr/lib/python2.7/site-packages/salt/modules/modjk.pytlb_edits


cC@swi}t|tj�r*|jd�}nxF|D]>}yt|||�||<Wq1tk
rnt||<q1Xq1W|S(u�
    Stop all the given workers in the specific load balancer

    CLI Examples:

    .. code-block:: bash

        salt '*' modjk.bulk_stop node1,node2,node3 loadbalancer1
        salt '*' modjk.bulk_stop node1,node2,node3 loadbalancer1 other-profile

        salt '*' modjk.bulk_stop ["node1","node2","node3"] loadbalancer1
        salt '*' modjk.bulk_stop ["node1","node2","node3"] loadbalancer1 other-profile
    u,(t
isinstanceRtstring_typesR!tworker_stopRtFalse(R;R*R#R$R)((s6/usr/lib/python2.7/site-packages/salt/modules/modjk.pyt	bulk_stop.s

cC@swi}t|tj�r*|jd�}nxF|D]>}yt|||�||<Wq1tk
rnt||<q1Xq1W|S(u�
    Activate all the given workers in the specific load balancer

    CLI Examples:

    .. code-block:: bash

        salt '*' modjk.bulk_activate node1,node2,node3 loadbalancer1
        salt '*' modjk.bulk_activate node1,node2,node3 loadbalancer1 other-profile

        salt '*' modjk.bulk_activate ["node1","node2","node3"] loadbalancer1
        salt '*' modjk.bulk_activate ["node1","node2","node3"] loadbalancer1 other-profile
    u,(RFRRGR!R=RRI(R;R*R#R$R)((s6/usr/lib/python2.7/site-packages/salt/modules/modjk.pyt
bulk_activateKs

cC@swi}t|tj�r*|jd�}nxF|D]>}yt|||�||<Wq1tk
rnt||<q1Xq1W|S(u�
    Disable all the given workers in the specific load balancer

    CLI Examples:

    .. code-block:: bash

        salt '*' modjk.bulk_disable node1,node2,node3 loadbalancer1
        salt '*' modjk.bulk_disable node1,node2,node3 loadbalancer1 other-profile

        salt '*' modjk.bulk_disable ["node1","node2","node3"] loadbalancer1
        salt '*' modjk.bulk_disable ["node1","node2","node3"] loadbalancer1 other-profile
    u,(RFRRGR!tworker_disableRRI(R;R*R#R$R)((s6/usr/lib/python2.7/site-packages/salt/modules/modjk.pytbulk_disablehs

cC@swi}t|tj�r*|jd�}nxF|D]>}yt|||�||<Wq1tk
rnt||<q1Xq1W|S(u�
    Recover all the given workers in the specific load balancer

    CLI Examples:

    .. code-block:: bash

        salt '*' modjk.bulk_recover node1,node2,node3 loadbalancer1
        salt '*' modjk.bulk_recover node1,node2,node3 loadbalancer1 other-profile

        salt '*' modjk.bulk_recover ["node1","node2","node3"] loadbalancer1
        salt '*' modjk.bulk_recover ["node1","node2","node3"] loadbalancer1 other-profile
    u,(RFRRGR!R?RRI(R;R*R#R$R)((s6/usr/lib/python2.7/site-packages/salt/modules/modjk.pytbulk_recover�s

cC@sUt|�}y0i|dj|�d6|dj|�d6SWntk
rPtSXdS(u�
    Return the state of the worker

    CLI Examples:

    .. code-block:: bash

        salt '*' modjk.worker_status node1
        salt '*' modjk.worker_status node1 other-profile
    uworker.{0}.activationu
activationuworker.{0}.stateustateN(R/RR1RI(R)R#R3((s6/usr/lib/python2.7/site-packages/salt/modules/modjk.pyR<�s
cC@s/idd6dd6|d6|d6}t||�S(u
    Set the worker to recover
    this module will fail if it is in OK state

    CLI Examples:

    .. code-block:: bash

        salt '*' modjk.worker_recover node1 loadbalancer1
        salt '*' modjk.worker_recover node1 loadbalancer1 other-profile
    urecoverucmdupropumimeuwusw(R((R)R*R#R,((s6/usr/lib/python2.7/site-packages/salt/modules/modjk.pyR?�s

cC@st||d|�S(u�
    Set the worker to disable state in the lbn load balancer

    CLI Examples:

    .. code-block:: bash

        salt '*' modjk.worker_disable node1 loadbalancer1
        salt '*' modjk.worker_disable node1 loadbalancer1 other-profile
    ud(R-(R)R*R#((s6/usr/lib/python2.7/site-packages/salt/modules/modjk.pyRL�scC@st||d|�S(u�
    Set the worker to activate state in the lbn load balancer

    CLI Examples:

    .. code-block:: bash

        salt '*' modjk.worker_activate node1 loadbalancer1
        salt '*' modjk.worker_activate node1 loadbalancer1 other-profile
    ua(R-(R)R*R#((s6/usr/lib/python2.7/site-packages/salt/modules/modjk.pyR=�scC@st||d|�S(u�
    Set the worker to stopped state in the lbn load balancer

    CLI Examples:

    .. code-block:: bash

        salt '*' modjk.worker_activate node1 loadbalancer1
        salt '*' modjk.worker_activate node1 loadbalancer1 other-profile
    us(R-(R)R*R#((s6/usr/lib/python2.7/site-packages/salt/modules/modjk.pyRH�scC@s?d|d<d|d<||d<||d<t||�ddkS(	u|
    Edit the worker settings

    Note: http://tomcat.apache.org/connectors-doc/reference/status.html
    Data Parameters for the standard Update Action

    CLI Examples:

    .. code-block:: bash

        salt '*' modjk.worker_edit node1 loadbalancer1 "{'vwf': 500, 'vwd': 60}"
        salt '*' modjk.worker_edit node1 loadbalancer1 "{'vwf': 500, 'vwd': 60}" other-profile
    uupdateucmdupropumimeuwuswuworker.result.typeuOK(R((R)R*RDR#((s6/usr/lib/python2.7/site-packages/salt/modules/modjk.pytworker_edit�s




N(+t__doc__t
__future__RRRtsalt.extRtsalt.ext.six.moves.urllib.parseRRt!salt.ext.six.moves.urllib.requestRRRRRRRRR	RRRR(R-R.R/R0R5R;RBRCRERJRKRMRNR<R?RLR=RHRO(((s6/usr/lib/python2.7/site-packages/salt/modules/modjk.pyt<module> s4(
		 $

Zerion Mini Shell 1.0