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

�N�g�B�@s|ddlZddlZdejd<ddlZddlZddlZddlmZm	Z	m
Z
mZmZm
Z
mZddlmZGdd�dejjj�ZdS)�NZ
pkg_resources)�AuthenticationError�AuthorizationError�EauthAuthenticationError�LoaderError�SaltClientError�SaltInvocationError�SaltSystemExit)�yamlify_argc@sreZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
ddd�Zdd�Zdd�Z
dd�Zdd�ZdS)�SaltCMDz6
    The execution of a salt command happens here
    csjddl�|��z|jjdk}�jj|��|dd�|_Wnty8}z|�	d|�d��WYd}~dSd}~ww|jj
sA|jjrG|��dS|jj
r\|��}|�||j�dd	��dS|jjdkrj|jjd
|j_|jd|jd|jd
|jj|jj|jjd�}d|jvr�ddl�z(�jj�tj�|jdd�d��}|��|d<Wd�n1s�wYWnty�|jd|d<Ynw|jj|d<|j r�|j |d<nd|d<|jj!dk�r	t"|���|jj!k�r	�jj#�$d�|jj%|j_
z|��W|j�&�dS|j�&�wt'|jd��rt'|jd�|d<t'|jd��r't'|jd�|d<t'|jd��r8t(t'|jd��|d<t'|jd��rIt(t'|jd��|d<t'|jd ��rZt(t'|jd ��|d <t'|jd!��rkt(t'|jd!��|d!<d|v�r�d|v�r�|jj�r�ddl)��j*�+|j�}|�,|jj�}|jj-�r�|�r�|�.|jj|�}|�r�|�dd�|d<|�s�t/j0�1d"�t/�	d�|�2|�|jj|d#<|jd$�r�|jj3d1i|��}	�jj#�$d%|	���dS|j�s�dSg}
g}�zH�z|jj4�r�|jj5}|jj4|d&<d|d'<n|jj6}|jj7�rMd|d(<d|jd(<i}
|d1i|��D])}d(}z|�8||�Wnt9�y5}zt:|��d}~wwd)|v�r@|
�2|��q|�;|�|�<|
�nq|jdd*k�r|i}
d}|jj6d1i|��D]}|�=|�\}}}|
�2|��qb|j|
||d+�nB|jj>�r�d|d,<i}
|d1i|��D]/}z|�=|�\}}}|
�?|�|j|||d+�|
�2|�W�q�t@�y�|�?|�Y�q�w|jd-du�r�|jdd*k�r�|jjAdu�r�|�<|
�|�B|�tC�fd.d/�|
D���s�t/j0�1d0�t/�	�jDjEjF�Wn$tGtHtItJtf�y}ztK|�}
|j|
ddd+�WYd}~n
d}~wwW|j�&�dSW|j�&�dS|j�&�w)2z/
        Execute the salt command line
        rN�T)�skip_perm_errorsZauto_reconnect��
�output�nested�timeout�tgt�fun�arg)rrrr�show_timeout�show_jid�tokenZcachedirz	.root_key�r�key�	delimiterZtgt_type�glob�zA
NOTICE: Too many minions targeted, switching to batch execution.�return�retZ
return_configZ
ret_configZ
return_kwargsZ
ret_kwargsZmodule_executorsZ
executor_opts�metadata�ERROR: Authentication failed
�eauth�asynczExecuted command with job ID: �subset�cli�progressZreturn_count�sys.doc)�retcode�verboseZcli_summaryc3s�|]
}|�jjjkVqdS)N)�defaults�	exitcodes�EX_OK)�.0Z	exit_code��salt��A/opt/saltstack/salt/lib/python3.10/site-packages/salt/cli/salt.py�	<genexpr>�s�
�zSaltCMD.run.<locals>.<genexpr>z0ERROR: Minions returned with non-zero exit code
r/)LZsalt.client�
parse_args�optionsr!�clientZget_local_clientZget_config_file_path�local_clientr�exit�batch�static�
_run_batchZpreview_target�_preview_target�_output_ret�config�getr�optsrrZsalt.utils.files�utils�filesZfopen�os�path�join�readline�OSErrorr�selected_target_optionZbatch_safe_limit�len�stringutils�	print_cliZbatch_safe_sizeZdestroy�getattrr	�	salt.auth�auth�Resolverr$�mktoken�	token_cli�sys�stderr�write�updateZ	cmd_asyncr#Z
cmd_subsetZcmd_clir%�
_progress_retrr�
_progress_end�_print_returns_summary�_format_retr(�append�KeyErrorr�_print_errors_summary�allr)r*Z
EX_GENERICrrrr�str)�selfr�excZminion_list�kwargsZfp_�resolver�res�tokZjidZretcodes�errorsZcmd_funcrr%�out�full_retZret_r'r/r-r0�runsF����
	�����

�
�
�





��

�


�


������
�zSaltCMD.runcCs|j�|jd|jpd�S)z>
        Return a list of minions from a given target
        rr)r5Zgather_minionsr<rF)r]r/r/r0r:�s�zSaltCMD._preview_targetcCs�ddl}i}d|jvr|jd|d<d|vr\|jjr\ddl}|j�|j�}|�|jj�}|jjrD|rD|�	|jj|�}|rD|�
dd�|d<|sQtj�
d�t�d�|�|�|jj|d<|jjr�|jjsid|jd<z
|jjj|j|d	d
�}Wnty�t�d�Ynwi}|��D]	\}}|�|�q�|�|d�dSz|jj|jd<|jjj|j||jd�}Wnty�t�d�Ynwd}	|��D]
\}}
|
|	kr�|
}	q�t�|	�dS)
Nrrrr r
r!z100%r7T)r!�quiet)r!Z_parserr)Zsalt.cli.batchr<r3r!rKrLrMr$rNrOr=rPrQrRr6rSr8r7ZBatchrrfr;)r]r.r!r`rarbr7r�_r'Zjob_retcoder/r/r0r9�sV



�

���zSaltCMD._run_batchcCsb|r-tjj�d�tjj�d�tjj�d�tjj�d�|D]}tjj�|�|��q dSdS)Nrz---------------------------ZErrors)r.r?rHrI�
_format_error)r]rc�errorr/r/r0rZ)s�zSaltCMD._print_errors_summaryc
Cs�d}d}g}g}g}g}|D]M}||}	t|	t�r$d|	vr$||�d�}	t|	t�rK|	�d�rKd|	vr8|�|�n	d|	vrA|�|�|d7}|�|�q|d7}|�||�r[|�|�qtjj	�
d�tjj	�
d�tjj	�
d	�tjj	�
d�tjj	�
d
||���tjj	�
d|���tjj	�
d|���tjj	�
d
t|����|jj
r�|r�tjj	�
d�d�|���|r�tjj	�
d�d�|���|r�tjj	�
d�d�|���tjj	�
d�dS)z)
        Display returns summary
        rr�Minion did not returnz
Not connectedzNo responserrz+-------------------------------------------ZSummaryz# of minions targeted: z# of minions returned: z"# of minions that did not return: z# of minions with errors: zMinions not connected: {}� zMinions not responding: {}zMinions with failures: {}N)�
isinstance�dictr=r\�
startswithrX�_get_retcoder.r?rHrIrGr3r(�formatrC)
r]rZreturn_counterZnot_return_counterZnot_return_minionsZnot_response_minionsZnot_connected_minionsZfailed_minionsZeach_minionZ
minion_retr/r/r0rV2sf�

�������zSaltCMD._print_returns_summarycCsddl}|j�|j�dS)Nr)�salt.outputrZprogress_end�progress_bar)r]rdr.r/r/r0rUjszSaltCMD._progress_endcCs\ddl}t|d�s!z|j�|j||�|_Wnty td��w|j�|j||j|�dS)z'
        Print progress events
        rNrszp
WARNING: Install the `progressbar` python package. Requested job was still run but output cannot be displayed.
)	rr�hasattrrZget_progressr<rs�	ExceptionrZupdate_progress)r]r%rdr.r/r/r0rTos
��zSaltCMD._progress_retrcCsdddl}|jddkrt|t�s|�|�n|jj|||j|d�|s0tj�	d�t�
d�dSdS)zG
        Print the output from a single return to the terminal
        rNrr&)rdr>Z_retcodezERROR: No return received
r
)rrr<rmru�_print_docsr�display_outputrPrQrRr6)r]rrdr'r.r/r/r0r;�s�zSaltCMD._output_retcCsZi}d}d}|��D]\}}|d||<d|vr|d}|�|�}||kr'|}q
|||fS)zJ
        Take the full return data and format it to simple output
        rrrrd)�itemsrp)r]rerrdr'r�dataZret_retcoder/r/r0rW�s
�
zSaltCMD._format_retcCsfd}t|t�r(|�dd�dkr(t|�dd�t�r$t|�dddi����S|dSt|t�r1|s1dS|S)z8
        Determine a retcode for a given return
        rr'r)rmrnr=�max�values�bool)r]rr'r/r/r0rp�szSaltCMD._get_retcodecCs&|��D]\}}d�||d�}q|S)Nz&Minion [{}] encountered exception '{}'�message)rxrq)r]Zminion_errorZminionZ	error_docrjr/r/r0ri�s
�zSaltCMD._format_errorcCsddl}i}|s|�dd�t|t�r|�d|�d��|D]0}t||t�r5||�d�s4||dkr5q||D]}||vrM|||rM|||||<q9q|jjrit|�D]}|j�|||id|j	�qWdSt|�D]}|j
j�|�d	��|j
j�||�|j
j�d
�qmdS)zR
        Print out the docstrings for all of the functions on the minions
        rNr
z%No minions found to gather docs from
rrkZ
VALUE_TRIMMEDr�:r)
rrr6rmr\ror3r�sortedrwr<r?rHrI)r]rr.Zdocs�hostrr/r/r0rv�s4
�����zSaltCMD._print_docsN)r)�__name__�
__module__�__qualname__�__doc__rfr:r9rZrVrUrTr;rWrprirvr/r/r/r0r
sK;	8
r
)rArP�modulesZsalt.defaults.exitcodesr.Zsalt.utils.parsersZsalt.utils.stringutilsZsalt.exceptionsrrrrrrrZsalt.utils.argsr	r?�parsersZSaltCMDOptionParserr
r/r/r/r0�<module>s
$