%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/consul.pyc

�
���^c@@s�dZddlmZmZmZddlZyddlZeZWne	k
r]e
ZnXddlmZej
e�ZdadZidd6Zd�Zd	�Zd
�Zdd�Zd�Zd
�ZdS(u�
Minion data cache plugin for Consul key/value data store.

.. versionadded:: 2016.11.2

:depends: python-consul >= 0.2.0

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

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

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

.. code-block: bash

    pip install python-consul

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

.. code-block:: yaml

    consul.host: 127.0.0.1
    consul.port: 8500
    consul.token: None
    consul.scheme: http
    consul.consistency: default
    consul.dc: dc1
    consul.verify: True

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

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

.. code-block:: yaml

    cache: consul


.. _`Consul documentation`: https://www.consul.io/docs/index.html
.. _`python-consul documentation`: https://python-consul.readthedocs.io/en/latest/#consul

i(tabsolute_importtprint_functiontunicode_literalsN(tSaltCacheErroruconsululistulist_cC@s�tstdfSitjdd�d6tjdd�d6tjdd�d	6tjd
d�d6tjd
d�d6tjdd�d6tjdt�d6}ytj|�aWnt	k
r�tdfSXt
S(u9
    Confirm this python-consul package is installed
    uDPlease install python-consul package to use consul data cache driveruconsul.hostu	127.0.0.1uhostuconsul.porti4!uportuconsul.tokenutokenu
consul.schemeuhttpuschemeuconsul.consistencyudefaultuconsistencyu	consul.dcudcu
consul.verifyuverifyuZFailed to invoke consul.Consul, please make sure you have python-consul >= 0.2.0 installedN(t
HAS_CONSULtFalset__opts__tgettNonetTruetconsultConsultapitAttributeErrort__virtualname__(t
consul_kwargs((s5/usr/lib/python2.7/site-packages/salt/cache/consul.pyt__virtual__Es

cC@sndj||�}y*tdj|�}tjj||�Wn+tk
ri}tdj||���nXdS(u
    Store a key value.
    u{0}/{1}userialu,There was an error writing the key, {0}: {1}N(tformatt__context__tdumpsRtkvtputt	ExceptionR(tbanktkeytdatatc_keytc_datatexc((s5/usr/lib/python2.7/site-packages/salt/cache/consul.pytstore_scC@s�dj||�}yAtjj|�\}}|dkr=iStdj|d�SWn+tk
r�}tdj||���nXdS(u
    Fetch a key value.
    u{0}/{1}userialuValueu,There was an error reading the key, {0}: {1}N(	RRRRRRtloadsRR(RRRt_tvalueR((s5/usr/lib/python2.7/site-packages/salt/cache/consul.pytfetchoscC@sy|dkr|}ndj||�}y tjj|d|dk�SWn+tk
rt}tdj||���nXdS(uF
    Remove the key from the cache bank with all the key content.
    u{0}/{1}trecurseu-There was an error removing the key, {0}: {1}N(RRRRtdeleteRR(RRRR((s5/usr/lib/python2.7/site-packages/salt/cache/consul.pytflush�s	 cC@s�y,tjj|ddtdd�\}}Wn+tk
rY}tdj||���nX|dkrog}nJt�}x2|D]*}|j	|t
|�djd��qWt|�}|S(uX
    Return an iterable object containing all entries stored in the specified bank.
    u/tkeyst	separatoru-There was an error getting the key "{0}": {1}iN(
RRRR	RRRRtsettaddtlentrstriptlist(RRR%RtoutR((s5/usr/lib/python2.7/site-packages/salt/cache/consul.pytlist_�s,		
(cC@sz|dkrtSy.dj||�}tjj|�\}}Wn+tk
rk}tdj||���nX|dk	SdS(uB
    Checks if the specified bank contains the specified key.
    u{0}/{1}u,There was an error getting the key, {0}: {1}N(RR	RRRRRR(RRRRR R((s5/usr/lib/python2.7/site-packages/salt/cache/consul.pytcontains�s(t__doc__t
__future__RRRtloggingR
R	RtImportErrorRtsalt.exceptionsRt	getLoggert__name__tlogRRRt__func_alias__RRR!R$R-R.(((s5/usr/lib/python2.7/site-packages/salt/cache/consul.pyt<module>0s$



				

Zerion Mini Shell 1.0