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/states/__pycache__/kapacitor.cpython-310.pyc
o

�N�g��@sDdZddlZddlZddlZdd�Z					ddd	�Zd
d�ZdS)
a�
Kapacitor state module.

:configuration: This module accepts connection configuration details either as
    parameters or as configuration settings in /etc/salt/minion on the relevant
    minions::

        kapacitor.unsafe_ssl: 'false'
        kapacitor.protocol: 'http'
        kapacitor.host: 'localhost'
        kapacitor.port: 9092

    This data can also be passed into pillar. Options passed into opts will
    overwrite options passed into pillar.

.. versionadded:: 2016.11.0
�NcCsdtvrdSdS)Nzkapacitor.versionZ	kapacitor)Fz$kapacitor module could not be loaded)�__salt__�rr�I/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/kapacitor.py�__virtual__sr�stream�defaultTcCs�g}g}|iddd�}	td|�}
|
r|
dnd}|sg}|r-|r-|�d|��}|�|�dd�d	d
�|D�D�}
|�d�rFtd|t�}n|}tjj�|d
��}tjj�	|�
���dd�}Wd�n1shwY|
o~||ko~||
dko~|
d|
k}|r�|�d�ntdr�d|	d<|�d�n0td||||||d�}|d|	d<|	ds�|�d�|�
d�r�|�|d�d�|�|	d<|	S||kr�d�t�|��|����|	dd<|�d �|
r�|
d|kr�||	dd<|�d!�|
r�|
d|
k�r|
|	dd<|�d"�|�ra|
�r|
d#�r|�d$�n�td�r&d|	d<|�d%�n1td&|�}|d|	d<|	d�sR|�d'�|�
d��rI|�|d�d�|�|	d<|	S|�d(�d)dd*�|	dd#<nW|
�ro|
d#�so|�d+�nItd�r~d|	d<|�d,�n1td-|�}|d|	d<|	d�s�|�d.�|�
d��r�|�|d�d�|�|	d<|	S|�d/�dd)d*�|	dd#<d�|�|	d<|	S)0a2
    Ensure that a task is present and up-to-date in Kapacitor.

    name
        Name of the task.

    tick_script
        Path to the TICK script for the task. Can be a salt:// source.

    task_type
        Task type. Defaults to 'stream'

    dbrps
        A list of databases and retention policies in "dbname"."rpname" format
        to fetch data from. For backward compatibility, the value of
        'database' and 'retention_policy' will be merged as part of dbrps.

        .. versionadded:: 2019.2.0

    database
        Which database to fetch data from. Defaults to None, which will use the
        default database in InfluxDB.

    retention_policy
        Which retention policy to fetch data from. Defaults to 'default'.

    enable
        Whether to enable the task or not. Defaults to True.
    T���name�changes�result�comment�kapacitor.get_taskZscript�.cSsg|]}|d|dd��qS)r�)ZdbZrpr��.0�dbrprrr�
<listcomp>Ps�z task_present.<locals>.<listcomp>css�|]}|�d�VqdS)rN)�splitrrrr�	<genexpr>Qs�ztask_present.<locals>.<genexpr>zsalt://z
cp.cache_file�r�	z    N�type�dbrpsz!Task script is already up-to-date�testrzTask would have been updatedzkapacitor.define_task)�	task_type�database�retention_policyr�successzCould not define task�stderr�
r
rzTICKscript diffzTask script updatedzTask type updatedzTask dbrps updated�enabledzTask is already enabledzTask would have been enabledzkapacitor.enable_taskzCould not enable taskzTask was enabledF)�old�newzTask is already disabledzTask would have been disabledzkapacitor.disable_task�Could not disable taskzTask was disabled)r�append�
startswithZ__env__�salt�utils�filesZfopenZstringutilsZ
to_unicode�read�replace�__opts__�get�join�difflibZunified_diff�
splitlines)r
Ztick_scriptrrr�enablerZcommentsr�ret�taskZ
old_scriptrZ
task_dbrpsZscript_path�fileZ
new_scriptZ
is_up_to_daterrrr�task_presents�&
�
��
�
��

��










r6cCs�|iddd�}td|�}|rOtdrd|d<d|d	<n+td
|�}|d|d<|dsCd|d	<|�d
�rA|d	d|d
7<|Sd|d	<d|d|<|Sd|d	<|S)zZ
    Ensure that a task is absent from Kapacitor.

    name
        Name of the task.
    Trr	rrNrzTask would have been deletedr
zkapacitor.delete_taskrr%r r!zTask was deletedZdeletedrzTask does not exist)rr-r.)r
r3r4rrrr�task_absent�s$

�r7)rNrTN)�__doc__r0Zsalt.utils.filesr(Zsalt.utils.stringutilsrr6r7rrrr�<module>s	
�