%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/mysql.pyc

�
���^c@@sdZddlmZmZmZddlmZddlZddlm	Z	ej
e�Zy(ddl
Z
ddlZ
ddlZ
Wniek
r�y>ddlZej�ddl
Z
ddlZ
ddlZ
Wq�ek
r�dZ
q�XnXd�Zde	fd��YZd	�ZdS(
u�
Retrieve Pillar data by doing a MySQL query

MariaDB provides Python support through the MySQL Python package.
Therefore, you may use this module with both MySQL or MariaDB.

This module is a concrete implementation of the sql_base ext_pillar for MySQL.

:maturity: new
:depends: python-mysqldb
:platform: all

Configuring the mysql ext_pillar
================================

Use the 'mysql' key under ext_pillar for configuration of queries.

MySQL configuration of the MySQL returner is being used (mysql.db, mysql.user,
mysql.pass, mysql.port, mysql.host) for database connection info.

Required python modules: MySQLdb

Complete example
================

.. code-block:: yaml

    mysql:
      user: 'salt'
      pass: 'super_secret_password'
      db: 'salt_db'
      port: 3306
      ssl:
        cert: /etc/mysql/client-cert.pem
        key: /etc/mysql/client-key.pem

    ext_pillar:
      - mysql:
          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@s"tt�tdkrdndfS(u:
    Confirm that a python mysql client is installed.
    u!No python mysql client installed.uN(tbooltMySQLdbtNone(((s5/usr/lib/python2.7/site-packages/salt/pillar/mysql.pyt__virtual__NstMySQLExtPillarcB@s>eZdZed��Zd�Zed��Zd�ZRS(uI
    This class receives and processes the database rows from MySQL.
    cC@sdS(NuMySQL((tcls((s5/usr/lib/python2.7/site-packages/salt/pillar/mysql.pyt_db_nameYscC@s�idd6dd6dd6dd6dd6id	6}i}tjd
i�}xL|D]D}||kr�tjd|�||||<qOn||||<qOW|S(u@
        Returns options used for the MySQL connection.
        u	localhostuhostusaltuuserupassudbi�uportusslumysqluUsing default for MySQL %s(t__opts__tgettlogtdebug(tselftdefaultst_optionst_optstattr((s5/usr/lib/python2.7/site-packages/salt/pillar/mysql.pyt_get_options]s


cc@s�|j�}tjd|dd|dd|dd|dd	|d
d|d�}|j�}z9y	|VWn)tjk
r�}tjd
|j�nXWd|j�XdS(u&
        Yield a MySQL cursor
        thostuhosttuseruusertpasswdupasstdbudbtportuporttsslussluError in ext_pillar MySQL: %sN(	RRtconnecttcursort
DatabaseErrorRt	exceptiontargstclose(RRtconnRterr((s5/usr/lib/python2.7/site-packages/salt/pillar/mysql.pyt_get_cursorqs


	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((s5/usr/lib/python2.7/site-packages/salt/pillar/mysql.pyR&�s(	t__name__t
__module__t__doc__tclassmethodRRRR$R&(((s5/usr/lib/python2.7/site-packages/salt/pillar/mysql.pyR	Us
	cO@st�j||||�S(uC
    Execute queries against MySQL, merge and return as a dict
    (R	tfetch(t	minion_idtpillarR R'((s5/usr/lib/python2.7/site-packages/salt/pillar/mysql.pyt
ext_pillar�s(R*t
__future__RRRt
contextlibRtloggingtsalt.pillar.sql_baseRt	getLoggerR(RRtMySQLdb.cursorstMySQLdb.converterstImportErrortpymysqltinstall_as_MySQLdbRRR	R/(((s5/usr/lib/python2.7/site-packages/salt/pillar/mysql.pyt<module>/s*


	7

Zerion Mini Shell 1.0