File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/cache/__pycache__/consul.cpython-310.pyc
Back
o ;j� � @ s� d Z ddlZddlZddlZddlmZ zddlZdZW n e y' dZY nw e� e�Zda dadZdd iZd d� Zdd � Zdd� Zddd�Zdd� Zdd� Zdd� ZdS )a� Minion data cache plugin for Consul key/value data store. .. versionadded:: 2016.11.2 .. versionchanged:: 3005 Timestamp/cache updated support added. :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 consul.timestamp_suffix: .tstamp # Added in 3005.0 In order to bring the cache APIs into conformity, in 3005.0 timestamp information gets stored as a separate ``{key}.tstamp`` key/value. If your existing functionality depends on being able to store normal keys with the ``.tstamp`` suffix, override the ``consul.timestamp_suffix`` default config. 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 � N)�SaltCacheErrorTFz.tstamp�consul�list_�listc C s� t sdS t�dd�t�dd�t�dd�t�dd �t�d d�t�dd�t�d d�d�} zt�dt�atjdi | ��aW tS tyE Y dS w )z9 Confirm this python-consul package is installed )FzDPlease install python-consul package to use consul data cache driverzconsul.hostz 127.0.0.1zconsul.porti4! zconsul.tokenNz consul.scheme�httpzconsul.consistency�defaultz consul.dcz consul.verifyT)�host�port�token�schemeZconsistencyZdcZverifyzconsul.timestamp_suffix)FzZFailed to invoke consul.Consul, please make sure you have python-consul >= 0.2.0 installed� ) � HAS_CONSULZ__opts__�get�_tstamp_suffixr ZConsul�api�AttributeError�__virtualname__)Z consul_kwargsr r �E/opt/saltstack/salt/lib/python3.10/site-packages/salt/cache/consul.py�__virtual__T s"