File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/postgres.cpython-310.pyc
o
�N�g�` � @ s� d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl
Z
ddlZddl
ZddlZddlZddlZddlmZmZ ddlmZ ddlmZ zddlZdZW n eye dZY nw zddlmZ W n ey} dd lmZ Y nw e�e�Z d
Z!dZ"dZ#dZ$d
Z%dZ&e#e$e%e&fZ'dddddddddddddd�
Z(e)d�Z*ddd d!d"d#d$d%�Z+d&d'� Z,d(d)� Z-d�d*d+�Z. , - d�d.d/�Z/ d�d0d1�Z0 d�d2d3�Z1d�d4d5�Z2d6d7� Z3 d�d8d9�Z4 d�d:d;�Z5 d�d<d=�Z6 d�d>d?�Z7d�dAdB�Z8 d�dCdD�Z9 d�dEdF�Z: d�dGdH�Z; d�dIdJ�Z< d�dKdL�Z= d�dMdN�Z> d�dOdP�Z? d�dQdR�Z@ d�dSdT�ZA d�dUdV�ZB d�dWdX�ZCd�d[d\�ZDe!fd]d^�ZEd_d`� ZFdadb� ZGd�ddde�ZH Z f d�dgdh�ZI f d�didj�ZJ d�dkdl�ZK f d�dmdn�ZL d�dodp�ZM d�dqdr�ZN d�dsdt�ZO d�dudv�ZP d�dwdx�ZQ d�dydz�ZR d�d{d|�ZSd}d~� ZT d�dd��ZU d�d�d��ZV d�d�d��ZW d�d�d��ZX d�d�d��ZY d�d�d��ZZ d�d�d��Z[ d�d�d��Z\ d�d�d��Z] d�d�d��Z^ d�d�d��Z_ d�d�d��Z` d�d�d��Za d�d�d��Zb d�d�d��Zc d�d�d��Zd d�d�d��Ze d�d�d��Zfd�d�� Zg � d�d�d��Zhd�d�� Zid�d�� Zjd�d�� Zk � d�d�d��Zl � d�d�d��Zm � d�d�d��Zn � d�d�d��Zo , - d�d�d��Zpd�d�� ZqdS )�a�
Module to provide Postgres compatibility to salt.
:configuration: In order to connect to Postgres, certain configuration is
required in /etc/salt/minion on the relevant minions. Some sample configs
might look like::
postgres.host: 'localhost'
postgres.port: '5432'
postgres.user: 'postgres' -> db user
postgres.pass: ''
postgres.maintenance_db: 'postgres'
The default for the maintenance_db is 'postgres' and in most cases it can
be left at the default setting.
This data can also be passed into pillar. Options passed into opts will
overwrite options passed into pillar
To prevent Postgres commands from running arbitrarily long, a timeout (in seconds) can be set
.. code-block:: yaml
postgres.timeout: 60
.. versionadded:: 3006.0
:note: This module uses MD5 hashing which may not be compliant with certain
security audits.
:note: When installing postgres from the official postgres repos, on certain
linux distributions, either the psql or the initdb binary is *not*
automatically placed on the path. Add a configuration to the location
of the postgres bin's path to the relevant minion for this module::
postgres.bins_dir: '/usr/pgsql-9.5/bin/'
� N)�CommandExecutionError�SaltInvocationError)�saslprep��LooseVersionTF)�token_bytes)�urandom�md5zEXTENSION NOT INSTALLEDzEXTENSION INSTALLEDzEXTENSION TO UPGRADEzEXTENSION TO MOVEZINSERTZCREATEZTRUNCATEZCONNECTZTRIGGERZSELECTZUSAGEZ TEMPORARYZUPDATEZEXECUTEZ
REFERENCESZDELETEZGRANT)
�a�C�D�c�t�r�U�T�w�X�x�d�*)�schema�
tablespace�language�sequence�table�group�database�functionZarwdDxtr r ZrwUZUCZCTcr )r r r r r r r c C sD dg} t sdS | D ]}tjj�|�st|�sd|� d�f S q dS )z�
Only load this module if the psql bin exist.
initdb bin might also be used, but its presence will be detected on runtime.
�psqlFz was not foundT)�HAS_CSV�salt�utils�path�which�_find_pg_binary)r"