File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/cache/__pycache__/etcd_cache.cpython-310.pyc
o
�N�g= � @ s� d Z ddlZddlZddlZddlZddlmZ zddlZdZ W n e
y+ dZ Y nw dZe r7ej�
ej� e�e�ZdadadadZd d
iZdd� Zd
d� Zdd� Zdd� Zddd�Zdd� Zdd � Zdd� Zdd� ZdS )a
Minion data cache plugin for Etcd key/value data store.
.. versionadded:: 2018.3.0
.. versionchanged:: 3005
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
.. note::
While etcd API v3 has been implemented in other places within salt,
etcd_cache does not support it at this time due to fundamental differences in
how the versions are designed and v3 not being compatible with the cache API.
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
In Phosphorus, ls/list was changed to always return the final name in the path.
This should only make a difference if you were directly using ``ls`` on paths
that were more or less nested than, for example: ``1/2/3/4``.
.. _`Etcd documentation`: https://github.com/coreos/etcd
.. _`python-etcd documentation`: http://python-etcd.readthedocs.io/en/latest/
� N)�SaltCacheErrorTFz/salt_cachez.tstamp�etcd�ls�listc C s t sdS tS )z8
Confirm that python-etcd package is installed.
)Fz@Please install python-etcd package to use etcd data cache driver)�HAS_ETCD�__virtualname__� r r �I/opt/saltstack/salt/lib/python3.10/site-packages/salt/cache/etcd_cache.py�__virtual__^ s r
c C s t durdS t�dd�t�dd�t�dd�t�dd �t�d
d�t�dd�t�d
d�t�dd�t�dd�t�dd�t�dd�d�} t�dt�at�dt�atdkrXd�t�d��at� d| � t
jdi | ��a zt �t� W dS t
j
y� t� dt� t jtdd d� Y dS w )z Setup client and init datastore.Nz etcd.hostz 127.0.0.1z etcd.portiK z
etcd.protocol�httpzetcd.allow_reconnectTzetcd.allow_redirectFzetcd.srv_domainzetcd.read_timeout�<