%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/modules/mysql.pyo

�
���^c.@@sdZddlmZmZmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddl
ZddlZddlmZddlmZmZyNddlZddlZddlZddlmZmZddlmZWn�ek
r�ydddlZej�ddlZddlZddlZddlmZmZddlmZWq�ek
r�dZq�XnXeje �Z!iZ"dd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5g.Z#d6d7d8gZ$e$d9d:gZ%d	d
ddd
dddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d5g+Z&d;�Z'd<�Z(d=�Z)d>�Z*d?�Z+d@�Z,dA�Z-e.dB�Z/ddC�Z0dD�Z1dE�Z2dF�Z3dG�Z4dH�Z5dI�Z6dJ�Z7dddK�Z8dL�Z9dM�Z:dN�Z;dddO�Z<dP�Z=dQ�Z>dRdde.e.ddS�Z?dRdT�Z@dRdde.e.ddU�ZAdRdde.dddV�ZBdRdW�ZCdX�ZDddY�ZEddZ�ZFdd[�ZGd\�ZHd]�ZIdRe.eJe.d^�ZKdRd_�ZLdRe.eJd`�ZMdRe.eJe.da�ZNdRe.eJdb�ZOdc�ZPdd�ZQde�ZRdf�ZSdg�ZTdh�ZUddi�ZVdS(ju
Module to provide MySQL compatibility to salt.

:depends:   - MySQLdb Python module

.. note::

    On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb
    need to be installed.

:configuration: In order to connect to MySQL, certain configuration is required
    in /etc/salt/minion on the relevant minions. Some sample configs might look
    like::

        mysql.host: 'localhost'
        mysql.port: 3306
        mysql.user: 'root'
        mysql.pass: ''
        mysql.db: 'mysql'
        mysql.unix_socket: '/tmp/mysql.sock'
        mysql.charset: 'utf8'

    You can also use a defaults file::

        mysql.default_file: '/etc/mysql/debian.cnf'

.. versionchanged:: 2014.1.0
    'charset' connection argument added. This is a MySQL charset, not a python one.
.. versionchanged:: 0.16.2
    Connection arguments from the minion config file can be overridden on the
    CLI by using the arguments defined :mod:`here <salt.states.mysql_user>`.
    Additionally, it is now possible to setup a user with no password.
i(tabsolute_importtprint_functiontunicode_literalsN(tsix(trangetzip(t
FIELD_TYPEtFLAG(tOperationalErroruALL PRIVILEGESuALTERu
ALTER ROUTINEuBACKUP_ADMINuBINLOG_ADMINuCONNECTION_ADMINuCREATEuCREATE ROLEuCREATE ROUTINEuCREATE TABLESPACEuCREATE TEMPORARY TABLESuCREATE USERuCREATE VIEWuDELETEuDROPu	DROP ROLEuENCRYPTION_KEY_ADMINuEVENTuEXECUTEuFILEuGRANT OPTIONuGROUP_REPLICATION_ADMINuINDEXuINSERTuLOCK TABLESuPERSIST_RO_VARIABLES_ADMINuPROCESSu
REFERENCESuRELOADuREPLICATION CLIENTuREPLICATION SLAVEuREPLICATION_SLAVE_ADMINuRESOURCE_GROUP_ADMINuRESOURCE_GROUP_USERu
ROLE_ADMINuSELECTuSET_USER_IDuSHOW DATABASESu	SHOW VIEWuSHUTDOWNuSUPERuSYSTEM_VARIABLES_ADMINuTRIGGERuUPDATEuUSAGEuXA_RECOVER_ADMINuCIPHERuISSUERuSUBJECTuSSLuX509cC@s"tt�tdkrdndfS(u:
    Confirm that a python mysql client is installed.
    u!No python mysql client installed.uN(tbooltMySQLdbtNone(((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pyt__virtual__sc	K@s�t|�}|dkriS|jtjj�}t|�}t|�}dj||�}t||�|j	�}t
j|�|S(NuCHECK TABLE {0}.{1}(t_connectRtcursorR
tcursorst
DictCursortquote_identifiertformatt_executetfetchalltlogtdebug(	tnamettabletconnection_argstdbctcurts_namets_tabletqrytresults((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pyt
__check_tables

c	K@s�t|�}|dkriS|jtjj�}t|�}t|�}dj||�}t||�|j	�}t
j|�|S(NuREPAIR TABLE {0}.{1}(R
RRR
RRRRRRRR(	RRRRRRRRR((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pyt__repair_tables

c	K@s�t|�}|dkriS|jtjj�}t|�}t|�}dj||�}t||�|j	�}t
j|�|S(NuOPTIMIZE TABLE {0}.{1}(R
RRR
RRRRRRRR(	RRRRRRRRR((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pyt__optimize_table&s

cK@szt|�}|dkrdS|j�}d}idd6dd6dd6}t|||�t|j�dkrrdSd	SdS(
NuPasswordu�SELECT column_name from information_schema.COLUMNS WHERE table_schema=%(schema)s and table_name=%(table)s and column_name=%(column)sumysqluschemauuserutableucolumniuauthentication_string(R
RRRtinttrowcount(RRRRtargs((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pyt__password_column5s
c@s�t��dt��fd�}d�kr6t}nt}|dd|�|dd|�|dd|�|d	d
|�|dd|�|d
d|�|dd|�|dd|�|dd|�t�d<|dd�dt_�jdt�dkr!tjd��j	d�nytj
��}Wn=tk
rs}dj|j
�}|td<tj|�dSX|jt�|S(u.
    wrap authentication credentials here
    c@s�|dkr|}n|�kr2�|�|<n|r�d}|j|�ryy|t|�}Wqytk
rudSXntddj|�d�}|dk	r�|�|<q�ndS(u�
        Add key to connargs, only if name exists in our kwargs or,
        if get_opts is true, as mysql.<name> in __opts__ or __pillar__

        If get_opts is true, evaluate in said order - kwargs, opts
        then pillar. To avoid collision with other functions,
        kwargs-based connection arguments are prefixed with 'connection_'
        (i.e. 'connection_host', 'connection_user', etc.).
        uconnection_Nu
config.optionu	mysql.{0}(Rt
startswithtlent
IndexErrort__salt__R(Rtkeytget_optstprefixtval(tconnargstkwargs(s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pyt_connargOs
	
uconnection_default_fileuconnection_hostuhostuconnection_useruuseruconnection_passupasswduconnection_portuportu
connection_dbudbuconnection_convuconvuconnection_unix_socketuunix_socketuread_default_fileuconnection_default_groupuread_default_groupuuse_unicodeuconnection_charsetucharsetupyformatu<MySQL password of None found. Attempting passwordless login.uMySQL Error {0}: {1}umysql.errorN(tdictRtTruetFalseR
t
paramstyletgetRtwarningtpoptconnectRRR%t__context__terrort
autocommit(R0R1R,Rtexcterr((R/R0s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pyR
Is:		

	



c
C@s�tjd|�t}t|t�r�t}|jdd�jdd�}|jdi�}|jdd�}|jdd�}n|}d	}tj|�}d
|_	t|_
d	|_|jd7_t
|�}g}g}	d}
d	}d
}x||
D]}
|
dkr*|d
kr*|
d7}
q�n|
dkrX|d
krXd}|
d7}
q�n\|
dkr�|dkr�d}|
d7}
q�n.|
dkr�|dkr�d}|
d7}
q�n|d
kr:||
ddks�||
ddkr*|	r|	j|
�|jdj|	��g}	q7|j|
�q�|	j|
�n�|dkr�||
7}y!||
ddkrpd}nWq�tk
r�Pq�Xno|dkr�||
7}nV|dkr�|r�Pq�||
7}||
ddkr�d}q�n|dkr�|
}Pn|
d7}
q�WyD|s0|jd�}|jd�}ntjd||||�Wntk
rcd	}nXtd|d|d|d|�S(u�

    This should correspond fairly closely to the YAML rendering of a
    mysql_grants state which comes out as follows:

     OrderedDict([
        ('whatever_identifier',
         OrderedDict([
            ('mysql_grants.present',
             [
              OrderedDict([('database', 'testdb.*')]),
              OrderedDict([('user', 'testuser')]),
              OrderedDict([('grant', 'ALTER, SELECT, LOCK TABLES')]),
              OrderedDict([('host', 'localhost')])
             ]
            )
         ])
        )
     ])

    :param grant: An un-parsed MySQL GRANT statement str, like
        "GRANT SELECT, ALTER, LOCK TABLES ON `mydb`.* TO 'testuser'@'localhost'"
        or a dictionary with 'qry' and 'args' keys for 'user' and 'host'.
    :return:
        A Python dict with the following keys/values:
            - user: MySQL User
            - host: MySQL host
            - grant: [grant1, grant2] (ala SELECT, USAGE, etc)
            - database: MySQL DB
    u_grant_to_tokens entry '%s'uqryu	undefinedu%%u%uargsuhostuuseruu'`u"iugrantsu,uONudbuTOutablesu@upre-hostu u.u'u%grant to token '%s'::'%s'::'%s'::'%s'tuserthosttgranttdatabase(RRR4t
isinstanceR2R3R6treplacetshlextquotestwhitespace_splitt
commenterst	wordcharstlisttappendtjoinR)tstriptUnboundLocalError(RAt	dict_modet	grant_sqltsql_argsR@R?tlextexploded_granttgrant_tokenstmultiword_statementtposition_trackerRBtphrasettoken((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pyt_grant_to_tokens�s�			




	






cC@s^|r6d|jdd�jdd�jdd�dSd|jdd�jdd�dSdS(u�
    Return an identifier name (column, table, database, etc) escaped for MySQL

    This means surrounded by "`" character and escaping this character inside.
    It also means doubling the '%' character for MySQLdb internal usage.

    :param identifier: the table, column or database identifier

    :param for_grants: is False by default, when using database names on grant
     queries you should set it to True to also escape "_" and "%" characters as
     requested by MySQL. Note that theses characters should only be escaped when
     requesting grants on the database level (`my\_\%db`.*) but not for table
     level grants (`my_%db`.`foo`)

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.quote_identifier 'foo`bar'
    u`u``u_u\_u%u%%N(RD(t
identifiert
for_grants((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pyR2s0cC@st|dks|ikrG|jdd�}tjd|�|j|�Stjd|t|��|j||�SdS(u
    Internal wrapper around MySQLdb cursor.execute() function

    MySQLDb does not apply the same filters when arguments are used with the
    query. For example '%' characters on the query must be encoded as '%%' and
    will be restored as '%' when arguments are applied. But when there're no
    arguments the '%%' is not managed. We cannot apply Identifier quoting in a
    predictable way if the query are not always applying the same filters. So
    this wrapper ensure this escape is not made if no arguments are used.
    u%%u%uDoing query: %suDoing query: %s args: %s N(RRDRRtexecutetrepr(RRR%((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pyRNs
cK@s�tjj}t|�}tt|tgt|���}itd6}|j	tj
j��r�tj
tfg|tj<tj
tfg|tj<tj
tfg|tj<tj
tfg|tj<n|ji|d6|d6�t|�}|dkr�iS|j�}tj�}	tjd||�yt||�}
Wn=tk
rz}dj|j�}|td<tj|�t SX|j!�}
tj�|	}|dkr�tt"|dd	��d
}ntt"|d��d}i}i|d
6tt"|d��d6|d<dddg}t }x3|D]+}|j�j#�j$|�r%t}Pq%q%W|r�|
|d<d}x"|j%D]}||df7}qtW||d<|
|d<|S|
|d<|SdS(u
    Run an arbitrary SQL query and return the results or
    the number of affected rows.

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.query mydb "UPDATE mytable set myfield=1 limit 1"

    Return data:

    .. code-block:: python

        {'query time': {'human': '39.0ms', 'raw': '0.03899'}, 'rows affected': 1L}

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.query mydb "SELECT id,name,cash from users limit 3"

    Return data:

    .. code-block:: python

        {'columns': ('id', 'name', 'cash'),
            'query time': {'human': '1.0ms', 'raw': '0.001'},
            'results': ((1L, 'User 1', Decimal('110.000000')),
                        (2L, 'User 2', Decimal('215.636756')),
                        (3L, 'User 3', Decimal('0.040000'))),
            'rows returned': 3L}

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.query mydb 'INSERT into users values (null,"user 4", 5)'

    Return data:

    .. code-block:: python

        {'query time': {'human': '25.6ms', 'raw': '0.02563'}, 'rows affected': 1L}

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.query mydb 'DELETE from users where id = 4 limit 1'

    Return data:

    .. code-block:: python

        {'query time': {'human': '39.0ms', 'raw': '0.03899'}, 'rows affected': 1L}

    Jinja Example: Run a query on ``mydb`` and use row 0, column 0's data.

    .. code-block:: jinja

        {{ salt['mysql.query']('mydb', 'SELECT info from mytable limit 1')['results'][0][0] }}
    uMYSQLDBu
connection_dbuconnection_convuUsing db: %s to run query %suMySQL Error {0}: {1}umysql.errorg�������?i�iumsiusuhumaniurawu
query timeuSELECTuSHOWuDESCu
rows returnediucolumnsuresultsu
rows affectedN((&R
t
converterstconversionstiterR2RtstrR(R3R6t__package__tupperRtBINARYRtBLOBtSTRINGt
VAR_STRINGtVARCHARtupdateR
RRttimeRRRRRR%R:R;R4RtroundRMR'tdescription(RBtqueryRt	orig_convt	conv_itertconvtconv_mysqldbRRtstarttaffectedR=R>Rtelapsedt	elapsed_htrettselect_keywordstselect_querytkeywordtcolumnstcolumn((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pyRmbs\F"


 '




c	@s}t�fd�dD��r/td���ntjj��r�tjjj�d��"}tjj	j
|j��}Wd	QXntj
d
��tSd}idd
6gd6gd6dd6idd6d6}x<|j�D].}tjd|�r�q�ntjd|�s||}q�||}t|||�}d}|tkrFtSd|krw|ddct|dd�7<nd
|kr�|d
c|d
7<nd|kr�|dj|d�nd|kr�|dj|d�nd|kr�|dc|d7<q�q�Wtjtt|dd�d��d|dd<tt|dd�d�|dd<d�tj|�D�}|S(ur
    Run an arbitrary SQL query from the specified file and return the
    the number of affected rows.

    .. versionadded:: 2017.7.0

    database

        database to run script inside

    file_name

        File name of the script.  This can be on the minion, or a file that is reachable by the fileserver

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.file_query mydb file_name=/tmp/sqlfile.sql
        salt '*' mysql.file_query mydb file_name=salt://sqlfile.sql

    Return data:

    .. code-block:: python

        {'query time': {'human': '39.0ms', 'raw': '0.03899'}, 'rows affected': 1L}

    c3@s|]}�j|�VqdS(N(R'(t.0tproto(t	file_name(s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pys	<genexpr>susalt://uhttp://uhttps://uswift://us3://u
cp.cache_fileurNuFile "%s" does not existuiu
rows returneducolumnsuresultsu
rows affectedurawu
query timeu--u[^-;]+;iusuhumanicS@s%i|]\}}|r||�qS(((R|tktv((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pys
<dictcomp>+s	(usalt://uhttp://uhttps://uswift://us3://(tanyR*tostpathtexiststsalttutilstfilestfopentstringutilst
to_unicodetreadRR;R4t
splitlinestretmatchtsearchRmtfloatRKRt	text_typeRkt	iteritems(	RBR~Rtifiletcontentstquery_stringRvtlinetquery_result((R~s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pyt
file_query�sB$0

%2%c	K@s�t|�}|dkriS|j�}d}yt||�Wn=tk
r~}dj|j�}|td<tj	|�iSXi}x5t
|j�D]$}|j�}|d||d<q�W|S(u�
    Return the status of a MySQL server using the output from the ``SHOW
    STATUS`` query.

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.status
    uSHOW STATUSuMySQL Error {0}: {1}umysql.erroriiN(
R
RRRRRR%R:RR;RR$tfetchone(	RRRRR=R>Rvt_trow((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pytstatus0s"

cK@s�t|�}|dkrdS|j�}d}yt||�Wn@tjk
r�}dj|j�}|td<t	j
|�dSXy!tjj
j|j�d�SWntk
r�dSXdS(u�
    Return the version of a MySQL server using the output from the ``SELECT
    VERSION()`` query.

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.version
    uuSELECT VERSION()uMySQL Error {0}: {1}umysql.erroriN(R
RRRR
RRR%R:RR;R�R�tdatatdecodeR�R)(RRRRR=R>((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pytversionOs 

!
cK@s�t|�}|dkrdS|jtjj�}d}yt||�Wn@tjk
r�}dj|j	�}|t
d<tj|�dSX|j
�}|jdkr�dS|ddkr�|d	Sd
SdS(u�
    Return the number of seconds that a slave SQL server is lagging behind the
    master, if the host is not a slave it will return -1.  If the server is
    configured to be a slave for replication but slave IO is not running then
    -2 will be returned. If there was an error connecting to the database or
    checking the slave status, -3 will be returned.

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.slave_lag
    i����ushow slave statusuMySQL Error {0}: {1}umysql.errorii����uSlave_IO_RunninguYesuSeconds_Behind_Masteri����N(R
RRR
RRRRRR%R:RR;R�R$(RRRRR=R>R((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pyt	slave_lagms$

cK@s
t|�}|dkrdS|jtjj�}|jd�|j�}i|dd6}yCt|�}|dkrzdS|j�}|jd�|j�Wntj	k
r�nX|jd�|jd�|jd�|jd�|j�}|dkrd	Sd
SdS(u�
    Frees a slave from its master.  This is a WIP, do not use.

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.free_slave
    uushow slave statusuMaster_Hostuhostu
flush logsu
stop slaveureset masteruchange master to MASTER_HOST=upromotedufailedN(
R
RRR
RRR\R�tcloseR(Rtslave_dbt	slave_curtslave_statustmastert	master_dbt
master_curR((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pyt
free_slave�s0






c	K@s�t|�}|dkrgS|j�}d}yt||�Wn@tjk
r�}dj|j�}|td<t	j
|�gSXg}|j�}x|D]}|j|d�q�Wt	j
|�|S(u�
    Return a list of databases of a MySQL server using the output
    from the ``SHOW DATABASES`` query.

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.db_list
    uSHOW DATABASESuMySQL Error {0}: {1}umysql.erroriN(R
RRRR
RRR%R:RR;RRKR(	RRRRR=R>RvRtdbs((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pytdb_list�s$



c	K@s�t|�}|dkrgS|j�}t||�}dj|jdd�jdd�|pj|jd�|p||jd��}i}t|||�dS(	u�
    Modify database using ``ALTER DATABASE %(dbname)s CHARACTER SET %(charset)s
    COLLATE %(collation)s;`` query.

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.alter_db testdb charset='latin1'
    u3ALTER DATABASE `{0}` CHARACTER SET {1} COLLATE {2};u%u\%u_u\_u
character_setucollateN(R
RRtdb_getRRDR6R(	Rt
character_settcollateRRRtexistingRR%((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pytalter_db�scK@s�t|�}|dkrgS|j�}d}i|d6}t|||�|jr�|j�}i|ddd6|ddd6SiS(u*
    Return a list of databases of a MySQL server using the output
    from the ``SELECT DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME FROM
    INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME='dbname';`` query.

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.db_get test
    uxSELECT DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME=%(dbname)s;udbnameiu
character_setiucollateN(R
RRRR$R(RRRRRR%trows((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pyR��s
	cK@s�t||�s#tjd|�tSt|�}|dkr?gS|j�}t|�}dj|�}yt	||�Wn@t
jk
r�}dj|j�}|t
d<tj|�gSXg}|j�}	x|	D]}
|j|
d�q�Wtj|�|S(u�
    Shows the tables in the given MySQL database (if exists)

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.db_tables 'database'
    uDatabase '%s' does not existuSHOW TABLES IN {0}uMySQL Error {0}: {1}umysql.erroriN(t	db_existsRtinfoR4R
RRRRRR
RR%R:R;RRKR(RRRRRRR=R>RvRR((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pyt	db_tabless,




cK@s�t|�}|dkrtS|j�}i|d6}d}yt|||�Wn@tjk
r�}dj|j�}|t	d<t
j|�tSX|j�|j
dkS(u�
    Checks if a database exists on the MySQL server.

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.db_exists 'dbname'
    udbnameuSHOW DATABASES LIKE %(dbname)s;uMySQL Error {0}: {1}umysql.erroriN(R
RR4RRR
RRR%R:RR;RR$(RRRRR%RR=R>((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pyR�>s




cK@s,t||�r#tjd|�tSt|�}|dkr?tS|j�}t|�}dj|�}i}|dk	r�|d7}||d<n|dk	r�|d7}||d<n|d7}y*t	|||�r�tjd|�t
SWn?tjk
r'}	d	j|	j
�}
|
td
<tj|
�nXtS(u�
    Adds a databases to the MySQL server.

    name
        The name of the database to manage

    character_set
        The character set, if left empty the MySQL default will be used

    collate
        The collation, if left empty the MySQL default will be used

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.db_create 'dbname'
        salt '*' mysql.db_create 'dbname' 'utf8' 'utf8_general_ci'
    uDB '%s' already existsu!CREATE DATABASE IF NOT EXISTS {0}u  CHARACTER SET %(character_set)su
character_setu COLLATE %(collate)sucollateu;uDB '%s' createduMySQL Error {0}: {1}umysql.errorN(R�RR�R4R
RRRRRR3R
RR%R:R;(RR�R�RRRRRR%R=R>((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pyt	db_create\s4





cK@st||�s#tjd|�tS|d
krCtjd|�tSt|�}|dkr_tS|j�}t|�}dj|�}yt	||�Wn@t
jk
r�}dj|j�}|t
d<tj|�tSXt||�s�tjd|�tStjd	|�tS(u�
    Removes a databases from the MySQL server.

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.db_remove 'dbname'
    uDB '%s' does not existumysqluinformation_schemeuDB '%s' may not be removeduDROP DATABASE {0};uMySQL Error {0}: {1}umysql.erroruDatabase '%s' has been removedu"Database '%s' has not been removed(umysqluinformation_schemeN(R�RR�R4R
RRRRRR
RR%R:R;R3(RRRRRRR=R>((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pyt	db_remove�s0

cK@s�t|�}|dkrgS|jtjj�}yd}t||�Wn@tjk
r�}dj|j	�}|t
d<tj|�gSX|j
�}tj|�|S(u�
    Return a list of users on a MySQL server

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.user_list
    u SELECT User,Host FROM mysql.useruMySQL Error {0}: {1}umysql.errorN(R
RRR
RRRRRR%R:RR;RR(RRRRR=R>R((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pyt	user_list�s



u	localhostcK@spt}tjjjt|��}	|	sQtd}
dj|
�}tj	|�tSd|	krcdnd}t
|�}
|
dkr�tdjdj|��r�|r�dtd<||d<t
|�}
n|
dkr�tS|s�t
|�}n|
j�}d}i}||d	<||d
<tjjj|�rmtjjj|�rX|d7}d|d<q�|d
|d7}n�|r�tjjj|	|�dkr�t}q�|}|d
|d7}tj|�|d<n%|r�|d
|d7}||d<n|rt|||�stSnyt|||�Wn@tjk
rb}dj|j�}|td<tj	|�tSX|jdkS(ur
    Checks if a user exists on the MySQL server. A login can be checked to see
    if passwordless login is permitted by omitting ``password`` and
    ``password_hash``, and using ``passwordless=True``.

    .. versionadded:: 0.16.2
        The ``passwordless`` option was added.

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.user_exists 'username' 'hostname' 'password'
        salt '*' mysql.user_exists 'username' 'hostname' password_hash='hash'
        salt '*' mysql.user_exists 'username' passwordless=True
        salt '*' mysql.user_exists 'username' password_column='authentication_string'
    umysql.erroruIMySQL Error: Unable to fetch current server version. Last error was: "{}"uMariaDBu10.2.0u8.0.11u/MySQL Error 1045: Access denied for user '{0}'@uconnection_passuJSELECT User,Host FROM mysql.user WHERE User = %(user)s AND Host = %(host)suuseruhostu AND plugin=%(unix_socket)suunix_socketu AND u = ''iu = PASSWORD(%(password)s)upasswordu = %(password)suMySQL Error {0}: {1}iN(R4R�R�R�R�R�R:RRR;R
RR'R&Rtis_truetversionstversion_cmpR3RR�tverify_loginRR
RR%R$(R?R@tpasswordt
password_hashtpasswordlesstunix_sockettpassword_columnRt
run_verifytserver_versiontlast_errR>tcompare_versionRRRR%t	_passwordR=((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pytuser_exists�sd








	


c
K@s�t|�}|dkrtS|jtjj�}d}i}||d<||d<yt|||�Wn@tjk
r�}dj	|j
�}|td<tj
|�tSX|j�}	tj|	�|	S(u�
    Get full info on a MySQL user

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.user_info root localhost
    uBSELECT * FROM mysql.user WHERE User = %(user)s AND Host = %(host)suuseruhostuMySQL Error {0}: {1}umysql.errorN(R
RR4RR
RRRRRR%R:RR;R�R(
R?R@RRRRR%R=R>tresult((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pyt	user_info0s$





cK@s�tjjjt|��}|sKtd}	dj|	�}
tj|
�t	Sd|kr]dnd}t
|||�r�tjd||�t	St|�}|dkr�t	S|s�t|�}n|j�}
d}i}||d<||d	<|dk	r|d
7}tj|�|d<n�|dk	rctjjj||�dkrL|d
7}n
|d
7}||d<ngtjjj|�r�tjjj|�r�|dkr�|d7}q�tjd�q�ntjd�t	Syt|
||�Wn@tjk
r }dj|j�}
|
td<tj|
�t	SXt
||||d||�r�dj||�}t||f�sp|d7}ntj|�tStjd||�t	S(u�
    Creates a MySQL user

    host
        Host for which this user/password combo applies

    password
        The password to use for the new user. Will take precedence over the
        ``password_hash`` option if both are specified.

    password_hash
        The password in hashed form. Be sure to quote the password because YAML
        doesn't like the ``*``. A password hash can be obtained from the mysql
        command-line client like so::

            mysql> SELECT PASSWORD('mypass');
            +-------------------------------------------+
            | PASSWORD('mypass')                        |
            +-------------------------------------------+
            | *6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4 |
            +-------------------------------------------+
            1 row in set (0.00 sec)

    allow_passwordless
        If ``True``, then ``password`` and ``password_hash`` can be omitted (or
        set to ``None``) to permit a passwordless login.

    unix_socket
        If ``True`` and allow_passwordless is ``True`` then will be used unix_socket auth plugin.

    .. versionadded:: 0.16.2
        The ``allow_passwordless`` option was added.

    CLI Examples:

    .. code-block:: bash

        salt '*' mysql.user_create 'username' 'hostname' 'password'
        salt '*' mysql.user_create 'username' 'hostname' password_hash='hash'
        salt '*' mysql.user_create 'username' 'hostname' allow_passwordless=True
    umysql.erroruIMySQL Error: Unable to fetch current server version. Last error was: "{}"uMariaDBu10.2.0u8.0.11uUser '%s'@'%s' already existsuCREATE USER %(user)s@%(host)suuseruhostu IDENTIFIED BY %(password)supasswordiu$ IDENTIFIED BY PASSWORD %(password)su	localhostu IDENTIFIED VIA unix_socketu7Auth via unix_socket can be set only for host=localhostuKpassword or password_hash must be specified, unless allow_passwordless=TrueuMySQL Error {0}: {1}R�u!User '{0}'@'{1}' has been createdu with passwordless loginuUser '%s'@'%s' was not createdN(R�R�R�R�R�R:RRR;R4R�R�R
RR&RRR�R�R�R�RR
RR%R�R3(R?R@R�R�tallow_passwordlessR�R�RR�R�R>R�RRRR%R=tmsg((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pytuser_createQsf1














cK@sItjjjt|��}|sKtd}	dj|	�}
tj|
�t	Sd|kr]dnd}i}|dk	r�tjjj||�dkr�d}
nd}
||d	<nK|dk	r�d}
||d	<n,tjjj
|�s�tjd
�t	Sd}
t|�}|dkrt	S|s+t|�}n|j�}||d<||d
<tjjj||�dkrrd}nd|d|
d}tjjj
|�rtjjj
|�r|dkrd|d<tjjj||�dkr�d}qd|d|
dd}qtjd�nyt|||�}Wn@tjk
rt}dj|j�}
|
td<tj|
�t	SXtjjj||�dkr�t|d�tjd||t||f�r�dnd�tS|rt|d�tjd||t||f�rdnd�tStjd||t||f�r>dnd�t	S(u?
    Change password for a MySQL user

    host
        Host for which this user/password combo applies

    password
        The password to set for the new user. Will take precedence over the
        ``password_hash`` option if both are specified.

    password_hash
        The password in hashed form. Be sure to quote the password because YAML
        doesn't like the ``*``. A password hash can be obtained from the mysql
        command-line client like so::

            mysql> SELECT PASSWORD('mypass');
            +-------------------------------------------+
            | PASSWORD('mypass')                        |
            +-------------------------------------------+
            | *6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4 |
            +-------------------------------------------+
            1 row in set (0.00 sec)

    allow_passwordless
        If ``True``, then ``password`` and ``password_hash`` can be omitted (or
        set to ``None``) to permit a passwordless login.

    .. versionadded:: 0.16.2
        The ``allow_passwordless`` option was added.

    CLI Examples:

    .. code-block:: bash

        salt '*' mysql.user_chpass frank localhost newpassword
        salt '*' mysql.user_chpass frank localhost password_hash='hash'
        salt '*' mysql.user_chpass frank localhost allow_passwordless=True
    umysql.erroruIMySQL Error: Unable to fetch current server version. Last error was: "{}"uMariaDBu10.2.0u8.0.11iu%(password)suPASSWORD(%(password)s)upassworduKpassword or password_hash must be specified, unless allow_passwordless=Trueu''uuseruhostu8ALTER USER %(user)s@%(host)s IDENTIFIED BY %(password)s;uUPDATE mysql.user SET u=u) WHERE User=%(user)s AND Host = %(host)s;u	localhostuauth_socketuunix_socketuIALTER USER %(user)s@%(host)s IDENTIFIED WITH %(unix_socket)s AS %(user)s;u, plugin=%(unix_socket)su7Auth via unix_socket can be set only for host=localhostuMySQL Error {0}: {1}uFLUSH PRIVILEGES;u'Password for user '%s'@'%s' has been %suchangeduclearedu&Password for user '%s'@'%s' was not %sN(R�R�R�R�R�R:RRR;R4RR�R�R�R
R&RRR
RR%R�R�R3(R?R@R�R�R�R�R�RR�R�R>R�R%tpassword_sqlRRRR�R=((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pytuser_chpass�s�.

	




	
	




c	K@s�t|�}|dkrtS|j�}d}i}||d<||d<yt|||�Wn@tjk
r�}dj|j�}|t	d<t
j|�tSXt|||�s�t
j
d||�tSt
j
d||�tS(	u{
    Delete MySQL user

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.user_remove frank localhost
    uDROP USER %(user)s@%(host)suuseruhostuMySQL Error {0}: {1}umysql.erroruUser '%s'@'%s' has been removedu#User '%s'@'%s' has NOT been removedN(R
RR4RRR
RRR%R:RR;R�R�R3(	R?R@RRRRR%R=R>((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pytuser_removeEs(



cC@s
t|�S(u�
    External wrapper function
    :param grant:
    :return: dict

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.tokenize_grant             "GRANT SELECT, INSERT ON testdb.* TO 'testuser'@'localhost'"
    (RY(RA((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pyttokenize_grantjs
cK@s�g}|dkrat||�}xb|D]2}tjd||�|jt|||��q(Wn%tjd||�t|||�}|S(u�
    Repairs the full database or just a given table

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.db_check dbname
        salt '*' mysql.db_check dbname dbtable
    u Checking table '%s' in db '%s'..N(RR�RR�RKR (RRRRvttables((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pytdb_check{s

 cK@s�g}|dkrat||�}xb|D]2}tjd||�|jt|||��q(Wn%tjd||�t|||�}|S(u�
    Repairs the full database or just a given table

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.db_repair dbname
    u!Repairing table '%s' in db '%s'..N(RR�RR�RKR!(RRRRvR�((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pyt	db_repair�s
 cK@s�g}|dkrat||�}xb|D]2}tjd||�|jt|||��q(Wn%tjd||�t|||�}|S(u�
    Optimizes the full database or just a given table

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.db_optimize dbname
    u"Optimizing table '%s' in db '%s'..N(RR�RR�RKR"(RRRRvR�((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pytdb_optimize�s
 cC@si|dkrd}n|jd�}x>|D]6}|j�j�tkr+tdj|���q+q+W|S(NuALLuALL PRIVILEGESu,uInvalid grant : '{0}'(tsplitRMRct
__grants__t	ExceptionR(RAtexploded_grantstchkgrant((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pyt__grant_normalize�s	
	cC@s�g}x�|D]�}ttj|��}|j�j�}|tkr^tdj|���n|tkr�|j	dj|||j
dd���q
||r
|j	|�q
q
Wddj|�S(NuInvalid SSL option : '{0}'u	{0} '{1}'u'uu	 REQUIRE u AND (tnextRtiterkeysRMRct__ssl_options__R�Rt__ssl_options_parameterized__RKRDRL(t
ssl_optiontnew_ssl_optiontoptR+t
normal_key((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pyt__ssl_option_sanitize�s
	,
cC@s?tjdd|�j�}t|�}|jd�}|d}|d}	|r�|dkrwt|d|	dk�}n|	dkr�t|	�}	q�ndj|||	�}
i}||d	<||d
<t|t�r�t	|�r�|
t
|�7}
ntjj
j|�r|
d7}
ntjd|
t|��i|
d
6|d6S(u�
    Validate grants and build the query that could set the given grants

    Note that this query contains arguments for user and host but not for
    grants or database.
    u\s*,\s*u, u.iiu*R[u)GRANT {0} ON {1}.{2} TO %(user)s@%(host)suuseruhostu WITH GRANT OPTIONu!Grant Query generated: %s args %suqryuargs(R�tsubRcR�t
rpartitionRRRCRJR(R�R�R�R�R�RRR](RARBR?R@tgrant_optiontescapeR�tdb_partRRRR%((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pyt__grant_generate�s(




c
K@s]t|||�s)tjd||�tSt|�}|dkrEtS|j�}d}i}||d<||d<yt|||�Wn@tj	k
r�}dj
|j�}|td<tj
|�tSXg}	tjjj|j��}
x`|
D]X}|djd�d}d	|dkr;d	|kr;d
j
|�}n|	j|�q�Wtj|	�|	S(u�
    Shows the grants for the given MySQL user (if it exists)

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.user_grants 'frank' 'localhost'
    uUser '%s'@'%s' does not existu!SHOW GRANTS FOR %(user)s@%(host)suuseruhostuMySQL Error {0}: {1}umysql.erroriu IDENTIFIED BYuWITH GRANT OPTIONu{0} WITH GRANT OPTIONN(R�RR�R4R
RRRR
RRR%R:R;R�R�R�R�RR�RKR(
R?R@RRRRR%R=R>RvRRAttmp((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pytuser_grantss6





c	K@sRtjjjt|��}|sKtd}dj|�}	tj|	�t	Sd|kr�tjj
j|d�dkr�d|kr�djgt
D]}
|
^q��}q�d}nyt||||||�}Wntk
r�tjd	�t	SXt|||�}|t	krtjd
�t	Si}
x�|D]|}t|�}|d|
kr�i|dd6|dd6|d
d
6|dd6|
|d<q,|
|ddj|d�q,Wt|�}x�|
j�D]x\}}y i}i}g|dD]"}
|
|dkrtnt	^q�}x{ddd
gD]j}||jdd�jdd�jdd�||<||jdd�jdd�jdd�||<q#W|d|dkr�|d|dkr�|d
|d
kr�t|�r�tStjd||�Wq�tk
r<}tj|�|t	k	r=||kr=tjd�tSq�Xq�Wtjd�t	S(u�
    Checks to see if a grant exists in the database

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.grant_exists              'SELECT,INSERT,UPDATE,...' 'database.*' 'frank' 'localhost'
    umysql.erroruIMySQL Error: Unable to fetch current server version. Last error was: "{}"uALLu8.0iuMariaDBu,uALL PRIVILEGESuError during grant generation.u�Grant does not exist or may not be ordered properly. In some cases, this could also indicate a connection error. Check your configuration.udatabaseuuseruhostugrantu"uu\u`ugrants mismatch '%s'<>'%s'u
Grant exists.u9Grant does not exist, or is perhaps not ordered properly?(R�R�R�R�R�R:RRR;R4R�R�RLt__all_privileges__R�R�R�RYtextendtitemsR3RDtallRt	exception(RARBR?R@R�R�RR�R�R>tittargettgrantst_grantstgrant_tokent
target_tokensRTt
_grant_tokenst_target_tokenst_grant_matchestitemR=((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pytgrant_existsGsj

%	



!026


c
K@s2t|�}|dkrtS|j�}	|j�}y"t|||||||�}
Wntk
rwtjd�tSXyt	|	|
d|
d�WnIt
jt
jfk
r�}dj
|j�}|td<tj|�tSXt|||||||�rtjd|||�tStjd|||�tS(	u
    Adds a grant to the MySQL server.

    For database, make sure you specify database.table or database.*

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.grant_add             'SELECT,INSERT,UPDATE,...' 'database.*' 'frank' 'localhost'
    uError during grant generationuqryuargsuMySQL Error {0}: {1}umysql.erroru/Grant '%s' on '%s' for user '%s' has been addedu3Grant '%s' on '%s' for user '%s' has NOT been addedN(R
RR4RRMR�R�RR;RR
RtProgrammingErrorRR%R:R�R�R3(
RARBR?R@R�R�R�RRRRR=R>((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pyt	grant_add�s8"



	

cK@s�t|�}|dkrtS|j�}t|�}tjjj|�rV|d7}n|j	d�}	|	d}|	d}
|dkr�t
|d|
dk�}n|dkr�|}n|
dkr�t
|
�}
ndj|||
�}i}
||
d<||
d	<yt|||
�Wn@t
jk
rU}d
j|j�}|td<tj|�tSXt|||||||�s�tjd|||�tStjd
|||�tS(u�
    Removes a grant from the MySQL server.

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.grant_revoke             'SELECT,INSERT,UPDATE' 'database.*' 'frank' 'localhost'
    u, GRANT OPTIONu.iiu*R[u-REVOKE {0} ON {1}.{2} FROM %(user)s@%(host)s;uuseruhostuMySQL Error {0}: {1}umysql.erroru1Grant '%s' on '%s' for user '%s' has been revokedu5Grant '%s' on '%s' for user '%s' has NOT been revokedN(R
RR4RR�R�R�R�R�R�RRRR
RR%R:RR;R�R�R3(RARBR?R@R�R�RRRR�Rt
s_databaseRR%R=R>((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pytgrant_revoke�sZ


		



	

c
K@s�g}t|�}|dkr"gS|j�}t|d�g|jD]}|d^qE}xet|j�D]T}|j�}i}x,tt|��D]}	||	|||	<q�W|j	|�qkW|j
�|S(u(
    Retrieves the processlist from the MySQL server via
    "SHOW FULL PROCESSLIST".

    Returns: a list of dicts, with each dict representing a process:

    .. code-block:: python

        {'Command': 'Query',
        'Host': 'localhost',
        'Id': 39,
        'Info': 'SHOW FULL PROCESSLIST',
        'Rows_examined': 0,
        'Rows_read': 1,
        'Rows_sent': 0,
        'State': None,
        'Time': 0,
        'User': 'root',
        'db': 'mysql'}

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.processlist

    uSHOW FULL PROCESSLISTiN(R
RRRRlRR$R�R(RKR�(
RRvRRtcthdrR�R�tidx_rtidx_j((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pytprocesslist$s
 
cC@s`tj�jj}tjd||�g}y|j�}WnBtjk
rtj	d||�|j
�tjd|�|SXyt||�WnBtjk
r�tj	d||�|j
�tjd|�|SX|j�}x]|D]U}d}i}x3|j
D](}	|	d}
||||
<|d7}qW|j|�q�W|j
�tjd|�|S(ud
    Perform the query that is passed to it (sql_str).

    Returns:
       results in a dict.

    u	%s<--(%s)u %s: Can't get cursor for SQL->%su%s-->u%s: try to execute : SQL->%sii(tsyst	_getframetf_codetco_nameRRRR
t
MySQLErrorR;R�RRRlRK(tconntsql_strtmodtrtn_resultsRtqrstrow_datatcol_cntR�tcol_datatcol_name((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pyt__do_query_into_hashRs:




cK@s�tj�jj}tjd|�t|�}|dkr>gSt|d�}|j	�t
|�dkry|jg�ntjd|t
|d��|dS(u_
    Retrieves the master status from the minion.

    Returns::

        {'host.domain.com': {'Binlog_Do_DB': '',
                         'Binlog_Ignore_DB': '',
                         'File': 'mysql-bin.000021',
                         'Position': 107}}

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.get_master_status

    u%s<--uSHOW MASTER STATUSiu%s-->%sN(RRRRRRR
RRR�R(RK(RR
Rtrtnv((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pytget_master_status�s
cK@s�tj�jj}tjd|�t|�}|dkr>gSt|d�}|j	�t
|�dkry|jg�ntjd|t
|d��|dS(u�
    Retrieves the slave status from the minion.

    Returns::

        {'host.domain.com': {'Connect_Retry': 60,
                       'Exec_Master_Log_Pos': 107,
                       'Last_Errno': 0,
                       'Last_Error': '',
                       'Last_IO_Errno': 0,
                       'Last_IO_Error': '',
                       'Last_SQL_Errno': 0,
                       'Last_SQL_Error': '',
                       'Master_Host': 'comet.scion-eng.com',
                       'Master_Log_File': 'mysql-bin.000021',
                       'Master_Port': 3306,
                       'Master_SSL_Allowed': 'No',
                       'Master_SSL_CA_File': '',
                       'Master_SSL_CA_Path': '',
                       'Master_SSL_Cert': '',
                       'Master_SSL_Cipher': '',
                       'Master_SSL_Key': '',
                       'Master_SSL_Verify_Server_Cert': 'No',
                       'Master_Server_Id': 1,
                       'Master_User': 'replu',
                       'Read_Master_Log_Pos': 107,
                       'Relay_Log_File': 'klo-relay-bin.000071',
                       'Relay_Log_Pos': 253,
                       'Relay_Log_Space': 553,
                       'Relay_Master_Log_File': 'mysql-bin.000021',
                       'Replicate_Do_DB': '',
                       'Replicate_Do_Table': '',
                       'Replicate_Ignore_DB': '',
                       'Replicate_Ignore_Server_Ids': '',
                       'Replicate_Ignore_Table': '',
                       'Replicate_Wild_Do_Table': '',
                       'Replicate_Wild_Ignore_Table': '',
                       'Seconds_Behind_Master': 0,
                       'Skip_Counter': 0,
                       'Slave_IO_Running': 'Yes',
                       'Slave_IO_State': 'Waiting for master to send event',
                       'Slave_SQL_Running': 'Yes',
                       'Until_Condition': 'None',
                       'Until_Log_File': '',
                       'Until_Log_Pos': 0}}

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.get_slave_status

    u%s<--uSHOW SLAVE STATUSiu%s-->%sN(RRRRRRR
RRR�R(RK(RR
RR((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pytget_slave_status�s6
cK@s�tj�jj}tjd|�t|�}|dkr>gSt|d�}|j	�t
|�dkry|jg�ntjd|t
|d��|S(u�
    Retrieves the show variables from the minion.

    Returns::
        show variables full dict

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.showvariables

    u%s<--uSHOW VARIABLESiu%s-->%sN(RRRRRRR
RRR�R(RK(RR
RR((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pyt
showvariables�s
cK@s�tj�jj}tjd|�t|�}|dkr>gSt|d�}|j	�t
|�dkry|jg�ntjd|t
|d��|S(u�
    Retrieves the show global variables from the minion.

    Returns::
        show global variables full dict

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.showglobal

    u%s<--uSHOW GLOBAL VARIABLESiu%s-->%sN(RRRRRRR
RRR�R(RK(RR
RR((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pyt
showglobal	s
cK@sJ||d<||d<t|�}|dkrFdtkrBtd=ntStS(u�
    Attempt to login using the provided credentials.
    If successful, return true.  Otherwise, return False.

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.verify_login root password
    uconnection_useruconnection_passumysql.errorN(R
RR:R4R3(R?R�RR((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pyR� 	s


(Wt__doc__t
__future__RRRRjtloggingR�RRER�tsalt.utils.dataR�tsalt.utils.filestsalt.utils.stringutilstsalt.extRtsalt.ext.six.movesRRR
tMySQLdb.cursorstMySQLdb.converterstMySQLdb.constantsRRRtImportErrortpymysqltinstall_as_MySQLdbRt	getLoggert__name__Rt__opts__R�R�R�R�RR R!R"R&R
RYR4RRRmR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R3R�R�R�R�R�RRRRRRR�(((s6/usr/lib/python2.7/site-packages/salt/modules/mysql.pyt<module>"s�


		
	K						J	�	�	J			*	.	!		%	5	,	R"l~$			&,W4H	.	.	"	F		

Zerion Mini Shell 1.0