%PDF- %PDF-
Direktori : /usr/lib/python2.7/site-packages/salt/pillar/ |
Current File : //usr/lib/python2.7/site-packages/salt/pillar/sqlcipher.pyo |
� ���^c @@ s� d Z d d l m Z m Z m Z d d l m Z d d l Z d d l m Z e j e � Z y d d l m Z e Z Wn e k r� e Z n Xd � Z d e f d � � YZ d � Z d S( u Retrieve Pillar data by running a SQLCipher query .. versionadded:: 2016.3.0 Python SQLCipher support is provided by the pysqlcipher Python package. You need this module installed to query Pillar data from a SQLCipher database. This module is a concrete implementation of the sql_base ext_pillar for SQLCipher. :maturity: new :depends: pysqlcipher (for py2) or pysqlcipher3 (for py3) :platform: all Configuring the sqlcipher ext_pillar ==================================== Use the 'sqlcipher' key under ext_pillar for configuration of queries. SQLCipher database connection configuration requires the following values configured in the master config: * ``sqlcipher.database`` - The SQLCipher database to connect to. Defaults to ``'/var/lib/salt/pillar-sqlcipher.db'``. * ``sqlcipher.pass`` - The SQLCipher database decryption password. * ``sqlcipher.timeout`` - The connection timeout in seconds. Example configuration .. code-block:: yaml sqlcipher: database: /var/lib/salt/pillar-sqlcipher.db pass: strong_pass_phrase timeout: 5.0 Complete Example ================ .. code-block:: yaml sqlcipher: database: '/var/lib/salt/pillar-sqlcipher.db' pass: strong_pass_phrase timeout: 5.0 ext_pillar: - sqlcipher: fromdb: query: 'SELECT col1,col2,col3,col4,col5,col6,col7 FROM some_random_table WHERE minion_pattern LIKE ?' depth: 5 as_list: True with_lists: [1,3] i ( t absolute_importt print_functiont unicode_literals( t contextmanagerN( t SqlBaseExtPillar( t dbapi2c C@ s t s t St S( N( t HAS_SQLCIPHERt Falset True( ( ( s9 /usr/lib/python2.7/site-packages/salt/pillar/sqlcipher.pyt __virtual__P s t SQLCipherExtPillarc B@ s5 e Z d Z e d � � Z d � Z e d � � Z RS( uM This class receives and processes the database rows from SQLCipher. c C@ s d S( Nu SQLCipher( ( t cls( ( s9 /usr/lib/python2.7/site-packages/salt/pillar/sqlcipher.pyt _db_nameZ s c C@ s� i d d 6d d 6d d 6} i } t j d i � } xL | D]D } | | k rp t j d | � | | | | <q: n | | | | <q: W| S( uD Returns options used for the SQLCipher connection. u! /var/lib/salt/pillar-sqlcipher.dbu databaseu strong_pass_phraseu passg @u timeoutu sqlcipheru% Using default for SQLCipher pillar %s( t __opts__t gett logt debug( t selft defaultst _optionst _optst attr( ( s9 /usr/lib/python2.7/site-packages/salt/pillar/sqlcipher.pyt _get_options^ s c c@ s� | j � } t j | j d � d t | j d � � �} | j d j | j d � � � | j � } z9 y | VWn) t j k r� } t j d | j � n XWd | j � Xd S( u* Yield a SQLCipher cursor u databaset timeoutu timeoutu pragma key="{0}"u passu! Error in ext_pillar SQLCipher: %sN( R t sqlciphert connectR t floatt executet formatt cursort ErrorR t exceptiont argst close( R R t connR t err( ( s9 /usr/lib/python2.7/site-packages/salt/pillar/sqlcipher.pyt _get_cursorp s ( t __name__t __module__t __doc__t classmethodR R R R$ ( ( ( s9 /usr/lib/python2.7/site-packages/salt/pillar/sqlcipher.pyR V s c O@ s t � j | | | | � S( uG Execute queries against SQLCipher, merge and return as a dict ( R t fetch( t minion_idt pillarR t kwargs( ( s9 /usr/lib/python2.7/site-packages/salt/pillar/sqlcipher.pyt ext_pillar� s ( R'