%PDF- %PDF-
Direktori : /usr/lib/python2.7/site-packages/salt/cache/ |
Current File : //usr/lib/python2.7/site-packages/salt/cache/consul.pyo |
� ���^c @@ s� d Z d d l m Z m Z m Z d d l Z y d d l Z e Z Wn e k r] e Z n Xd d l m Z e j e � Z d a d Z i d d 6Z d � Z d � Z d � Z d d � Z d � Z d � Z d S( 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 ( t absolute_importt print_functiont unicode_literalsN( t SaltCacheErroru consulu listu list_c C@ s� t s t d f Si t j d d � d 6t j d d � d 6t j d d � d 6t j d d � d 6t j d d � d 6t j d d � d 6t j d t � d 6} y t j | � a Wn t k r� t d f SXt S( u9 Confirm this python-consul package is installed uD Please install python-consul package to use consul data cache driveru consul.hostu 127.0.0.1u hostu consul.porti4! u portu consul.tokenu tokenu consul.schemeu httpu schemeu consul.consistencyu defaultu consistencyu consul.dcu dcu consul.verifyu verifyuZ Failed to invoke consul.Consul, please make sure you have python-consul >= 0.2.0 installedN( t HAS_CONSULt Falset __opts__t gett Nonet Truet consult Consult apit AttributeErrort __virtualname__( t consul_kwargs( ( s5 /usr/lib/python2.7/site-packages/salt/cache/consul.pyt __virtual__E s c C@ sn d j | | � } y* t d j | � } t j j | | � Wn+ t k ri } t d j | | � � � n Xd S( u Store a key value. u {0}/{1}u serialu, There was an error writing the key, {0}: {1}N( t formatt __context__t dumpsR t kvt putt ExceptionR ( t bankt keyt datat c_keyt c_datat exc( ( s5 /usr/lib/python2.7/site-packages/salt/cache/consul.pyt store_ s c C@ s� d j | | � } yA t j j | � \ } } | d k r= i St d j | d � SWn+ t k r� } t d j | | � � � n Xd S( u Fetch a key value. u {0}/{1}u serialu Valueu, There was an error reading the key, {0}: {1}N( R R R R R R t loadsR R ( R R R t _t valueR ( ( s5 /usr/lib/python2.7/site-packages/salt/cache/consul.pyt fetcho s c C@ sy | d k r | } n d j | | � } y t j j | d | d k �SWn+ t k rt } t d j | | � � � n Xd S( uF Remove the key from the cache bank with all the key content. u {0}/{1}t recurseu- There was an error removing the key, {0}: {1}N( R R R R t deleteR R ( R R R R ( ( s5 /usr/lib/python2.7/site-packages/salt/cache/consul.pyt flush� s c C@ s� y, t j j | d d t d d �\ } } Wn+ t k rY } t d j | | � � � n X| d k ro g } nJ t � } x2 | D]* } | j | t | � d j d � � q Wt | � } | S( uX Return an iterable object containing all entries stored in the specified bank. u /t keyst separatoru- There was an error getting the key "{0}": {1}i N( R R R R R R R R t sett addt lent rstript list( R R R% R t outR ( ( s5 /usr/lib/python2.7/site-packages/salt/cache/consul.pyt list_� s , (c C@ sz | d k r t Sy. d j | | � } t j j | � \ } } Wn+ t k rk } t d j | | � � � n X| d k Sd S( uB Checks if the specified bank contains the specified key. u {0}/{1}u, There was an error getting the key, {0}: {1}N( R R R R R R R R ( R R R R R R ( ( s5 /usr/lib/python2.7/site-packages/salt/cache/consul.pyt contains� s ( t __doc__t __future__R R R t loggingR R R t ImportErrorR t salt.exceptionsR t getLoggert __name__t logR R R t __func_alias__R R R! R$ R- R. ( ( ( s5 /usr/lib/python2.7/site-packages/salt/cache/consul.pyt <module>0 s$