403Webshell
Server IP : 198.38.94.13  /  Your IP : 216.73.217.33
Web Server : Apache
System : Linux d4744.dxb1.stableserver.net 5.14.0-611.49.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Apr 21 16:39:08 EDT 2026 x86_64
User : revivere ( 1140)
PHP Version : 8.2.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/saltstack/salt/lib/python3.10/site-packages/salt/states/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/saltstack/salt/lib/python3.10/site-packages/salt/states/modjk.py
"""
State to control Apache modjk
"""

# Python Libs

import logging

log = logging.getLogger(__name__)


def __virtual__():
    """
    Load this state if modjk is loaded
    """
    if "modjk.workers" in __salt__:
        return True
    return (False, "modjk module could not be loaded")


def _bulk_state(saltfunc, lbn, workers, profile):
    """
    Generic function for bulk worker operation
    """
    ret = {"name": lbn, "result": True, "changes": {}, "comment": ""}

    if not isinstance(workers, list):
        ret["result"] = False
        ret["comment"] = f"workers should be a list not a {type(workers)}"
        return ret

    if __opts__["test"]:
        ret["result"] = None
        return ret

    log.info("executing %s to modjk workers %s", saltfunc, workers)
    try:
        cmdret = __salt__[saltfunc](workers, lbn, profile=profile)
    except KeyError:
        ret["result"] = False
        ret["comment"] = f"unsupported function {saltfunc}"
        return ret

    errors = []
    for worker, ok in cmdret.items():
        if not ok:
            errors.append(worker)

    ret["changes"] = {"status": cmdret}
    if errors:
        ret["result"] = False
        ret["comment"] = f"{saltfunc} failed on some workers"

    return ret


def worker_stopped(name, workers=None, profile="default"):
    """
    Stop all the workers in the modjk load balancer

    Example:

    .. code-block:: yaml

        loadbalancer:
          modjk.worker_stopped:
            - workers:
              - app1
              - app2
    """
    if workers is None:
        workers = []
    return _bulk_state("modjk.bulk_stop", name, workers, profile)


def worker_activated(name, workers=None, profile="default"):
    """
    Activate all the workers in the modjk load balancer

    Example:

    .. code-block:: yaml

        loadbalancer:
          modjk.worker_activated:
            - workers:
              - app1
              - app2
    """
    if workers is None:
        workers = []
    return _bulk_state("modjk.bulk_activate", name, workers, profile)


def worker_disabled(name, workers=None, profile="default"):
    """
    Disable all the workers in the modjk load balancer

    Example:

    .. code-block:: yaml

        loadbalancer:
          modjk.worker_disabled:
            - workers:
              - app1
              - app2
    """
    if workers is None:
        workers = []
    return _bulk_state("modjk.bulk_disable", name, workers, profile)


def worker_recover(name, workers=None, profile="default"):
    """
    Recover all the workers in the modjk load balancer

    Example:

    .. code-block:: yaml

        loadbalancer:
          modjk.worker_recover:
            - workers:
              - app1
              - app2
    """
    if workers is None:
        workers = []
    return _bulk_state("modjk.bulk_recover", name, workers, profile)

Youez - 2016 - github.com/yon3zu
LinuXploit