%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@sdZddlmZmZmZddlZddlZyddlZeZ	Wne
k
rieZ	nXddlm
Z
dZe	r�ejjej�neje�ZdadadZidd6Zd	�Zd
�Zd�Zd�Zdd
�Zd�Zd�Z d�Z!dS(u
Minion data cache plugin for Etcd key/value data store.

.. versionadded:: develop

It is up to the system administrator to set up and configure the Etcd
infrastructure. All is needed for this plugin is a working Etcd agent
with a read-write access to the key-value store.

The related documentation can be found in the `Etcd documentation`_.

To enable this cache plugin, the master will need the python client for
Etcd installed. This can be easily installed with pip:

.. code-block: bash

    pip install python-etcd

Optionally, depending on the Etcd agent configuration, the following values
could be set in the master config. These are the defaults:

.. code-block:: yaml

    etcd.host: 127.0.0.1
    etcd.port: 2379
    etcd.protocol: http
    etcd.allow_reconnect: True
    etcd.allow_redirect: False
    etcd.srv_domain: None
    etcd.read_timeout: 60
    etcd.username: None
    etcd.password: None
    etcd.cert: None
    etcd.ca_cert: None

Related docs could be found in the `python-etcd documentation`_.

To use the etcd as a minion data cache backend, set the master ``cache`` config
value to ``etcd``:

.. code-block:: yaml

    cache: etcd


.. _`Etcd documentation`: https://github.com/coreos/etcd
.. _`python-etcd documentation`: http://python-etcd.readthedocs.io/en/latest/

i(tabsolute_importtprint_functiontunicode_literalsN(tSaltCacheErroru/salt_cacheuetcdulistulscC@ststdfStS(u8
    Confirm that python-etcd package is installed.
    u@Please install python-etcd package to use etcd data cache driver(tHAS_ETCDtFalset__virtualname__(((s9/usr/lib/python2.7/site-packages/salt/cache/etcd_cache.pyt__virtual__Os
cC@s�tdk	rdSitjdd�d6tjdd�d6tjdd	�d
6tjdt�d6tjd
t�d6tjdd�d6tjdd�d6tjdd�d6tjdd�d6tjdd�d6tjdd�d6}tjdt�atdkr djtj	d��ant
jd |�tj
|�aytjt�Wn:tjk
r�t
jd!t�tjtdd"t�nXdS(#u%Setup client and init datastore.
    Nu	etcd.hostu	127.0.0.1uhostu	etcd.portiK	uportu
etcd.protocoluhttpuprotocoluetcd.allow_reconnectuallow_reconnectuetcd.allow_redirectuallow_redirectuetcd.srv_domainu
srv_domainuetcd.read_timeouti<uread_timeoutu
etcd.usernameuusernameu
etcd.passwordupasswordu	etcd.certucertuetcd.ca_certuca_certuetcd.path_prefixuu/{0}u/u'etcd: Setting up client with params: %ruetcd: Creating dir %rtdir(tclienttNonet__opts__tgettTrueRt_DEFAULT_PATH_PREFIXtpath_prefixtformattstriptlogtinfotetcdtClienttreadtEtcdKeyNotFoundtwrite(tetcd_kwargs((s9/usr/lib/python2.7/site-packages/salt/cache/etcd_cache.pyt_init_clientZs0cC@s~t�djt||�}y0tdj|�}tj|tj|��Wn+t	k
ry}t
dj||���nXdS(u
    Store a key value.
    u{0}/{1}/{2}userialu,There was an error writing the key, {0}: {1}N(RRRt__context__tdumpsR	Rtbase64t	b64encodet	ExceptionR(tbanktkeytdatatetcd_keytvaluetexc((s9/usr/lib/python2.7/site-packages/salt/cache/etcd_cache.pytstorezscC@s�t�djt||�}y0tj|�j}tdjtj	|��SWn?t
jk
rciStk
r�}t
dj||���nXdS(u
    Fetch a key value.
    u{0}/{1}/{2}userialu,There was an error reading the key, {0}: {1}N(RRRR	RR$RtloadsRt	b64decodeRRRR(R R!R#R$R%((s9/usr/lib/python2.7/site-packages/salt/cache/etcd_cache.pytfetch�scC@s�t�|dkr(djt|�}ndjt||�}ytj|�Wntjk
redSXytj|dt	�Wn+t
k
r�}tdj||���nXdS(uF
    Remove the key from the cache bank with all the key content.
    u{0}/{1}u{0}/{1}/{2}Nt	recursiveu-There was an error removing the key, {0}: {1}(RR
RRR	RRRtdeleteR
RR(R R!R#R%((s9/usr/lib/python2.7/site-packages/salt/cache/etcd_cache.pytflush�scC@s`|js#|jjdd�dgSg}x0tj|j�jD]}|jt|��q?W|S(uV
    Recursively walk dirs. Return flattened list of keys.
    r: etcd.EtcdResult
    u/i(RR!tsplitR	Rtchildrentextendt_walk(trtkeystc((s9/usr/lib/python2.7/site-packages/salt/cache/etcd_cache.pyR0�s	cC@sbt�djt|�}yttj|��SWn+tk
r]}tdj||���nXdS(u\
    Return an iterable object containing all entries stored in the specified
    bank.
    u{0}/{1}u-There was an error getting the key "{0}": {1}N(RRRR0R	RRR(R tpathR%((s9/usr/lib/python2.7/site-packages/salt/cache/etcd_cache.pytls�scC@s�t�djt||�}y tj|�}|jtkSWn?tjk
rStSt	k
r}}t
dj||���nXdS(uB
    Checks if the specified bank contains the specified key.
    u{0}/{1}/{2}u,There was an error getting the key, {0}: {1}N(RRRR	RRRRRRR(R R!R#R1R%((s9/usr/lib/python2.7/site-packages/salt/cache/etcd_cache.pytcontains�s("t__doc__t
__future__RRRtloggingRRR
RtImportErrorRtsalt.exceptionsRRt_logtsetLeveltINFOt	getLoggert__name__RR
R	RRt__func_alias__RRR&R)R,R0R5R6(((s9/usr/lib/python2.7/site-packages/salt/cache/etcd_cache.pyt<module>2s2



		 				

Zerion Mini Shell 1.0