File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/__pycache__/sdb.cpython-310.pyc
o
�N�g$ � @ sR d Z ddlZddlZddlmZ ddd�Zddd�Zdd d
�Z dd
d�Z dS )zt
Basic functions for accessing the SDB interface
For configuration options, see the docs for specific sdb
modules.
� N)�SaltInvocationErrorFc
C s t | t�r
| �d�s|rtd��| S |du rtj�|�}td�}| �d|�}|dks2| |d d� s:|r8td��| S |� | ||� i �}|sT|� di �� | ||� i �}d |vrg|retd
�
| ||� ���| S d�
|d �}| |d d� }tjj|||d�} | | ||d
�S )z�
Get a value from a db, using a uri in the form of ``sdb://<profile>/<key>``. If
the uri provided is not valid, then it will be returned as-is, unless ``strict=True`` was passed.
�sdb://z SDB uri must start with "sdb://"N�/���� zHSDB uri must have a profile name as a first part of the uri before the /�pillar�driverz8SDB profile "{}" wasnt found in the minion configurationz{}.get��utils��profile)�
isinstance�str�
startswithr �salt�loaderr
�len�find�get�format�sdb)
�uri�optsr
�strict�sdlen�indxr �fun�query� loaded_db� r �B/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/sdb.py�sdb_get s: �
��r! c
C s� t | t�r
| �d�sdS |du rtj�|�}td�}| �d|�}|dks,| |d d� s.dS |�| ||� i �}|sH|�di ��| ||� i �}d|vrNdS d � |d �}| |d d� }tjj
|||d
�} | | |||d�S )z�
Set a value in a db, using a uri in the form of ``sdb://<profile>/<key>``.
If the uri provided does not start with ``sdb://`` or the value is not
successfully set, return ``False``.
r FNr r r r r z{}.setr r �r
r r r r r
r r r r r )
r �valuer r
r r r r r r r r r �sdb_set<