%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/modules/oracle.pyc

�
���^c@@sddZddlmZmZmZddlZddlZddlmZddl	m
Z
eje�Z
y0ddlZiejd6ejd6ZeZWn+ek
r�idd6d	d6ZeZnXd
Zd�Zd�Zd
�Zd�Zedde�d��Zd�Zedde�d��Zedde�d��Zdd�Z d�Z!dS(u�
Oracle DataBase connection module

:maintainer: Vladimir Bormotov <bormotov@gmail.com>

:maturity: new

:depends: cx_Oracle

:platform: all

:configuration: module provide connections for multiple Oracle DB instances.

    **OS Environment**

    .. code-block:: yaml

        ORACLE_HOME: path to oracle product
        PATH: path to Oracle Client libs need to be in PATH

    **pillar**

    .. code-block:: yaml

        oracle:
          dbs:
            <db>:
              uri: connection credentials in format:
            user/password@host[:port]/sid[ servicename as {sysdba|sysoper}]
              optional keyword servicename will determine whether it is a sid or service_name
            <db>:
              uri: .....
i(tabsolute_importtprint_functiontunicode_literalsN(tdepends(tsixusysdbausysoperiiuoraclecC@str
tStdfS(u1
    Load module only if cx_Oracle installed
    uHThe oracle execution module not loaded: python oracle library not found.(t
HAS_CX_ORACLEt__virtualname__tFalse(((s7/usr/lib/python2.7/site-packages/salt/modules/oracle.pyt__virtual__:scC@sdS(u 
    Fallback function stub
    uDNeed "cx_Oracle" and Oracle Client installed for this function exist((((s7/usr/lib/python2.7/site-packages/salt/modules/oracle.pyt_cx_oracle_reqDscC@sA|tjtjtjtjfkr=|jtj||j�SdS(u�
    Return strings values as python unicode string

    http://www.oracle.com/technetwork/articles/dsl/tuininga-cx-oracle-084866.html
    N(	t	cx_OracletSTRINGtLONG_STRINGt
FIXED_CHARtCLOBtvarRt	text_typet	arraysize(tcursortnametdefault_typetsizet	precisiontscale((s7/usr/lib/python2.7/site-packages/salt/modules/oracle.pyt_unicode_outputKscC@s�|jdd�}t|�dkr=|\}}t|}n|d}d}t}|jd�\}}|jd�\}}|jd�\}	}
d|
kr�t}|
jd�dj�}
n|	jd�}t|�dkr�|\}}
n|d}d	}
tjd
||||
|
|f�dt	j
d<|rbtj||tj
||
d
|
�|�}n'tj||tj
||
|
�|�}t|_|S(um
    uri = user/password@host[:port]/sid[ as {sysdba|sysoper}]

    Return cx_Oracle.Connection instance
    u as iiiu@u/uservicenameu:i�uconnect: %su	.AL32UTF8uNLS_LANGtservice_name(trsplittlentMODERtsplittTruetstriptlogtdebugtostenvironR
tconnecttmakedsnRtoutputtypehandler(turituri_ltcredentialstmodet	serv_nametuserpassthostportsidtusertpasswordthostporttsidt
hostport_lthosttporttconn((s7/usr/lib/python2.7/site-packages/salt/modules/oracle.pyt_connectVs:


"
		u	cx_Oracletfallback_functioncC@sFtjd||�tt|�|d�}|j�j|�j�S(u�
    Run SQL query and return result

    CLI Example:

    .. code-block:: bash

        salt '*' oracle.run_query my_db "select * from my_table"
    urun query on %s: %suuri(R R!R6tshow_dbsRtexecutetfetchall(tdbtqueryR5((s7/usr/lib/python2.7/site-packages/salt/modules/oracle.pyt	run_query�scG@sw|rItjd|�i}x&|D]}tdd|�||<q#W|Stdd�}tjdt|��|SdS(u�
    Show databases configuration from pillar. Filter by `*args`

    CLI Example:

    .. code-block:: bash

        salt '*' oracle.show_dbs
        salt '*' oracle.show_dbs my_db
    uget dbs from pillar: %su
pillar.getuoracle:dbs:u
oracle:dbsuget all (%s) dbs from pillarN(R R!t__salt__R(tdbstresultR;t
pillar_dbs((s7/usr/lib/python2.7/site-packages/salt/modules/oracle.pyR8�s
cG@s�tdd�}d�}i}|rhtjd|�xg|D]%}||kr<||�||<q<q<Wn7tjdt|��x|D]}||�||<q�W|S(u�
    Server Version (select banner  from v$version)

    CLI Example:

    .. code-block:: bash

        salt '*' oracle.version
        salt '*' oracle.version my_db
    u
pillar.getu
oracle:dbscS@s$gt|d�D]}|d^qS(Nu,select banner from v$version order by banneri(R=(txtr((s7/usr/lib/python2.7/site-packages/salt/modules/oracle.pyt<lambda>�suget db versions for: %suget all (%s) dbs versions(R>R R!R(R?RAtget_versionR@R;((s7/usr/lib/python2.7/site-packages/salt/modules/oracle.pytversion�s	

cC@sdjd�tj�D��S(us
    Oracle Client Version

    CLI Example:

    .. code-block:: bash

        salt '*' oracle.client_version
    u.cs@s|]}tj|�VqdS(N(RR(t.0RB((s7/usr/lib/python2.7/site-packages/salt/modules/oracle.pys	<genexpr>�s(tjoinR
t
clientversion(((s7/usr/lib/python2.7/site-packages/salt/modules/oracle.pytclient_version�scC@s*|rtdd|�Stdd�SdS(u�
    Show Pillar segment oracle.* and subitem with notation "item:subitem"

    CLI Example:

    .. code-block:: bash

        salt '*' oracle.show_pillar
        salt '*' oracle.show_pillar dbs:my_db
    u
pillar.getuoracle:uoracleN(R>(titem((s7/usr/lib/python2.7/site-packages/salt/modules/oracle.pytshow_pillar�scC@sPddddg}i}x1|D])}|tjkrtj|||<qqW|S(u�
    Show Environment used by Oracle Client

    CLI Example:

    .. code-block:: bash

        salt '*' oracle.show_env

    .. note::
        at first _connect() ``NLS_LANG`` will forced to '.AL32UTF8'
    uPATHuORACLE_HOMEu	TNS_ADMINuNLS_LANG(R"R#(tenvsR@tenv((s7/usr/lib/python2.7/site-packages/salt/modules/oracle.pytshow_env�s

("t__doc__t
__future__RRRR"tloggingtsalt.utils.decoratorsRtsalt.extRt	getLoggert__name__R R
tSYSDBAtSYSOPERRRRtImportErrorRRRR	RR6R=R8RFRJtNoneRLRO(((s7/usr/lib/python2.7/site-packages/salt/modules/oracle.pyt<module>"s4




	
			+	

Zerion Mini Shell 1.0