HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/cli/__pycache__/caller.cpython-310.pyc
o

�N�gq+�@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Zddl
ZddlZddlZddl
ZddlZddlZddlZddlZddlmZddlmZmZmZmZe�e�ZGdd�d�ZGdd�d�ZGd	d
�d
e�ZdS)z]
The caller module is used as a front-end to manage direct calls to the salt
minion modules.
�N)�
LOG_LEVELS)�CommandExecutionError�CommandNotFoundError�SaltClientError�SaltInvocationErrorc@seZdZdZedd��ZdS)�CallerzK
    Factory class to create salt-call callers for different transport
    cKst|fi|��S)N)�ZeroMQCaller)�opts�kwargs�r�C/opt/saltstack/salt/lib/python3.10/site-packages/salt/cli/caller.py�factory(szCaller.factoryN)�__name__�
__module__�__qualname__�__doc__�staticmethodr
rrrrr#src@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�
BaseCallerz*
    Base class for caller transports
    c
Csj||_d|jd<z|j�d�rtj�|�|_WdStj�|�|_WdSty4}ztt|���d}~ww)z+
        Pass in command line opts
        TZcallerZproxyidN)	r	�get�salt�minionZSProxyMinionZSMinionr�
SystemExit�str)�selfr	�excrrr�__init__2s
��zBaseCaller.__init__cCsvi}|jj��D]\}}||vr|jr|j||<qt|�D]}|�|j�dd��r8tj	j
�|�d||�d��qdS)zT
        Pick up the documentation for all of the modules and print it out.
        �fun�z:
�
N)r�	functions�itemsr�sorted�
startswithr	rr�utils�stringutils�	print_cli)r�docs�name�funcrrr�
print_docsCs
���zBaseCaller.print_docscCs6|jj�d�p
tj�|j�}tj�d|id|j�dS)z&
        Print out the grains
        �grains�localN)rr	rr�loaderr*�output�display_output)rr*rrr�print_grainsPszBaseCaller.print_grainscCs*|j�dd�}z}tjj�|�}z|��}Wtjjj||j�dd�dd�ntjjj||j�dd�dd�w|�dd�}|jd	rE|}d}n|�d
i�}tjj	d|i||j|�dd
�d�|j�dd�rmt
�|d�WdS|�d�tjj
jkr�t
�tjj
j�WdSWdSty�}zt|��d}~ww)z-
        Execute the salt call logic
        �profiling_enabledFZprofiling_pathz
/tmp/statsT)Z
stats_path�stop�out�nestedZprint_metadata�returnr+�retcoder)r2r	Z_retcodeZretcode_passthroughN)r	rrr#ZprofileZactivate_profile�callZoutput_profiler-r.�sys�exit�defaults�	exitcodes�EX_OK�
EX_GENERICrr)rr0Zpr�retr2Z	print_ret�errrrr�runWsD
��

����zBaseCaller.runc
sxi�|jd}tjj�|j��d<tj�tj�	|jd��d�}||jj
vrx|jj
d|�d��}|rG|jj
�|�||<d�d<|�d<�Stj
�|jj
�|��|�d	�d
}||jjvrmtj
�d�|jj|��ntj
�d�t�d
�|j�d�}|dur�tjj�|�}�zx|t���ddd�}|dur�||d<tjj|jj
|tjjj|jd|j�dg�d�|d�\}}z#tjj�|d��}	|	�tj�|��Wd�n1s�wYWnty�Ynty�tj
�d�|��Ynw|jj
|}
||d�}|�|�t |jdg��ptjj�|j�dd��}|j�dd��r2tjj�|jd�|d<t!|t"��r;|g}z4|D]/}
|
�d�}||jj#v�rTt$d|
�d���|jj#||j||
||��d<�ddu�rln�q>WnIt%�y�}z<tj
�d|�d ��tjj&�'|
j(�t)�|jd!�*�t+j,�}|t+j-k�r�t.�/�}tj
�|�t�tj0j1j2�WYd}~nd}~wwz
|jj#j3d"�d#d
�}Wnt4�y�tj0j1j2}Ynw|d
k�r�z
t5�fd$d%�d&D��}Wnt6�y�d'}Ynw|�s�tj0j1j2}|�d#<Wngt7�yC}z4d(}t)�|jd!�*�t+j,�}|t+j-k�r'tj
�t.�/��tj
�|�||��t�tj0j1j2�WYd}~n+d}~wt8�yi}zd)}tj
�|�||��t�tj0j1j2�WYd}~nd}~wwzt�9|�Wn
t�y{Ynwt:|jj
|d*��r�|jj
|j;}t!|t"��r�|�d<|jd+�p�|j�d,d-�d+k�p�|j�d.�d/k}|j�dd0��d1�}|�r�|�r�|jd2�d2<|�d<|jd�d3<|du�r�|�d<|D]$}|�s�q�zd'�d4<|jj<|�d5���W�q�t6�yY�q�w|�s(|j�d6d-��s(z��=�}d7|d<|�>|�W�St6�y'Y�Sw|jd8�r:tjj�?|j�d���S)9z!
        Call the module
        r�jidZcachedirzsys.doc�*r3r2r4�.rz Possible reasons: {}
r����metadataNz	salt-call)r�pidr@Ztgt�arg�no_parse)rG)�datazw+bzLCannot write to process directory. Do you have permissions to write to {} ?
)rFrZmodule_executorsz
[direct_call]Z
executor_optsz.executez
Executor 'z' is not availablez
Passed invalid arguments: z
.

Usage:
Z	log_level�__context__r5c3s �|]}�d�|d�VqdS)r4TN)r)�.0�x�r=rr�	<genexpr>�s�
�z"BaseCaller.call.<locals>.<genexpr>)�result�successTzError running '{0}': {1}
z*Command required for '{0}' not found: {1}
�
__outputter__r+Zfile_clientFZmaster_type�disabler�,�idZfun_argsrOz	.returnerZno_return_eventZreq�
cache_jobs)@r	rr#r@Zgen_jid�os�path�joinrZget_proc_dirrZmissing_fun_stringr7�stderr�write�splitZfunction_errors�formatr8r�argsZyamlify_arg�getpidZload_args_and_kwargsZparse_input�filesZfopen�payload�dumps�	NameError�OSError�update�getattr�
isinstancer�	executorsr�	TypeErrorr$r%rr�lower�logging�ERROR�DEBUG�	traceback�
format_excr9r:r<�pack�AttributeError�all�	Exceptionrr�remove�hasattrrP�	returners�copy�
return_pubrT)rrZproc_fnr&�mod_namerDZsdatar\r
Zfp_r(rHrfr'�fnamerZactive_levelZtracer5Zfunc_result�msgZoputZis_localrtZreturnerZmretrrLrr6zsN
�
��
�
�
�����

����

������
�
��
������
���zBaseCaller.callN)	rrrrrr)r/r?r6rrrrr-s
#rcs(eZdZdZ�fdd�Zdd�Z�ZS)rzT
    Object to wrap the calling of local salt modules for the salt-call command
    cst��|�dS)z2
        Pass in the command line options
        N)�superr)rr	��	__class__rrr'szZeroMQCaller.__init__cCsptjjjj|jdd��#}d|jdd�}|��D]\}}|||<q|�|�Wd�dS1s1wYdS)z2
        Return the data up to the master
        Z	salt_call)�usageZ_returnrS)�cmdrSN)r�channel�clientZ
ReqChannelr
r	r �send)rr=r�load�key�valuerrrrv-s
�
"�zZeroMQCaller.return_pub)rrrrrrv�
__classcell__rrr{rr"sr)rrirUr7rlrZsalt.channel.clientZsalt.defaults.exitcodesZsalt.loaderZsalt.minionZsalt.outputZsalt.payloadZsalt.utils.argsZsalt.utils.filesZsalt.utils.jidZsalt.utils.minionZsalt.utils.profileZsalt.utils.stringutilsZ
salt._loggingrZsalt.exceptionsrrrr�	getLoggerr�logrrrrrrr�<module>s2

v