HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/modjk.cpython-310.pyc
o

�N�gY1�@s�dZddlZddlZdd�Zdd�Zd0dd	�Zd0d
d�Zd0dd
�Zd0dd�Z	d0dd�Z
d0dd�Zd0dd�Zd0dd�Z
d0dd�Zd0dd�Zd0dd�Zd0dd�Zd0d d!�Zd0d"d#�Zd0d$d%�Zd0d&d'�Zd0d(d)�Zd0d*d+�Zd0d,d-�Zd0d.d/�ZdS)1a�
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
�NcCsdS)z
    Always load
    T�rrr�F/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/modjk.py�__virtual__%srcCsFtj��}|j||||d�tj��}|j||||d�tj�||�S)z+
    returns a authentication handler.
    )�realmZuri�user�passwd)�urllib�requestZHTTPBasicAuthHandlerZadd_passwordZHTTPDigestAuthHandlerZbuild_opener)�urlrrrZbasic�digestrrr�_auth,s


r�defaultcCs(i}tdd|�d�d�}tdd|�d�d�}tdd|�d�d�}tdd|�d�d�}tdd|�d�d�}|sBtd	|����|rT|rTt||||d
�}tj�|�|dtj�|���7}tjj||d��	��
�D]&}	|	�d
d�}
|
d|vr�||
dd|
d��7<qk|
d||
d<qk|S)z3
    Make the http request and return the data
    z
config.getzmodjk:z:url�z:userz:passz:realmz:timeoutzmissing url in profile )r
rrr�?)�timeout�=�r�,)Z__salt__�	Exceptionrrr	Zinstall_opener�parse�	urlencode�urlopen�read�
splitlines�split)�opts�profile�retr
rrrrZauth�lineZspltrrr�_do_http8s$ rcCs"dd|||d�}t||�ddkS)z&
    enable/disable/stop a worker
    �update�prop)�cmd�mime�w�sw�vwa�worker.result.type�OK�r)�worker�lbnr&rr"rrr�_worker_ctlXs�r,cCs"ddd�}t||�d�d�dS)z�
    Return the modjk version

    CLI Examples:

    .. code-block:: bash

        salt '*' modjk.version
        salt '*' modjk.version other-profile
    �versionr!�r"r#zworker.jk_version�/���)rr�rr"rrrr-gs
�r-cC�ddd�}t||�S)z�
    Get the current running config (not from disk)

    CLI Examples:

    .. code-block:: bash

        salt '*' modjk.get_running
        salt '*' modjk.get_running other-profile
    �listr!r.r)r1rrr�get_runningz�
�
r4cCr2)z�
    Dump the original configuration that was loaded from disk

    CLI Examples:

    .. code-block:: bash

        salt '*' modjk.dump_config
        salt '*' modjk.dump_config other-profile
    �dumpr!r.r)r1rrr�dump_config�r5r7cCsLt|�}z
|d|�d�}WntygYSwdd�|���d�D�S)z�
    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
    �worker.�.balance_workerscSsg|]}|r|�qSrr)�.0Z_frrr�
<listcomp>�sz+list_configured_members.<locals>.<listcomp>r)r7�KeyError�stripr)r+r�configrrrr�list_configured_members�s�r?c	Cs�t|�}|d�d�}g}i}|D]}z|�|d|�d��d��Wqty,Yqwtt|��}|D]}|d|�d�|d|�d�d�||<q5|S)z�
    Return a list of member workers and their status

    CLI Examples:

    .. code-block:: bash

        salt '*' modjk.workers
        salt '*' modjk.workers other-profile
    zworker.listrr8r9�.activation�.state��
activation�state)r4r�extendr<r3�set)rr>r+Zworker_listrZlbr*rrr�workers�s  ��rGcCs�i}t|�}z
|d|�d��d�}Wnty|YSw|D]'}t||�}|ddkr4t|||�|d�d�sAt|||�t||�||<q!|S)z�
    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
    r8r9rrCZACTrDr()r4rr<�
worker_status�worker_activate�
startswith�worker_recover)r+rrr>Zworkers_r*Z
curr_staterrr�recover_all�s�
rLcCsdd|d�}t||�ddkS)z�
    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
    �resetr!)r"r#r$r'r(r))r+rr"rrr�reset_stats�s

�rNcCs*d|d<d|d<||d<t||�ddkS)aj
    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
    r r"r!r#r$r'r(r))r+�settingsrrrr�lb_edit
srPc	C�Ti}t|t�r|�d�}|D]}z
t|||�||<Wqty'd||<Yqw|S)a�
    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
    rF)�
isinstance�strr�worker_stopr�rGr+rrr*rrr�	bulk_stop �

�rVc	CrQ)a�
    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
    rF)rRrSrrIrrUrrr�
bulk_activate=rWrXc	CrQ)a�
    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
    rF)rRrSr�worker_disablerrUrrr�bulk_disableZrWrZc	CrQ)a�
    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
    rF)rRrSrrKrrUrrr�bulk_recoverwrWr[cCsBt|�}z|d|�d�|d|�d�d�WSty YdSw)z�
    Return the state of the worker

    CLI Examples:

    .. code-block:: bash

        salt '*' modjk.worker_status node1
        salt '*' modjk.worker_status node1 other-profile
    r8r@rArBF)r4r<)r*rr>rrrrH�s��rHcCsdd||d�}t||�S)a
    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
    Zrecoverr!)r"r#r$r%r))r*r+rr"rrrrK�s�
rKcC�t||d|�S)z�
    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
    �d�r,�r*r+rrrrrY��rYcCr\)z�
    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
    �ar^r_rrrrI�r`rIcCr\)z�
    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
    �sr^r_rrrrT�r`rTcCs2d|d<d|d<||d<||d<t||�ddkS)	a|
    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
    r r"r!r#r$r%r'r(r))r*r+rOrrrr�worker_edit�s
rc)r
)�__doc__�urllib.parser�urllib.requestrrrr,r-r4r7r?rGrLrNrPrVrXrZr[rHrKrYrIrTrcrrrr�<module>s2 

 





"