%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/modules/redismod.pyc

�
���^c@@sdZddlmZmZmZddlmZddlmZddl	m	Z	ddl
ZyddlZe
ZWnek
r�eZnXdZd�Zddddd	�Zdddd
�Zddddd�Zddddd�Zd
ddddd�Zddddd�Zddddd�Zd�Zddddd�Zddddd�Zddddd�Zddddd�Zddddd�Z ddddd�Z!d�Z"ddddd�Z#ddddd�Z$ddddd�Z%dddddd�Z&dddddd�Z'ddddd �Z(d!�Z)d"�Z*ddddd#�Z+ddddd$�Z,ddddd%�Z-dddddddd&�Z.ddddd'�Z/d
ddddd(�Z0ddddd)�Z1ddddd*�Z2ddddd+�Z3ddddd,�Z4ddddd-�Z5ddddd.�Z6ddddd/�Z7ddddd0�Z8ddddddd1�Z9ddddd2�Z:ddddd3�Z;ddddd4�Z<ddddd5�Z=dddd6�Z>dddd7�Z?dS(8uN
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
i(tabsolute_importtunicode_literalstprint_function(tzip(tsix(tdatetimeNurediscC@str
tStdfSdS(uC
    Only load this module if redis python module is installed
    uUThe redis execution module failed to load: the redis python library is not available.N(t	HAS_REDISt__virtualname__tFalse(((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyt__virtual__#scC@s�|stdd�}n|s2tdd�}n|sKtdd�}n|sdtdd�}ntj||||dt�S(u1
    Returns an instance of the redis client
    u
config.optionu
redis.hostu
redis.porturedis.dburedis.passwordtdecode_responses(t__salt__tredistStrictRedistTrue(thosttporttdbtpassword((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyt_connect-scC@s|d	kr"tddd�}n|d	krDtddd�}n|d	krctdd�}ntj||d|dt�S(
u1
    Returns an instance of the redis client
    u
config.optionuredis_sentinel.hostu	localhosturedis_sentinel.portiguredis_sentinel.passwordRR
N(tNoneRRR
R(RRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyt	_sconnect=scC@st||||�}|j�S(u�
    Asynchronously rewrite the append-only file

    CLI Example:

    .. code-block:: bash

        salt '*' redis.bgrewriteaof
    (Rtbgrewriteaof(RRRRtserver((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyRKs
cC@st||||�}|j�S(u|
    Asynchronously save the dataset to disk

    CLI Example:

    .. code-block:: bash

        salt '*' redis.bgsave
    (Rtbgsave(RRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyRYs
u*cC@s"t||||�}|j|�S(u�
    Get redis server configuration values

    CLI Example:

    .. code-block:: bash

        salt '*' redis.config_get
        salt '*' redis.config_get port
    (Rt
config_get(tpatternRRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyRgscC@s%t||||�}|j||�S(u�
    Set redis server configuration values

    CLI Example:

    .. code-block:: bash

        salt '*' redis.config_set masterauth luv_kittens
    (Rt
config_set(tnametvalueRRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyRvs
cC@st||||�}|j�S(u�
    Return the number of keys in the selected database

    CLI Example:

    .. code-block:: bash

        salt '*' redis.dbsize
    (Rtdbsize(RRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyR�s
cO@sYi}x7ddddgD]#}||kr||||<qqWt|�}|j|�S(u�
    Deletes the keys from redis, returns number of keys deleted

    CLI Example:

    .. code-block:: bash

        salt '*' redis.delete foo
    uhostuportudbupassword(Rtdelete(tkeystconnection_argst	conn_argstargR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyR�scC@s"t||||�}|j|�S(u
    Return true if the key exists in redis

    CLI Example:

    .. code-block:: bash

        salt '*' redis.exists foo
    (Rtexists(tkeyRRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyR$�s
cC@s%t||||�}|j||�S(u
    Set a keys time to live in seconds

    CLI Example:

    .. code-block:: bash

        salt '*' redis.expire foo 300
    (Rtexpire(R%tsecondsRRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyR&�s
cC@s%t||||�}|j||�S(u�
    Set a keys expire at given UNIX time

    CLI Example:

    .. code-block:: bash

        salt '*' redis.expireat foo 1400000000
    (Rtexpireat(R%t	timestampRRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyR(�s
cC@st||||�}|j�S(uy
    Remove all keys from all databases

    CLI Example:

    .. code-block:: bash

        salt '*' redis.flushall
    (Rtflushall(RRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyR*�s
cC@st||||�}|j�S(u�
    Remove all keys from the selected database

    CLI Example:

    .. code-block:: bash

        salt '*' redis.flushdb
    (Rtflushdb(RRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyR+�s
cC@s"t||||�}|j|�S(um
    Get redis key value

    CLI Example:

    .. code-block:: bash

        salt '*' redis.get_key foo
    (Rtget(R%RRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pytget_key�s
cO@sm|jdd�}|jdd�}|jdd�}|jdd�}t||||�}|j||�S(u�
    Delete one of more hash fields.

    .. versionadded:: 2017.7.0

    CLI Example:

    .. code-block:: bash

        salt '*' redis.hdel foo_hash bar_field1 bar_field2
    uhostuportudbupasswordN(R,RRthdel(R%tfieldstoptionsRRtdatabaseRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyR.�scC@s%t||||�}|j||�S(u�
    Determine if a hash fields exists.

    .. versionadded:: 2017.7.0

    CLI Example:

    .. code-block:: bash

        salt '*' redis.hexists foo_hash bar_field
    (Rthexists(R%tfieldRRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyR2scC@s%t||||�}|j||�S(u�
    Get specific field value from a redis hash, returns dict

    CLI Example:

    .. code-block:: bash

        salt '*' redis.hget foo_hash bar_field
    (Rthget(R%R3RRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyR4s
cC@s"t||||�}|j|�S(u�
    Get all fields and values from a redis hash, returns dict

    CLI Example:

    .. code-block:: bash

        salt '*' redis.hgetall foo_hash
    (Rthgetall(R%RRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyR5,s
icC@s+t||||�}|j||d|�S(u�
    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
    tamount(Rthincrby(R%R3t	incrementRRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyR7:sg�?cC@s+t||||�}|j||d|�S(u�
    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
    R6(Rthincrbyfloat(R%R3R8RRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyR9JscC@s"t||||�}|j|�S(u�
    Returns number of fields of a hash.

    .. versionadded:: 2017.7.0

    CLI Example:

    .. code-block:: bash

        salt '*' redis.hlen foo_hash
    (Rthlen(R%RRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyR:ZscO@sm|jdd�}|jdd�}|jdd�}|jdd�}t||||�}|j||�S(u�
    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
    uhostuportudbupasswordN(R,RRthmget(R%R/R0RRR1RR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyR;jscK@s||jdd�}|jdd�}|jdd�}|jdd�}t||||�}|j|tjjj|��S(u�
    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
    uhostuportudbupasswordN(tpopRRthmsettsalttutilstargstclean_kwargs(R%t
fieldsvalsRRR1RR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyR=~scC@s(t||||�}|j|||�S(u�
    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
    (Rthset(R%R3RRRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyRC�scC@s(t||||�}|j|||�S(u�
    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
    (Rthsetnx(R%R3RRRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyRD�scC@s"t||||�}|j|�S(u�
    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
    (Rthvals(R%RRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyRE�sc	C@s4t||||�}|j|d|d|d|�S(u�
    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
    tcursortmatchtcount(Rthscan(	R%RFRGRHRRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyRI�scC@st||||�}|j�S(u�
    Get information and statistics about the server

    CLI Example:

    .. code-block:: bash

        salt '*' redis.info
    (Rtinfo(RRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyRJ�s
cC@s"t||||�}|j|�S(u�
    Get redis keys, supports glob style patterns

    CLI Example:

    .. code-block:: bash

        salt '*' redis.keys
        salt '*' redis.keys test*
    (RR (RRRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyR �scC@s"t||||�}|j|�S(ui
    Get redis key type

    CLI Example:

    .. code-block:: bash

        salt '*' redis.type foo
    (Rttype(R%RRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pytkey_type�s
cC@s^t||||�}tjrDt|j�tddd�j��St|j�j��SdS(u�
    Get the UNIX time in seconds of the last successful save to disk

    CLI Example:

    .. code-block:: bash

        salt '*' redis.lastsave
    i�iN(RRtPY2tinttlastsaveRt
total_secondsR)(RRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyRO�s
	&cC@s"t||||�}|j|�S(u}
    Get the length of a list in Redis

    CLI Example:

    .. code-block:: bash

        salt '*' redis.llen foo_list
    (Rtllen(R%RRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyRQs
cC@s(t||||�}|j|||�S(u�
    Get a range of values from a list in Redis

    CLI Example:

    .. code-block:: bash

        salt '*' redis.lrange foo_list 0 10
    (Rtlrange(R%tstarttstopRRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyRRs
cC@s?t||||�}y|j�SWntjk
r:tSXdS(u�
    Ping the server, returns False on connection errors

    CLI Example:

    .. code-block:: bash

        salt '*' redis.ping
    N(RtpingRtConnectionErrorR(RRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyRU-s

cC@st||||�}|j�S(uy
    Synchronously save the dataset to disk

    CLI Example:

    .. code-block:: bash

        salt '*' redis.save
    (Rtsave(RRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyRW>s
cC@s%t||||�}|j||�S(uq
    Set redis key value

    CLI Example:

    .. code-block:: bash

        salt '*' redis.set_key foo bar
    (Rtset(R%RRRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pytset_keyLs
cC@sot||||�}y|j�Wntjk
r:tSX|j�y|j�Wntjk
rjtSXtS(u�
    Synchronously save the dataset to disk and then shut down the server

    CLI Example:

    .. code-block:: bash

        salt '*' redis.shutdown
    (RRURRVRtshutdownR(RRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyRZZs

cC@s;|r|rd}nt||||�}|j||�S(uV
    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�(Rtslaveof(tmaster_hosttmaster_portRRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyR[ts
	cC@s(t||||�}t|j|��S(uy
    Get members in a Redis set

    CLI Example:

    .. code-block:: bash

        salt '*' redis.smembers foo_set
    (Rtlisttsmembers(R%RRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyR_�s
cC@s#t||||�}|j�dS(u�
    Return the current server UNIX time in seconds

    CLI Example:

    .. code-block:: bash

        salt '*' redis.time
    i(Rttime(RRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyR`�s
cC@s"t||||�}|j|�S(u�
    Get the length of a sorted set in Redis

    CLI Example:

    .. code-block:: bash

        salt '*' redis.zcard foo_sorted
    (Rtzcard(R%RRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyRa�s
cC@s(t||||�}|j|||�S(u�
    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
    (Rtzrange(R%RSRTRRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyRb�s
cC@s:t|||�}|j|�}tttd|���S(u�
    Get ip for sentinel master

    .. versionadded: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt '*' redis.sentinel_get_master_ip 'mymaster'
    umaster_hostumaster_port(umaster_hostumaster_port(Rt sentinel_get_master_addr_by_nametdictR^R(tmasterRRRRtret((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pytsentinel_get_master_ip�scC@s[t|||�}|j�}|jdd�|jdd�f}tttd|���S(u�
    Get host information about slave

    .. versionadded: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt '*' redis.get_master_ip
    umaster_hostuumaster_port(umaster_hostumaster_port(RRJR,RdR^R(RRRRtsrv_infoRf((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyt
get_master_ip�s$(@t__doc__t
__future__RRRtsalt.ext.six.movesRtsalt.extRRtsalt.utils.argsR>RRRtImportErrorRRR	RRRRRRRRRR$R&R(R*R+R-R.R2R4R5R7R9R:R;R=RCRDRERIRJR RLRORQRRRURWRYRZR[R_R`RaRbRgRi(((s9/usr/lib/python2.7/site-packages/salt/modules/redismod.pyt<module>sr


	
				

Zerion Mini Shell 1.0