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

�N�g��@s@dZddlZdZdd�Zddd�Zd
dd	�Z			dd
d�ZdS)a|
Management of Redis server
==========================

.. versionadded:: 2014.7.0

:depends:   - redis Python module
:configuration: See :py:mod:`salt.modules.redis` for setup instructions.

.. code-block:: yaml

    key_in_redis:
      redis.string:
        - value: string data

The redis server information specified in the minion config file can be
overridden in states using the following arguments: ``host``, ``post``, ``db``,
``password``.

.. code-block:: yaml

    key_in_redis:
      redis.string:
        - value: string data
        - host: localhost
        - port: 6379
        - db: 0
        - password: somuchkittycat
�NZrediscCsdtvrtSdS)z6
    Only load if the redis module is in __salt__
    �
redis.set_key)Fz redis module could not be loaded)�__salt__�__virtualname__�rr�H/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/redismod.py�__virtual__$srcKs�|iddd�}td|fi|��}||kr*td||fi|��d|d|<d|d	<|rBtd
||fi|��d|��|dd<|S|rYtd
||fi|��d|�d�|dd<|S)a)
    Ensure that the key exists in redis with the value specified

    name
        Redis key to manage

    value
        Data to persist in key

    expire
        Sets time to live for key in seconds

    expireat
        Sets expiration time for key via UNIX timestamp, overrides `expire`
    Tz Key already set to defined value��name�changes�result�commentz
redis.get_keyrz
Value updatedr
zKey updated to new valuerzredis.expireatzKey expires at �expireatzredis.expirezTTL set to z seconds�expire�r)r	�valuerr
�connection_args�retZold_keyrrr�string-s$��rcs�|iddd�}|r:t|t�sd|d<d|d<|S�fdd	�|D�}|s%|Std
|i���||dd<d
|d<|Std|fi���rYtd
|fi���d|d<|g|dd<|S)z�
    Ensure key absent from redis

    name
        Key to ensure absent from redis

    keys
        list of keys to ensure absent, name will be ignored if this is used
    TzKey(s) specified already absentrFrz `keys` not formed as a list typercs$g|]}td|fi���r|�qS)�redis.existsr)�.0�key�rrr�
<listcomp>ks
��zabsent.<locals>.<listcomp>zredis.deleter
ZdeletedzKeys deletedrzKey deleted)�
isinstance�listr)r	�keysrrZdelete_listrrr�absentUs0�

�rc
Ks|iddd�}t�|�}td||||�}|dtd�vr+d|d<d	|��|d
<|Stddi|��}||krEd|d<d|��|d
<|Std
dur[d�||d�|d
<d|d<|S|jdi|��tddi|��tddi|��}	|	|kr{|Sd|d<||	d�|d<d|��|d
<|S)a

    Set this redis instance as a slave.

    .. versionadded:: 2016.3.0

    name
        Master to make this a slave of

    sentinel_host
        Ip of the sentinel to check for the master

    sentinel_port
        Port of the sentinel to check for the master

    FzFailed to setup slaverzredis.sentinel_get_master_ipZmaster_hostznetwork.ip_addrsTrzMinion is the master: rzredis.get_master_ipz Minion already slave of master: �testz%Minion will be made a slave of {}: {}�hostNz
redis.slaveof)�old�newr
z)Minion successfully connected to master: r)�copyrZ__opts__�format�update)
r	Z
sentinel_hostZ
sentinel_portZsentinel_passwordrr�kwargsZsentinel_masterZfirst_masterZcurrent_masterrrr�slaveof|sF�
��
�r%)NN)N)NNN)�__doc__r!rrrrr%rrrr�<module>s
	
()�