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

�N�g��@sldZddlZddlZddlZddlZddlZddlZddlm	Z	e�
e�Zdd�Z
						dd	d
�ZdS)a�
This runner makes Salt's
execution modules available
on the salt master.

.. versionadded:: 2016.11.0

.. _salt_salt_runner:

Salt's execution modules are normally available
on the salt minion. Use this runner to call
execution modules on the salt master.
Salt :ref:`execution modules <writing-execution-modules>`
are the functions called by the ``salt`` command.

Execution modules can be called with ``salt-run``:

.. code-block:: bash

    salt-run salt.cmd test.ping
    # call functions with arguments and keyword arguments
    salt-run salt.cmd test.arg 1 2 3 key=value a=1

Execution modules are also available to salt runners:

.. code-block:: python

    __salt__['salt.cmd'](fun=fun, args=args, kwargs=kwargs)

�N)�SaltClientErrorcOs�t�d|�tjjjdi|��}|�dd�}t�t	�}tj
�|�|d<|r>tjj
||d|d|d|�d�d���|d	<ni|d	<tj
j|tj
�|�td
�}||vr\|||i|��Sd|�d�S)a�
    .. versionchanged:: 2018.3.0
        Added ``with_pillar`` argument

    Execute ``fun`` with the given ``args`` and ``kwargs``.  Parameter ``fun``
    should be the string :ref:`name <all-salt.modules>` of the execution module
    to call.

    .. note::
        Execution modules will be loaded *every time* this function is called.
        Additionally, keep in mind that since runners execute on the master,
        custom execution modules will need to be synced to the master using
        :py:func:`salt-run saltutil.sync_modules
        <salt.runners.saltutil.sync_modules>`, otherwise they will not be
        available.

    with_pillar : False
        If ``True``, pillar data will be compiled for the master

        .. note::
            To target the master in the pillar top file, keep in mind that the
            default ``id`` for the master is ``<hostname>_master``. This can be
            overridden by setting an ``id`` configuration parameter in the
            master config file.

    CLI Example:

    .. code-block:: bash

        salt-run salt.cmd test.ping
        # call functions with arguments and keyword arguments
        salt-run salt.cmd test.arg 1 2 3 a=1
        salt-run salt.cmd mymod.myfunc with_pillar=True
    z.Called salt.cmd runner with minion function %s�with_pillarF�grains�id�saltenv�	pillarenv)rr�pillar)�utils�context�'z' is not available.N�)�log�debug�saltr	�argsZclean_kwargs�pop�copy�deepcopy�__opts__�loaderrrZ
get_pillar�getZcompile_pillarZminion_mods�__context__)�funr�kwargsr�optsZ	functionsrr�E/opt/saltstack/salt/lib/python3.10/site-packages/salt/runners/salt.py�cmd,s0#
�����
�rr�glob�cKs�tj�td��G}	z|	j||f||ptd||||d�|��WWd�StyN}
zt�d|||�t�|
�iWYd}
~
Wd�Sd}
~
ww1sRwYdS)a�
    .. versionadded:: 2017.7.0

    Execute ``fun`` on all minions matched by ``tgt`` and ``tgt_type``.
    Parameter ``fun`` is the name of execution module function to call.

    This function should mainly be used as a helper for runner modules,
    in order to avoid redundant code.
    For example, when inside a runner one needs to execute a certain function
    on arbitrary groups of minions, only has to:

    .. code-block:: python

        ret1 = __salt__['salt.execute']('*', 'mod.fun')
        ret2 = __salt__['salt.execute']('my_nodegroup', 'mod2.fun2', tgt_type='nodegroup')

    It can also be used to schedule jobs directly on the master, for example:

    .. code-block:: yaml

        schedule:
            collect_bgp_stats:
                function: salt.execute
                args:
                    - edge-routers
                    - bgp.neighbors
                kwargs:
                    tgt_type: nodegroup
                days: 1
                returner: redis
    Z	conf_file�timeout)�argr�tgt_type�ret�jid�kwargNz#Error while executing %s on %s (%s))r�clientZget_local_clientrrrr
�error)Ztgtrr rr!r"r#r$rr%Zclient_errorrrr�executems0*�
�	��

��
�r')rNrrrN)�__doc__r�loggingZsalt.clientrZsalt.loaderZsalt.pillarZsalt.utils.argsZsalt.exceptionsr�	getLogger�__name__r
rr'rrrr�<module>s"
D�