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__/minion.cpython-310.pyc
o

�N�g��@sZdZddlZddlZddlZddlZddlZddiZdd�Zdd�Z	d
d	d
�Z
dd�ZdS)z-
Module to provide information about minions
�N�list_�listc	Cs�tddd�}|�dd�}t|�}i}|D]=}g|tj�|�<z*tjj�	t�
|��D]}|�d�sGtj�tj�
||��rG|tj�|��|�q*WqtyRYqw|S)z�
    Return a list of accepted, denied, unaccepted and rejected keys.
    This is the same output as `salt-key -L`

    CLI Example:

    .. code-block:: bash

        salt 'master' minion.list
    �
config.get�pki_dir�ZminionZmaster�.)�__salt__�replace�_check_minions_directories�os�path�basename�salt�utils�dataZsorted_ignorecase�listdir�
startswith�isfile�join�append�OSError)rZkey_dirs�retZdir_Zfn_�r�G/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/minion.pyrs"
���cCs\tj�|tjjj�}tj�|tjjj�}tj�|tjjj�}tj�|tjjj	�}||||fS)zz
    Return the minion keys directory paths.

    This function is a copy of salt.key.Key._check_minions_directories.
    )
rrrr�keyZKeyZACCZPENDZREJZDEN)rZminions_acceptedZminions_preZminions_rejectedZminions_deniedrrrr
3s
r
�cCs�ddd�}g}t�d�}|s|�d�tjjj|d<nLdtvr,|�d�tjjj|d<n;ttd|��|d<|drA|�d	�n&t	|�D]}t
�d�td|�}|sZ||d
<n
qE|�d�tjjj|d<|rm||d<|S)
a�
    Kill the salt minion.

    timeout
        int seconds to wait for the minion to die.

    If you have a monitor that restarts ``salt-minion`` when it dies then this is
    a great way to restart after a minion upgrade.

    CLI Example:

    .. code-block:: bash

        salt minion[12] minion.kill

        minion1:
            ----------
            killed:
                7874
            retcode:
                0
        minion2:
            ----------
            killed:
                29071
            retcode:
                0

    The result of the salt command shows the process ID of the minions and the
    results of a kill signal to the minion in as the ``retcode`` value: ``0``
    is success, anything else is a failure.
    N�)�killed�retcode�pidzUnable to find "pid" in grainsrzps.kill_pidzMissing command: ps.kill_pidzps.kill_pid failedrz$Timed out waiting for minion to exit�comment)
Z
__grains__�getrr�defaultsZ	exitcodes�EX_SOFTWAREr�int�range�time�sleep�EX_TEMPFAIL)�timeoutrr r�_�signaledrrr�killAs4#�



�
r,cCshd}d}g}didd�}tdd�}|r$|�d�|�dd	�|D��nd
tjvr<tj}|�d�|�dd	�|D��nd
}|�d�|rt|�t��d|vri|drit|dt�rb|�|d�n|�|d�|drt|�d�d
}|r�td|t	j
d�|d<d|dvr�|dd=|d�dd�r�|�d�|dd|d<d|dvr�|dd=|r�||d<|S)ax
    Kill and restart the salt minion.

    The configuration key ``minion_restart_command`` is an argv list for the
    command to restart the minion.  If ``minion_restart_command`` is not
    specified or empty then the ``argv`` of the current process will be used.

    if the configuration value ``minion_restart_command`` is not set and the
    ``-d`` (daemonize) argument is missing from ``argv`` then the minion
    *will* be killed but will *not* be restarted and will require the parent
    process to perform the restart.  This behavior is intended for managed
    salt minion processes.

    CLI Example:

    .. code-block:: bash

        salt minion[12] minion.restart

        minion1:
            ----------
            comment:
                - Restart using process argv:
                -     /home/omniture/install/bin/salt-minion
                -     -d
                -     -c
                -     /home/omniture/install/etc/salt
            killed:
                10070
            restart:
                ----------
                stderr:
                stdout:
            retcode:
                0
        minion2:
            ----------
            comment:
                - Using configuration minion_restart_command:
                -     /home/omniture/install/bin/salt-minion
                -     --not-an-option
                -     -d
                -     -c
                -     /home/omniture/install/etc/salt
                - Restart failed
            killed:
                10896
            restart:
                ----------
                stderr:
                    Usage: salt-minion

                    salt-minion: error: no such option: --not-an-option
                stdout:
            retcode:
                64

    The result of the command shows the process ID of ``minion1`` that is
    shutdown (killed) and the results of the restart.  If there is a failure
    in the restart it will be reflected in a non-zero ``retcode`` and possibly
    output in the ``stderr`` and/or ``stdout`` values along with addition
    information in the ``comment`` field as is demonstrated with ``minion2``.
    TNr)r�restartrrZminion_restart_commandz+Using configuration minion_restart_command:cS�g|]}d|���qS�z    r��.0�argrrr�
<listcomp>��zrestart.<locals>.<listcomp>z-dzRestart using process argv:cSr.r/rr0rrrr3�r4FzCNot running in daemon mode - will not restart process after killingr rzKill failed - not restartingzcmd.run_all)�envr-rzRestart failed)rr�extend�sys�argv�updater,�
isinstance�strr�environr!)Zshould_killZshould_restartr rZrestart_cmdrrrr-�sPA�


�



r-)r)�__doc__rr7r&Zsalt.keyrZsalt.utils.dataZ__func_alias__rr
r,r-rrrr�<module>s#
I