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/__pycache__/runner.cpython-310.pyc
o

�N�g�0�@s�dZddlZddlZddlZddlZddlZddlZddlZddl	Zddl
ZddlmZddl
mZddlmZe�e�ZGdd�dejej�ZGdd	�d	e�ZdS)
z#
Execute salt convenience routines
�N)�mixins)�display_output)�
verify_funcsZeZdZdZdZdZedd��Zdd�Zdd	�Z	ddd
�Z
	
	
	
		d�fdd�	Z�ZS)�RunnerClienta7
    The interface used by the :command:`salt-run` CLI tool on the Salt Master

    It executes :ref:`runner modules <all-salt.runners>` which run on the Salt
    Master.

    Importing and using ``RunnerClient`` must be done on the same machine as
    the Salt Master and it must be done using the same user that the Salt
    Master is running as.

    Salt's :conf_master:`external_auth` can be used to authenticate calls. The
    eauth user must be authorized to execute runner modules: (``@runner``).
    Only the :py:meth:`master_call` below supports eauth.
    �runner�runcCszt|d�s:t|d�stj�|j�|_ztjj|j|j|jd�|_W|jSty9tjj|j|jd�|_Y|jSw|jS)N�
_functions�utils)r	�context�r
)	�hasattr�salt�loaderr	�optsrr
r�AttributeError)�self�r�?/opt/saltstack/salt/lib/python3.10/site-packages/salt/runner.py�	functions)s


���zRunnerClient.functionsc	s���d�}t|j|��fdd�dD�}tjjj��dg�dd�\}}|���di��|���g}|�|�|�	t
dd	d
i|���tjj|j||d
d�\}}t
d|||d�d
�|��S)a�
        Format the low data for RunnerClient()'s master_call() function

        This also normalizes the following low data formats to a single, common
        low data structure.

        Old-style low: ``{'fun': 'jobs.lookup_jid', 'jid': '1234'}``
        New-style: ``{'fun': 'jobs.lookup_jid', 'kwarg': {'jid': '1234'}}``
        CLI-style: ``{'fun': 'jobs.lookup_jid', 'arg': ['jid="1234"']}``
        �funcs i|]}|�vr|��|��qSr)�pop)�.0�i��lowrr�
<dictcomp>Hs
	
�
z.RunnerClient._reformat_low.<locals>.<dictcomp>)�username�password�eauth�token�client�user�key�argF)Z	condition�kwargZ	__kwarg__T)Zignore_invalid)r$r#)rr$Nr)
rrrr
r	�args�parse_input�update�extend�append�dict�minion�load_args_and_kwargs)	rrrZeauth_credsZ_argZ_kwargZmungedr#r$rrr�
_reformat_low:s

�


�zRunnerClient._reformat_lowcCs|�|�}tj�||�S)a�
        Execute a runner function asynchronously; eauth is respected

        This function requires that :conf_master:`external_auth` is configured
        and the user is authorized to execute runner functions: (``@runner``).

        .. code-block:: python

            runner.cmd_async({
                'fun': 'jobs.list_jobs',
                'username': 'saltdev',
                'password': 'saltdev',
                'eauth': 'pam',
            })
        )r-r�AsyncClientMixin�	cmd_async)rr�reformatted_lowrrrr/ls
zRunnerClient.cmd_asyncNFcCs|�|�}tj�||||�S)a�
        Execute a runner function synchronously; eauth is respected

        This function requires that :conf_master:`external_auth` is configured
        and the user is authorized to execute runner functions: (``@runner``).

        .. code-block:: python

            runner.cmd_sync({
                'fun': 'jobs.list_jobs',
                'username': 'saltdev',
                'password': 'saltdev',
                'eauth': 'pam',
            })
        )r-r�SyncClientMixin�cmd_sync)rr�timeout�full_returnr0rrrr2�s
�zRunnerClient.cmd_syncTcst��||||||�S)a�
        Execute a function

        .. code-block:: python

            >>> opts = salt.config.master_config('/etc/salt/master')
            >>> runner = salt.runner.RunnerClient(opts)
            >>> runner.cmd('jobs.list_jobs', [])
            {
                '20131219215650131543': {
                    'Arguments': [300],
                    'Function': 'test.sleep',
                    'StartTime': '2013, Dec 19 21:56:50.131543',
                    'Target': '*',
                    'Target-type': 'glob',
                    'User': 'saltdev'
                },
                '20131219215921857715': {
                    'Arguments': [300],
                    'Function': 'test.sleep',
                    'StartTime': '2013, Dec 19 21:59:21.857715',
                    'Target': '*',
                    'Target-type': 'glob',
                    'User': 'saltdev'
                },
            }

        )�super�cmd)rrr#Zpub_datar$Zprint_eventr4��	__class__rrr6�s%zRunnerClient.cmd)NF)NNNTF)
�__name__�
__module__�__qualname__�__doc__r Z
tag_prefix�propertyrr-r/r2r6�
__classcell__rrr7rrs
2
�rcs8eZdZdZd
�fdd�	Z�fdd�Zddd	�Z�ZS)�Runnerz+
    Execute the salt runner interface
    Ncs8t�j||d�tjj||j|d�|_tj�|�|_dS)Nr)r5�__init__r
rZ	returnersrZ
outputters)rrr
r7rrr@�szRunner.__init__csL|j�dd�}t��|�}t|�D]}t|�d�d|j�t||�qdS)z.
        Print out the documentation!
        rN�:�text)r�getr5�get_docs�sortedr�print)rr#Zdocsrr7rr�
print_docs�s�zRunner.print_docsFcCs�ddl}i}|j�dd�r|��dSd|jdi}�za|j|j�d�d�}|d|_|jjj|jd|j�d	g�d
�}t	|j
|d�|j�|j
|d|�\}}||d<||d<|j�d�r�d
|jvr�z-|jj
�tj�|jdd�d��}	|jj�|	���|d<Wd�n1s�wYWnty�|jd
|d
<Ynwd
|vr�d|vr�|jdr�ddl}|j�|j�}
|
�|jd�}|jdr�|r�|
�|jd|�}|r�|�d
d�|d
<|s�t�d�|WS|�|�|jd|d<n|jj��}
|ddv�r	|d|dd<|j�dd��r7|j�d��r|� |�}n|j!|jd||
|d�}t�"d|d�|dWS|j�d��re|�#|�}t$|t%��r[t&|�ddhk�r[|d}|d}nd}t'|||j�n|j(||j|jd||
|d|dd|d�	}Wnw|j)j*�y�}zh|jj+j,d|jd�� }|j-d|�d |jd||jd!�d"|j�d#�d$�Wd�n	1�s�wYd|v�r�|�.d%�/|d��}nd}|�s�|�}|j�d&d��s�t'|d'|j�WYd}~|SWYd}~|Sd}~wwt�0d(|�|S))z-
        Execute the runner sequence
        rN�docFr�jid)rIr#�no_parse)rJr$rrZcachedirz	.root_key�rr"Zmktoken�zAuthentication failed)zstate.orchestratez
state.orchz	state.slsZorchestration_jid�async)r!Zpubz�Running in asynchronous mode. Results of this execution may be collected by attaching to the master event bus or by examining the master job cache, if configured. This execution is running under tag %s�tag�data�	outputter)	�instancerrrr!rNrIZ	daemonizer4Zmaster)r�)�success�return�retcoder�fun_argsrIz	salt/run/z/ret)rNz{}*�quiet�nestedzRunner return: %s)1�salt.minionrrCrGZ_gen_async_pubrIr	r%r&rrr+r,�filesZfopen�os�path�joinZstringutilsZ
to_unicode�readline�OSErrorZ	salt.authZauthZResolverZcliZ	token_cli�log�errorr'r!Zget_specific_userr/Zasynchronous�warningr2�
isinstancer*�setrZ_proc_function�
exceptionsZ
SaltException�eventZ	get_eventZ
fire_eventrD�format�debug)rr4r
�retrZ	async_pubrVr%�kwargsZfp_Zresolver�res�tokr!rP�excZevtrrrr�s�
��
�
����

���


�����


���z
Runner.run)N)F)r9r:r;r<r@rGrr>rrr7rr?�s
r?)r<�loggingr[Zsalt.exceptionsr
Zsalt.loaderrYZsalt.utils.argsZsalt.utils.eventZsalt.utils.filesZsalt.utils.userZsalt.clientrZsalt.outputrZsalt.utils.lazyr�	getLoggerr9r`r1r.rr?rrrr�<module>s"
(