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

�N�g��@s�dZddlZddlZddlZddlZddlmZddlZddl	Zddl
ZddlZddlZdgZ
e�e�Zdd�Zddd�Zd	d
�Z						ddd
�ZdS)zh
Use the :ref:`Salt Event System <events>` to fire events from the
master to the minion and vice-versa.
�N)�Mapping�*cs�fdd�|��D�S)zQ
    Return a dictionary of only the subset of keys/values specified in keys
    csi|]\}}|�vr||�qS�r)�.0�k�v��keysr�F/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/event.py�
<dictcomp>sz _dict_subset.<locals>.<dictcomp>)�items)r	Zmaster_dictrrr
�_dict_subsetsr
c
Cs�t�dd�st�dd�dkrt�dd�st�d|�dS|s%t�d�dkr�d	tvr=d
jtjj�td�t�dd
�d�td	<t	�}d}dtvrStdD]}|�
|�qJn|�
td	�tj�t�}td|||�
d�dd�}t|t�rw|�|�|D]1}tjjjjt|d��}	z	|	�|�d}Wnty�d}YnwWd�n1s�wYqy|Sztjjjtdd��||ddd�d�WSty�t��\}
}}t�|
||�}
t�|
�YdSw)z�
    Fire an event off up to the master server

    CLI Example:

    .. code-block:: bash

        salt '*' event.fire_master '{"data":"my event data"}' 'tag'
    �localN�file_client�use_master_when_localFz8Local mode detected. Event with tag %s will NOT be sent.Z__cliz	salt-call�
master_uriztcp://{ip}:{port}Z	interfaceZret_portZ4506)�ip�portTZmaster_uri_list�idssaltZ
_minion_event)r�tag�data�tok�cmd)r)�listen)rr�eventsZpretag�fire_master)�__opts__�get�log�warning�format�salt�utils�networkZ
ip_bracket�list�appendZcryptZSAuthZ	gen_token�
isinstance�dict�update�channel�clientZ
ReqChannel�factory�send�	Exception�eventZMinionEvent�
fire_event�sys�exc_info�	traceback�format_exception�debug)rr�preloadZmasters�retrZauth�loadZmasterr)�exc_type�	exc_value�
exc_traceback�linesrrr
rsn
�
�

���


�
����
�
�rcCs�z'tjjjdtdtdd��}|�||�Wd�WS1s wYWdStyDt��\}}}t	�
|||�}t�|�YdSw)z�
    Fire an event on the local minion event bus. Data must be formed as a dict.

    CLI Example:

    .. code-block:: bash

        salt '*' event.fire '{"data":"my event data"}' 'tag'
    Zminion�sock_dirF)r<�optsrN)
r!r"r.Z	get_eventrr/r-r0r1r2r3rr4)rrr.r8r9r:r;rrr
�fireds 
�
(�
�r>Fc	Ksi}|rt|t�rt|ttj��|d<nttj�|d<|r0t|t�r*t|t�|d<nt��|d<|rEt|t�r?t|t�|d<nt��|d<|rVt	�
dd�|d<t	�
d�|d<|r]|�|�t|t�rg|�|�t	�
d�szt	�
d�dkszt	�
d	�d
kr�t	�
d�s�t
||�St|||d�S)
a�	
    Send an event to the Salt Master

    .. versionadded:: 2014.7.0

    :param tag: A tag to give the event.
        Use slashes to create a namespace for related events. E.g.,
        ``myco/build/buildserver1/start``, ``myco/build/buildserver1/success``,
        ``myco/build/buildserver1/failure``.

    :param data: A dictionary of data to send in the event.
        This is free-form. Send any data points that are needed for whoever is
        consuming the event. Arguments on the CLI are interpreted as YAML so
        complex data structures are possible.

    :param with_env: Include environment variables from the current shell
        environment in the event data as ``environ``.. This is a short-hand for
        working with systems that seed the environment with relevant data such
        as Jenkins.
    :type with_env: Specify ``True`` to include all environment variables, or
        specify a list of strings of variable names to include.

    :param with_grains: Include grains from the current minion in the event
        data as ``grains``.
    :type with_grains: Specify ``True`` to include all grains, or specify a
        list of strings of grain names to include.

    :param with_pillar: Include Pillar values from the current minion in the
        event data as ``pillar``. Remember Pillar data is often sensitive data
        so be careful. This is useful for passing ephemeral Pillar values
        through an event. Such as passing the ``pillar={}`` kwarg in
        :py:func:`state.sls <salt.modules.state.sls>` from the Master, through
        an event on the Minion, then back to the Master.
    :type with_pillar: Specify ``True`` to include all Pillar values, or
        specify a list of strings of Pillar keys to include. It is a
        best-practice to only specify a relevant subset of Pillar data.

    :param with_env_opts: Include ``saltenv`` and ``pillarenv`` set on minion
        at the moment when event is send into event data.
    :type with_env_opts: Specify ``True`` to include ``saltenv`` and
        ``pillarenv`` values or ``False`` to omit them.

    :param kwargs: Any additional keyword arguments passed to this function
        will be interpreted as key-value pairs and included in the event data.
        This provides a convenient alternative to YAML for simple values.

    CLI Example:

    .. code-block:: bash

        salt-call event.send myco/mytag foo=Foo bar=Bar
        salt-call event.send 'myco/mytag' '{foo: Foo, bar: Bar}'

    �environZgrainsZpillarZsaltenv�baseZ	pillarenvrrZmaster_type�disabler)r5)r&r$r
r'�osr?Z
__grains__�valueZ
__pillar__rrr(rr>r)	rrr5Zwith_envZwith_grainsZwith_pillarZ
with_env_opts�kwargsZ	data_dictrrr
r,}s8@





��
r,)N)NNFFFF)�__doc__�loggingrBr0r2�collections.abcrZsalt.channel.clientr!Z
salt.cryptZsalt.payloadZsalt.utils.eventZsalt.utils.networkZ__proxyenabled__�	getLogger�__name__rr
rr>r,rrrr
�<module>s.

G�