%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@s
dZddlmZmZmZddlZddlZddlZddlZyddl	Z	e
ZWnek
r�e
ZnXddlZddlZddlZddlZddlZddlmZddlmZeje�Zdefd��YZdefd	��YZd
efd��YZdefd
��YZ defd��YZ!defd��YZ"d�Z#edkrej$j%d�Z&e e&�Z'e'j(dddg�e'j(dg�e'j(dg�e'j(dg�e)dj*e'j+���ndS(u 
In-memory caching used by Salt
i(tabsolute_importtprint_functiontunicode_literalsN(trange(tzmqtCacheFactorycB@seZdZed��ZRS(u2
    Cache which can use a number of backends
    cO@s`tjd|�|dkr,t|||�S|dkrOt||d||�Stjd�dS(NuFactory backend: %sumemoryudiskuminion_cache_pathu-CacheFactory received unrecognized cache type(tlogtinfot	CacheDictt	CacheDiskterror(tclstbackendtttltargstkwargs((s4/usr/lib/python2.7/site-packages/salt/utils/cache.pytfactory#s(t__name__t
__module__t__doc__tclassmethodR(((s4/usr/lib/python2.7/site-packages/salt/utils/cache.pyRsRcB@s;eZdZd�Zd�Zd�Zd�Zd�ZRS(uA
    Subclass of dict that will lazily delete items past ttl
    cO@s)tj|||�||_i|_dS(N(tdictt__init__t_ttlt_key_cache_time(tselfR
RR((s4/usr/lib/python2.7/site-packages/salt/utils/cache.pyR2s	cC@sT||jkrdStj�|j||jkrP|j|=tj||�ndS(uK
        Enforce the TTL to a specific key, delete if its past TTL
        N(RttimeRRt__delitem__(Rtkey((s4/usr/lib/python2.7/site-packages/salt/utils/cache.pyt_enforce_ttl_key7s
 
cC@s|j|�tj||�S(u?
        Check if the key is ttld out, then do the get
        (RRt__getitem__(RR((s4/usr/lib/python2.7/site-packages/salt/utils/cache.pyRAs
cC@s*tj�|j|<tj|||�dS(u8
        Make sure to update the key cache time
        N(RRRt__setitem__(RRtval((s4/usr/lib/python2.7/site-packages/salt/utils/cache.pyRHscC@s|j|�tj||�S(N(RRt__contains__(RR((s4/usr/lib/python2.7/site-packages/salt/utils/cache.pyR!Os
(RRRRRRRR!(((s4/usr/lib/python2.7/site-packages/salt/utils/cache.pyR.s		
		R	cB@sVeZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
RS(	u�
    Class that represents itself as a dictionary to a consumer
    but uses a disk-based backend. Serialization and de-serialization
    is done with msgpack
    cO@s<tt|�j|||�||_i|_|j�dS(N(tsuperR	Rt_patht_dictt_read(RR
tpathRR((s4/usr/lib/python2.7/site-packages/salt/utils/cache.pyRZs		cC@sT||jkrdStj�|j||jkrP|j|=|jj|�ndS(uK
        Enforce the TTL to a specific key, delete if its past TTL
        N(RRRR$R(RR((s4/usr/lib/python2.7/site-packages/salt/utils/cache.pyR`s
 
cC@s|j|�|jj|�S(N(RR$R!(RR((s4/usr/lib/python2.7/site-packages/salt/utils/cache.pyR!js
cC@s|j|�|jj|�S(u?
        Check if the key is ttld out, then do the get
        (RR$R(RR((s4/usr/lib/python2.7/site-packages/salt/utils/cache.pyRns
cC@s4tj�|j|<|jj||�|j�dS(u8
        Make sure to update the key cache time
        N(RRR$Rt_write(RRR ((s4/usr/lib/python2.7/site-packages/salt/utils/cache.pyRuscC@s(|j|=|jj|�|j�dS(u8
        Make sure to remove the key cache time
        N(RR$RR'(RR((s4/usr/lib/python2.7/site-packages/salt/utils/cache.pyR~s
c
C@s�tstjj|j�r!dStjjj|jd��+}tjj	j
tj|dt
��}WdQXd|kr�|d|_|d|_n?||_tjj|j�}x|jD]}||j|<q�Wtjtj�r�tjd|�ndS(u#
        Read in from disk
        NurbtencodinguCacheDisk_cachetimeuCacheDisk_datauDisk cache retrieved: %s(tHAS_MSGPACKtosR&texistsR#tsalttutilstfilestfopentdatatdecodetmsgpacktloadt__salt_system_encoding__R$RtgetmtimeRtisEnabledFortloggingtDEBUGtdebug(Rtfp_tcachet	timestampR((s4/usr/lib/python2.7/site-packages/salt/utils/cache.pyR%�s*
	c	C@sbts
dStjjj|jd��7}i|jd6|jd6}tj	||dt
�WdQXdS(u#
        Write out to disk
        Nuwb+uCacheDisk_datauCacheDisk_cachetimetuse_bin_type(R)R,R-R.R/R#R$RR2tdumptTrue(RR:R;((s4/usr/lib/python2.7/site-packages/salt/utils/cache.pyR'�s

(RRRRRR!RRRR%R'(((s4/usr/lib/python2.7/site-packages/salt/utils/cache.pyR	Ts		
							tCacheClicB@s)eZdZd�Zd�Zd�ZRS(u�
    Connection client for the ConCache. Should be used by all
    components that need the list of currently connected minions
    cC@s�||_tjj|jjdd��|_tjj|jdd�|_	tjj|jdd�|_
tj�}|j
tj�|_|jjtjd�|jjd|j	�|j
tj�|_|jjtjd�|jjd|j
�d	S(
u<
        Sets up the zmq-connection to the ConCache
        userialuusock_diru
con_cache.ipcucon_upd.ipciduipc://iN(toptsR,tpayloadtSerialtgettserialR*R&tjoint
cache_socktcache_upd_sockRtContexttsockettREQtcreq_outt
setsockopttLINGERtconnecttPUBtcupd_out(RRAtcontext((s4/usr/lib/python2.7/site-packages/salt/utils/cache.pyR�s	$	cC@s |jj|jj|��dS(u=
        published the given minions to the ConCache
        N(RQtsendREtdumps(Rtminions((s4/usr/lib/python2.7/site-packages/salt/utils/cache.pyt	put_cache�scC@sA|jjd�}|jj|�|jj|jj��}|S(uP
        queries the ConCache for a list of currently connected minions
        uminions(RERTRLRStloadstrecv(Rtmsgtmin_list((s4/usr/lib/python2.7/site-packages/salt/utils/cache.pyt
get_cached�s(RRRRRVR[(((s4/usr/lib/python2.7/site-packages/salt/utils/cache.pyR@�s		t
CacheRegexcB@sAeZdZdddddd�Zd�Zd�Zd�ZRS(	u�
    Create a regular expression object cache for the most frequently
    used patterns to minimize compilation of the same patterns over
    and over again
    ui�g�������?icC@s�||_||_||_t|||�|_|j|krvt|d�d|_|j|krv||_qvn||_i|_tj�|_dS(Nii(	tprependtappendtsizetintt
clear_sizetmax_ageR;RR<(RR]R^R_t
keep_fractionRb((s4/usr/lib/python2.7/site-packages/salt/utils/cache.pyR�s					cC@s|jj�dS(u!
        Clear the cache
        N(R;tclear(R((s4/usr/lib/python2.7/site-packages/salt/utils/cache.pyRd�scC@s�|jtj�|jkr8|j�tj�|_nKt|jj��}|j�x)t|j	�D]}|j||d=qgWdS(ub
        Sweep the cache and remove the outdated or least frequently
        used entries
        iN(
RbRR<RdtlistR;tvaluestsortRRa(Rtpaternstidx((s4/usr/lib/python2.7/site-packages/salt/utils/cache.pytsweep�s

cC@s�y*|j|dcd7<|j|dSWntk
r=nXt|j�|jkrc|j�ntjdj|j||j	��}d||t
j
�g|j|<|S(u�
        Get a compiled regular expression object based on pattern and
        cache it when it is not in the cache already
        iiu	{0}{1}{2}(R;tKeyErrortlenR_RjtretcompiletformatR]R^R(Rtpatterntregex((s4/usr/lib/python2.7/site-packages/salt/utils/cache.pyRD�s

(RRRRRdRjRD(((s4/usr/lib/python2.7/site-packages/salt/utils/cache.pyR\�s	
		tContextCachecB@s#eZd�Zd�Zd�ZRS(cC@sM||_tjj|dddj|��|_tjj|j�|_	dS(u(
        Create a context cache
        ucachedirucontextu{0}.pN(
RAR*R&RFRot
cache_pathR,RBRCRE(RRAtname((s4/usr/lib/python2.7/site-packages/salt/utils/cache.pyRs	(cC@s{tjjtjj|j��s@tjtjj|j��ntjjj	|jd��}|j
j||�WdQXdS(u1
        Cache the given context to disk
        uw+bN(R*R&tisdirtdirnameRstmkdirR,R-R.R/RER>(RRRR;((s4/usr/lib/python2.7/site-packages/salt/utils/cache.pyt
cache_contexts!cC@sGtjjj|jd��&}tjjj|jj|��SWdQXdS(u4
        Retrieve a context cache from disk
        urbN(	R,R-R.R/RsR0R1RER3(RR;((s4/usr/lib/python2.7/site-packages/salt/utils/cache.pytget_cache_context"s(RRRRxRy(((s4/usr/lib/python2.7/site-packages/salt/utils/cache.pyRrs			c@s�fd�}|S(u�
    A decorator to be used module functions which need to cache their
    context.

    To evaluate a __context__ and re-hydrate it if a given key
    is empty or contains no items, pass a list of keys to evaulate.
    c@s��jd}�jd}�jd}t||�}|rqtjj|j�rqtjjj	||j
��n
|j|��||�S(Nu__context__u__opts__u__name__(t__globals__RrR*R&tisfileRsR,R-t
dictupdatetupdateRyRx(RRtfunc_contextt	func_optst	func_namet
context_cache(tfunc(s4/usr/lib/python2.7/site-packages/salt/utils/cache.pytcontext_cache_wrap2s



((R�R�((R�s4/usr/lib/python2.7/site-packages/salt/utils/cache.pyR�*su__main__u/etc/salt/masterutest1utest10utest34utest12utest18utest21uminions: {0}(,Rt
__future__RRRR*RmRR7R2R?R)tImportErrortFalsetsalt.configR,tsalt.payloadtsalt.utils.datatsalt.utils.dictupdatetsalt.utils.filestsalt.ext.six.movesRtsalt.utils.zeromqRt	getLoggerRRtobjectRRRR	R@R\RrR�tconfigt
master_configRAtccliRVtprintRoR[(((s4/usr/lib/python2.7/site-packages/salt/utils/cache.pyt<module>sB


&V,:	

Zerion Mini Shell 1.0