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

�
���^c@@s�dZddlmZmZmZyddlZeZWne	k
rQe
ZnXddlZeje
�ZdZd�Zddddd�Zddddd�Zddddd�Zddddd	�Zddddd
�Zdddddd�Zdddddd�Zdddddd
�Zdddddd�Zdddddd�Zddddd�Zddddd�Ze
ddddd�Ze
ddddd�Zde
ddddd�Z dddd�Z!dS(u�
InfluxDB - A distributed time series database

Module to provide InfluxDB compatibility to Salt (compatible with InfluxDB
version 0.5-0.8)

.. versionadded:: 2014.7.0

:depends:    - influxdb Python module (>= 1.0.0)

:configuration: This module accepts connection configuration details either as
    parameters or as configuration settings in /etc/salt/minion on the relevant
    minions::

        influxdb08.host: 'localhost'
        influxdb08.port: 8086
        influxdb08.user: 'root'
        influxdb08.password: 'root'

    This data can also be passed into pillar. Options passed into opts will
    overwrite options passed into pillar.
i(tabsolute_importtprint_functiontunicode_literalsNu
influxdb08cC@str
tStdfS(u.
    Only load if influxdb lib is present
    uMThe influx execution module cannot be loaded: influxdb library not available.(tHAS_INFLUXDB_08t__virtualname__tFalse(((s>/usr/lib/python2.7/site-packages/salt/modules/influxdb08mod.pyt__virtual__+sc	C@s�|stddd�}n|s8tddd�}n|sTtddd�}n|sptddd�}ntjjd	|d
|d|d|�S(
Nu
config.optionuinfluxdb08.userurootuinfluxdb08.passworduinfluxdb08.hostu	localhostuinfluxdb08.porti�thosttporttusernametpassword(t__salt__tinfluxdbt
influxdb08tInfluxDBClient(tuserR
RR((s>/usr/lib/python2.7/site-packages/salt/modules/influxdb08mod.pyt_client4sc	C@s+td|d|d|d|�}|j�S(ue
    List all InfluxDB databases

    user
        The user to connect as

    password
        The password of the user

    host
        The host to connect to

    port
        The port to connect to

    CLI Example:

    .. code-block:: bash

        salt '*' influxdb08.db_list
        salt '*' influxdb08.db_list <user> <password> <host> <port>

    RR
RR(Rtget_list_database(RR
RRtclient((s>/usr/lib/python2.7/site-packages/salt/modules/influxdb08mod.pytdb_listAs!cC@sIt||||�}t|t�s(tS|g|D]}|d^q2kS(u�
    Checks if a database exists in Influxdb

    name
        Database name to create

    user
        The user to connect as

    password
        The password of the user

    host
        The host to connect to

    port
        The port to connect to

    CLI Example:

    .. code-block:: bash

        salt '*' influxdb08.db_exists <name>
        salt '*' influxdb08.db_exists <name> <user> <password> <host> <port>
    uname(Rt
isinstancetlistR(tnameRR
RRtdbstdb((s>/usr/lib/python2.7/site-packages/salt/modules/influxdb08mod.pyt	db_exists]sc	C@s^t|||||�r,tjd|�tStd|d|d|d|�}|j|�tS(u�
    Create a database

    name
        Database name to create

    user
        The user to connect as

    password
        The password of the user

    host
        The host to connect to

    port
        The port to connect to

    CLI Example:

    .. code-block:: bash

        salt '*' influxdb08.db_create <name>
        salt '*' influxdb08.db_create <name> <user> <password> <host> <port>
    uDB '%s' already existsRR
RR(RtlogtinfoRRtcreate_databasetTrue(RRR
RRR((s>/usr/lib/python2.7/site-packages/salt/modules/influxdb08mod.pyt	db_create}s!
c	C@sZt|||||�s,tjd|�tStd|d|d|d|�}|j|�S(u�
    Remove a database

    name
        Database name to remove

    user
        The user to connect as

    password
        The password of the user

    host
        The host to connect to

    port
        The port to connect to

    CLI Example:

    .. code-block:: bash

        salt '*' influxdb08.db_remove <name>
        salt '*' influxdb08.db_remove <name> <user> <password> <host> <port>
    uDB '%s' does not existRR
RR(RRRRRtdelete_database(RRR
RRR((s>/usr/lib/python2.7/site-packages/salt/modules/influxdb08mod.pyt	db_remove�s
!c	C@sHtd|d|d|d|�}|s1|j�S|j|�|j�S(uv
    List cluster admins or database users.

    If a database is specified: it will return database users list.
    If a database is not specified: it will return cluster admins list.

    database
        The database to list the users from

    user
        The user to connect as

    password
        The password of the user

    host
        The host to connect to

    port
        The port to connect to

    CLI Example:

    .. code-block:: bash

        salt '*' influxdb08.user_list
        salt '*' influxdb08.user_list <database>
        salt '*' influxdb08.user_list <database> <user> <password> <host> <port>
    RR
RR(Rtget_list_cluster_adminstswitch_databasetget_list_users(tdatabaseRR
RRR((s>/usr/lib/python2.7/site-packages/salt/modules/influxdb08mod.pyt	user_list�s
!

cC@s�t|||||�}t|t�s+tSxR|D]J}|jd|jd��}|rl||kr|tSq2tjd|�q2WtS(u�
    Checks if a cluster admin or database user exists.

    If a database is specified: it will check for database user existence.
    If a database is not specified: it will check for cluster admin existence.

    name
        User name

    database
        The database to check for the user to exist

    user
        The user to connect as

    password
        The password of the user

    host
        The host to connect to

    port
        The port to connect to

    CLI Example:

    .. code-block:: bash

        salt '*' influxdb08.user_exists <name>
        salt '*' influxdb08.user_exists <name> <database>
        salt '*' influxdb08.user_exists <name> <database> <user> <password> <host> <port>
    uuserunameu#Could not find username in user: %s(R%RRRtgetRRtwarning(RR$RR
RRtusersR	((s>/usr/lib/python2.7/site-packages/salt/modules/influxdb08mod.pytuser_exists�s!
c	C@s�t||||||�rK|r7tjd||�ntjd|�tStd|d|d|d|�}|s�|j||�S|j|�|j||�S(u
    Create a cluster admin or a database user.

    If a database is specified: it will create database user.
    If a database is not specified: it will create a cluster admin.

    name
        User name for the new user to create

    passwd
        Password for the new user to create

    database
        The database to create the user in

    user
        The user to connect as

    password
        The password of the user

    host
        The host to connect to

    port
        The port to connect to

    CLI Example:

    .. code-block:: bash

        salt '*' influxdb08.user_create <name> <passwd>
        salt '*' influxdb08.user_create <name> <passwd> <database>
        salt '*' influxdb08.user_create <name> <passwd> <database> <user> <password> <host> <port>
    u$User '%s' already exists for DB '%s'u!Cluster admin '%s' already existsRR
RR(R)RRRRtadd_cluster_adminR"tadd_database_user(RtpasswdR$RR
RRR((s>/usr/lib/python2.7/site-packages/salt/modules/influxdb08mod.pytuser_creates*!
c	C@s�t||||||�sK|r7tjd||�ntjd|�tStd|d|d|d|�}|s�|j||�S|j|�|j||�S(u
    Change password for a cluster admin or a database user.

    If a database is specified: it will update database user password.
    If a database is not specified: it will update cluster admin password.

    name
        User name for whom to change the password

    passwd
        New password

    database
        The database on which to operate

    user
        The user to connect as

    password
        The password of the user

    host
        The host to connect to

    port
        The port to connect to

    CLI Example:

    .. code-block:: bash

        salt '*' influxdb08.user_chpass <name> <passwd>
        salt '*' influxdb08.user_chpass <name> <passwd> <database>
        salt '*' influxdb08.user_chpass <name> <passwd> <database> <user> <password> <host> <port>
    u$User '%s' does not exist for DB '%s'u!Cluster admin '%s' does not existRR
RR(R)RRRRtupdate_cluster_admin_passwordR"tupdate_database_user_password(RR,R$RR
RRR((s>/usr/lib/python2.7/site-packages/salt/modules/influxdb08mod.pytuser_chpassRs*!
c	C@s�t||||||�sK|r7tjd||�ntjd|�tStd|d|d|d|�}|s|j|�S|j|�|j|�S(u�
    Remove a cluster admin or a database user.

    If a database is specified: it will remove the database user.
    If a database is not specified: it will remove the cluster admin.

    name
        User name to remove

    database
        The database to remove the user from

    user
        User name for the new user to delete

    user
        The user to connect as

    password
        The password of the user

    host
        The host to connect to

    port
        The port to connect to

    CLI Example:

    .. code-block:: bash

        salt '*' influxdb08.user_remove <name>
        salt '*' influxdb08.user_remove <name> <database>
        salt '*' influxdb08.user_remove <name> <database> <user> <password> <host> <port>
    u$User '%s' does not exist for DB '%s'u!Cluster admin '%s' does not existRR
RR(R)RRRRtdelete_cluster_adminR"tdelete_database_user(RR$RR
RRR((s>/usr/lib/python2.7/site-packages/salt/modules/influxdb08mod.pytuser_remove�s)!

c	C@sStd|d|d|d|�}x+|j|�D]}|d|kr1|Sq1WdS(u�
    Get an existing retention policy.

    database
        The database to operate on.

    name
        Name of the policy to modify.

    CLI Example:

    .. code-block:: bash

        salt '*' influxdb08.retention_policy_get metrics default
    RR
RRunameN(Rtget_list_retention_policiestNone(R$RRR
RRRtpolicy((s>/usr/lib/python2.7/site-packages/salt/modules/influxdb08mod.pytretention_policy_get�s
!cC@s%t||||||�}|dk	S(u
    Check if a retention policy exists.

    database
        The database to operate on.

    name
        Name of the policy to modify.

    CLI Example:

    .. code-block:: bash

        salt '*' influxdb08.retention_policy_exists metrics default
    N(R7R5(R$RRR
RRR6((s>/usr/lib/python2.7/site-packages/salt/modules/influxdb08mod.pytretention_policy_exists�sc	
	C@s>td|d|d|d|�}	|	j|||||�tS(u�
    Add a retention policy.

    database
        The database to operate on.

    name
        Name of the policy to modify.

    duration
        How long InfluxDB keeps the data.

    replication
        How many copies of the data are stored in the cluster.

    default
        Whether this policy should be the default or not. Default is False.

    CLI Example:

    .. code-block:: bash

        salt '*' influxdb.retention_policy_add metrics default 1d 1
    RR
RR(Rtcreate_retention_policyR(
R$RtdurationtreplicationtdefaultRR
RRR((s>/usr/lib/python2.7/site-packages/salt/modules/influxdb08mod.pytretention_policy_add�s!!c	
	C@s>td|d|d|d|�}	|	j|||||�tS(u�
    Modify an existing retention policy.

    database
        The database to operate on.

    name
        Name of the policy to modify.

    duration
        How long InfluxDB keeps the data.

    replication
        How many copies of the data are stored in the cluster.

    default
        Whether this policy should be the default or not. Default is False.

    CLI Example:

    .. code-block:: bash

        salt '*' influxdb08.retention_policy_modify metrics default 1d 1
    RR
RR(Rtalter_retention_policyR(
R$RR:R;R<RR
RRR((s>/usr/lib/python2.7/site-packages/salt/modules/influxdb08mod.pytretention_policy_alter"s!!usc		C@sGtd|d|d|d|�}|j|�|j|d|d|�S(u[
    Querying data

    database
        The database to query

    query
        Query to be executed

    time_precision
        Time precision to use ('s', 'm', or 'u')

    chunked
        Whether is chunked or not

    user
        The user to connect as

    password
        The password of the user

    host
        The host to connect to

    port
        The port to connect to

    CLI Example:

    .. code-block:: bash

        salt '*' influxdb08.query <database> <query>
        salt '*' influxdb08.query <database> <query> <time_precision> <chunked> <user> <password> <host> <port>
    RR
RRttime_precisiontchunked(RR"tquery(	R$RBR@RARR
RRR((s>/usr/lib/python2.7/site-packages/salt/modules/influxdb08mod.pyRBHs*!
c	C@sly3td|d|d|d|�}|j�tSWn2tjjjk
rg}|jdkratS�nXdS(u�
    Checks if a credential pair can log in at all.

    If a database is specified: it will check for database user existence.
    If a database is not specified: it will check for cluster admin existence.

    name
        The user to connect as

    password
        The password of the user

    database
        The database to try to log in to

    host
        The host to connect to

    port
        The port to connect to

    CLI Example:

    .. code-block:: bash

        salt '*' influxdb08.login_test <name>
        salt '*' influxdb08.login_test <name> <database>
        salt '*' influxdb08.login_test <name> <database> <user> <password> <host> <port>
    RR
RRi�N(	RRRRR
RtInfluxDBClientErrortcodeR(RR
R$RRRte((s>/usr/lib/python2.7/site-packages/salt/modules/influxdb08mod.pyt
login_testws!
("t__doc__t
__future__RRRtinfluxdb.influxdb08RRRtImportErrorRtloggingt	getLoggert__name__RRRR5RRRRR R%R)R-R0R3R7R8R=R?RBRF(((s>/usr/lib/python2.7/site-packages/salt/modules/influxdb08mod.pyt<module>sr


		
 "!'3656" (

Zerion Mini Shell 1.0