File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/__pycache__/runner.cpython-310.pyc
o
;j�6 � @ s� d Z ddlZddlZddlZddlZddlZddlZddlZddl Zddl
ZddlmZ ddl
mZ ddlmZ e�e�ZG dd� dejej�ZG dd � d e�ZdS )
z#
Execute salt convenience routines
� N)�mixins)�display_output)�
verify_func s| e Zd ZdZdZdZddd�Zdd� Zd d
� Zdd� Z e
d
d� �Zdd� Zdd� Z
ddd�Z d� fdd� Z� ZS )�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�runNc C sl t jj| ||d� t jj| ||d� || _|pi | _d | _tjj �
� | _tjjjd| jd | jdd�| _d S )N��context�masterZsock_dirF)�opts�listen)
r �SyncClientMixin�__init__�AsyncClientMixinr r �event�salt�utils�user�get_specific_userZ salt_user� get_event��selfr r � r �?/opt/saltstack/salt/lib/python3.10/site-packages/salt/runner.pyr ) s
�zRunnerClient.__init__c C s� | j d ur
| j �� d | _ t| d�r%| jd ur%t| jd�r"| j�� i | _t| d�r?| jd urAt| jd�r:| j�� i | _d S d S d S )N�
_functions�destroyr )r r �hasattrr r �r r r r r 4 s
�zRunnerClient.destroyc C s | S �Nr r r r r � __enter__A s zRunnerClient.__enter__c G s | � � d S r )r )r �argsr r r �__exit__D s zRunnerClient.__exit__c C sz t | d�s:t | d�stj�| j�| _ztjj| j| j| jd�| _W | jS ty9 tjj| j| jd�| _Y | jS w | jS )Nr r )r r r ) r r �loaderr r r r r �AttributeErrorr r r r � functionsG 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"']}``
�func s i | ]}|� v r|� � |��qS r )�pop)�.0�i��lowr r �
<dictcomp>f s
�
z.RunnerClient._reformat_low.<locals>.<dictcomp>)�username�password�eauth�token�clientr �key�argF)Z condition�kwargZ __kwarg__T)Zignore_invalid)r3 r2 )r% r3 Nr )
r&