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

�N�gtA�@s�dZddlZzddlZdZWneydZYnwdZdd�Zdcdd	�Zddd
d�Z	dcdd
�Z
dcdd�Zdedd�Zdcdd�Z
dcdd�Zdd�Zdcdd�Zdcdd�Zdcdd�Zdcdd �Zdcd!d"�Zdcd#d$�Zd%d&�Zdcd'd(�Zdcd)d*�Zdcd+d,�Zdfd.d/�Z	dgd1d2�Zdcd3d4�Zd5d6�Zd7d8�Zdcd9d:�Zdcd;d<�Z dcd=d>�Z!	dhd?d@�Z"dcdAdB�Z#dedCdD�Z$dcdEdF�Z%dcdGdH�Z&dcdIdJ�Z'dcdKdL�Z(dcdMdN�Z)dcdOdP�Z*dcdQdR�Z+dcdSdT�Z,	didUdV�Z-dcdWdX�Z.dcdYdZ�Z/dcd[d\�Z0dcd]d^�Z1ddd_d`�Z2dddadb�Z3dS)jaN
Module to provide redis functionality to Salt

.. versionadded:: 2014.7.0

:configuration: This module requires the redis python module and uses the
    following defaults which may be overridden in the minion configuration:

.. code-block:: yaml

    redis.host: 'salt'
    redis.port: 6379
    redis.db: 0
    redis.password: None
�NTF�rediscCstrtSdS)zC
    Only load this module if redis python module is installed
    )FzUThe redis execution module failed to load: the redis python library is not available.)�	HAS_REDIS�__virtualname__�rr�I/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/redismod.py�__virtual__srcCsT|stdd�}|stdd�}|stdd�}|s tdd�}tj||||dd�S)�1
    Returns an instance of the redis client
    �
config.optionz
redis.hostz
redis.portzredis.dbzredis.passwordT)�decode_responses�Z__salt__rZStrictRedis��host�port�db�passwordrrr�_connect+srcCsR|durtddd�}|durtddd�}|dur tdd�}tj|||dd	�S)
rNr	zredis_sentinel.hostZ	localhostzredis_sentinel.portigzredis_sentinel.passwordT)rr
r)r
rrrrr�	_sconnect;srcC�t||||�}|��S)z�
    Asynchronously rewrite the append-only file

    CLI Example:

    .. code-block:: bash

        salt '*' redis.bgrewriteaof
    )r�bgrewriteaof�r
rrr�serverrrrrI�
rcCr)z|
    Asynchronously save the dataset to disk

    CLI Example:

    .. code-block:: bash

        salt '*' redis.bgsave
    )r�bgsaverrrrrWrr�*cC�t||||�}|�|�S)z�
    Get redis server configuration values

    CLI Example:

    .. code-block:: bash

        salt '*' redis.config_get
        salt '*' redis.config_get port
    )r�
config_get��patternr
rrrrrrrre�
rcC�t||||�}|�||�S)z�
    Set redis server configuration values

    CLI Example:

    .. code-block:: bash

        salt '*' redis.config_set masterauth luv_kittens
    )r�
config_set)�name�valuer
rrrrrrrr t�
r cCr)z�
    Return the number of keys in the selected database

    CLI Example:

    .. code-block:: bash

        salt '*' redis.dbsize
    )r�dbsizerrrrr$�rr$cOs:i}dD]}||vr||||<qtdi|��}|j|�S)z�
    Deletes the keys from redis, returns number of keys deleted

    CLI Example:

    .. code-block:: bash

        salt '*' redis.delete foo
    rNr)r�delete)�keysZconnection_argsZ	conn_args�argrrrrr%�s�
r%cCr)z
    Return true if the key exists in redis

    CLI Example:

    .. code-block:: bash

        salt '*' redis.exists foo
    )r�exists��keyr
rrrrrrrr(��

r(cCr)z
    Set a keys time to live in seconds

    CLI Example:

    .. code-block:: bash

        salt '*' redis.expire foo 300
    )r�expire)r*�secondsr
rrrrrrrr,�r#r,cCr)z�
    Set a keys expire at given UNIX time

    CLI Example:

    .. code-block:: bash

        salt '*' redis.expireat foo 1400000000
    )r�expireat)r*�	timestampr
rrrrrrrr.�r#r.cCr)zy
    Remove all keys from all databases

    CLI Example:

    .. code-block:: bash

        salt '*' redis.flushall
    )r�flushallrrrrr0�rr0cCr)z�
    Remove all keys from the selected database

    CLI Example:

    .. code-block:: bash

        salt '*' redis.flushdb
    )r�flushdbrrrrr1�rr1cCr)zm
    Get redis key value

    CLI Example:

    .. code-block:: bash

        salt '*' redis.get_key foo
    )r�getr)rrr�get_key�r+r3cO�P|�dd�}|�dd�}|�dd�}|�dd�}t||||�}|j|g|�R�S)z�
    Delete one of more hash fields.

    .. versionadded:: 2017.7.0

    CLI Example:

    .. code-block:: bash

        salt '*' redis.hdel foo_hash bar_field1 bar_field2
    r
Nrrr)r2r�hdel�r*�fields�optionsr
r�databaserrrrrr5��r5cCr)z�
    Determine if a hash fields exists.

    .. versionadded:: 2017.7.0

    CLI Example:

    .. code-block:: bash

        salt '*' redis.hexists foo_hash bar_field
    )r�hexists�r*�fieldr
rrrrrrrr;sr;cCr)z�
    Get specific field value from a redis hash, returns dict

    CLI Example:

    .. code-block:: bash

        salt '*' redis.hget foo_hash bar_field
    )r�hgetr<rrrr>r#r>cCr)z�
    Get all fields and values from a redis hash, returns dict

    CLI Example:

    .. code-block:: bash

        salt '*' redis.hgetall foo_hash
    )r�hgetallr)rrrr?*r+r?�cC�t||||�}|j|||d�S)z�
    Increment the integer value of a hash field by the given number.

    .. versionadded:: 2017.7.0

    CLI Example:

    .. code-block:: bash

        salt '*' redis.hincrby foo_hash bar_field 5
    ��amount)r�hincrby�r*r=Z	incrementr
rrrrrrrrD8srD��?cCrA)z�
    Increment the float value of a hash field by the given number.

    .. versionadded:: 2017.7.0

    CLI Example:

    .. code-block:: bash

        salt '*' redis.hincrbyfloat foo_hash bar_field 5.17
    rB)r�hincrbyfloatrErrrrGHsrGcCr)z�
    Returns number of fields of a hash.

    .. versionadded:: 2017.7.0

    CLI Example:

    .. code-block:: bash

        salt '*' redis.hlen foo_hash
    )r�hlenr)rrrrHZ�
rHcOr4)z�
    Returns the values of all the given hash fields.

    .. versionadded:: 2017.7.0

    CLI Example:

    .. code-block:: bash

        salt '*' redis.hmget foo_hash bar_field1 bar_field2
    r
Nrrr)r2r�hmgetr6rrrrJjr:rJcKsZ|�dd�}|�dd�}|�dd�}|�dd�}t||||�}|�|tjjjdi|���S)z�
    Sets multiple hash fields to multiple values.

    .. versionadded:: 2017.7.0

    CLI Example:

    .. code-block:: bash

        salt '*' redis.hmset foo_hash bar_field1=bar_value1 bar_field2=bar_value2
    r
Nrrrr)�popr�hmset�salt�utils�argsZclean_kwargs)r*Z
fieldsvalsr
rr9rrrrrrL~srLcC�t||||�}|�|||�S)z�
    Set the value of a hash field.

    .. versionadded:: 2017.7.0

    CLI Example:

    .. code-block:: bash

        salt '*' redis.hset foo_hash bar_field bar_value
    )r�hset�r*r=r"r
rrrrrrrrQ��rQcCrP)z�
    Set the value of a hash field only if the field does not exist.

    .. versionadded:: 2017.7.0

    CLI Example:

    .. code-block:: bash

        salt '*' redis.hsetnx foo_hash bar_field bar_value
    )r�hsetnxrRrrrrT�rSrTcCr)z�
    Return all the values in a hash.

    .. versionadded:: 2017.7.0

    CLI Example:

    .. code-block:: bash

        salt '*' redis.hvals foo_hash bar_field1 bar_value1
    )r�hvalsr)rrrrU�rIrUc	Cs t||||�}|j||||d�S)z�
    Incrementally iterate hash fields and associated values.

    .. versionadded:: 2017.7.0

    CLI Example:

    .. code-block:: bash

        salt '*' redis.hscan foo_hash match='field_prefix_*' count=1
    )�cursor�match�count)r�hscan)	r*rVrWrXr
rrrrrrrrY�srYcCr)z�
    Get information and statistics about the server

    CLI Example:

    .. code-block:: bash

        salt '*' redis.info
    )r�inforrrrrZ�rrZcCr)z�
    Get redis keys, supports glob style patterns

    CLI Example:

    .. code-block:: bash

        salt '*' redis.keys
        salt '*' redis.keys test*
    )rr&rrrrr&�rr&cCr)zi
    Get redis key type

    CLI Example:

    .. code-block:: bash

        salt '*' redis.type foo
    )r�typer)rrr�key_type�r+r\cCst||||�}t|�����S)z�
    Get the UNIX time in seconds of the last successful save to disk

    CLI Example:

    .. code-block:: bash

        salt '*' redis.lastsave
    )r�int�lastsaver/rrrrr^�s
r^cCr)z}
    Get the length of a list in Redis

    CLI Example:

    .. code-block:: bash

        salt '*' redis.llen foo_list
    )r�llenr)rrrr_r+r_cCrP)z�
    Get a range of values from a list in Redis

    CLI Example:

    .. code-block:: bash

        salt '*' redis.lrange foo_list 0 10
    )r�lrange�r*�start�stopr
rrrrrrrr`�
r`cCs0t||||�}z|��WStjyYdSw)z�
    Ping the server, returns False on connection errors

    CLI Example:

    .. code-block:: bash

        salt '*' redis.ping
    F)r�pingr�ConnectionErrorrrrrre,s

�recCr)zy
    Synchronously save the dataset to disk

    CLI Example:

    .. code-block:: bash

        salt '*' redis.save
    )r�saverrrrrg=rrgcCr)zq
    Set redis key value

    CLI Example:

    .. code-block:: bash

        salt '*' redis.set_key foo bar
    )r�set)r*r"r
rrrrrrr�set_keyKr#ricCs`t||||�}z|��WntjyYdSw|��z|��WdStjy/YdSw)z�
    Synchronously save the dataset to disk and then shut down the server

    CLI Example:

    .. code-block:: bash

        salt '*' redis.shutdown
    FT)rrerrf�shutdownrrrrrjYs
�
��rjcCs&|r|sd}t||||�}|�||�S)aV
    Make the server a slave of another instance, or promote it as master

    CLI Example:

    .. code-block:: bash

        # Become slave of redis-n01.example.com:6379
        salt '*' redis.slaveof redis-n01.example.com 6379
        salt '*' redis.slaveof redis-n01.example.com
        # Become master
        salt '*' redis.slaveof
    i�)r�slaveof)�master_host�master_portr
rrrrrrrrkssrkcCst||||�}t|�|��S)zy
    Get members in a Redis set

    CLI Example:

    .. code-block:: bash

        salt '*' redis.smembers foo_set
    )r�list�smembersr)rrrro�rdrocCst||||�}|��dS)z�
    Return the current server UNIX time in seconds

    CLI Example:

    .. code-block:: bash

        salt '*' redis.time
    r)r�timerrrrrp�r#rpcCr)z�
    Get the length of a sorted set in Redis

    CLI Example:

    .. code-block:: bash

        salt '*' redis.zcard foo_sorted
    )r�zcardr)rrrrq�r+rqcCrP)z�
    Get a range of values from a sorted set in Redis by index

    CLI Example:

    .. code-block:: bash

        salt '*' redis.zrange foo_sorted 0 10
    )r�zrangerarrrrr�rdrrcCs(t|||�}|�|�}tttd|���S)z�
    Get ip for sentinel master

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt '*' redis.sentinel_get_master_ip 'mymaster'
    �rlrm)rZ sentinel_get_master_addr_by_name�dictrn�zip)Zmasterr
rrr�retrrr�sentinel_get_master_ip�s
rwcCs>t|||�}|��}|�dd�|�dd�f}tttd|���S)z�
    Get host information about slave

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt '*' redis.get_master_ip
    rl�rmrs)rrZr2rtrnru)r
rrrZsrv_inforvrrr�
get_master_ip�sry)NNNN)NNN)rNNNN)r@NNNN)rFNNNN)rNNNNNN)NNNNNN)4�__doc__Zsalt.utils.argsrMrr�ImportErrorrrrrrrrr r$r%r(r,r.r0r1r3r5r;r>r?rDrGrHrJrLrQrTrUrYrZr&r\r^r_r`rergrirjrkrorprqrrrwryrrrr�<module>sr�

















�




�










�