%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/states/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/states/grafana4_datasource.pyc

�
���^c@@s�dZddlmZmZmZddlmZddlmZd�Z	d
d
d
d
d
d
d
d
d
d
d
d
d
dd�Zd
dd�Zd
d	�Z
d
S(u�
Manage Grafana v4.0 data sources

.. versionadded:: 2017.7.0

:configuration: This state requires a configuration profile to be configured
    in the minion config, minion pillar, or master config. The module will use
    the 'grafana' key by default, if defined.

    Example configuration using basic authentication:

    .. code-block:: yaml

        grafana:
          grafana_url: http://grafana.localhost
          grafana_user: admin
          grafana_password: admin
          grafana_timeout: 3

    Example configuration using token based authentication:

    .. code-block:: yaml

        grafana:
          grafana_url: http://grafana.localhost
          grafana_token: token
          grafana_timeout: 3

The behavior of this module is to create data sources if the do not exists, and
to update data sources if the already exists.

.. code-block:: yaml

    Ensure influxdb data source is present:
      grafana4_datasource.present:
        - name: influxdb
        - type: influxdb
        - url: http://localhost:8086
        - access: proxy
        - basic_auth: true
        - basic_auth_user: myuser
        - basic_auth_password: mypass
        - is_default: true
i(tabsolute_importtprint_functiontunicode_literals(tstring_types(t	deep_diffcC@s
dtkS(u)Only load if grafana4 module is availableugrafana4.get_datasource(t__salt__(((sC/usr/lib/python2.7/site-packages/salt/states/grafana4_datasource.pyt__virtual__4sugrafanac!C@st|t�r"td|�}ni|d6d$d6d$d6id6}td|||�}td|d|d	|d
|d|d|d
|d|d|d|	d|
d|d|d|
d|d|�}|s?tdr�dj|�|d<|Stdd||�td|d|�}t|d<dj|�|d<||d<|Sx'|D]}||krFd$||<qFqFW||kr�dj|�|d<|Stdr�dj|�|d<|Std|dd||�t|d<t||d dd!d"g�|d<d#j|�|d<|S(%u
    Ensure that a data source is present.

    name
        Name of the data source.

    type
        Type of the datasource ('graphite', 'influxdb' etc.).

    access
        Use proxy or direct. Default: proxy

    url
        The URL to the data source API.

    user
        Optional - user to authenticate with the data source.

    password
        Optional - password to authenticate with the data source.

    database
        Optional - database to use with the data source.

    basic_auth
        Optional - set to True to use HTTP basic auth to authenticate with the
        data source.

    basic_auth_user
        Optional - HTTP basic auth username.

    basic_auth_password
        Optional - HTTP basic auth password.

    json_data
        Optional - additional json data to post (eg. "timeInterval").

    is_default
        Optional - set data source as default.

    with_credentials
        Optional - Whether credentials such as cookies or auth headers should
        be sent with cross-site requests.

    type_logo_url
        Optional - Logo to use for this datasource.

    orgname
        Name of the organization in which the data source should be present.

    profile
        Configuration profile used to connect to the Grafana instance.
        Default is 'grafana'.
    u
config.optionunameuresultucommentuchangesugrafana4.get_datasourcetnamettypeturltaccesstusertpasswordtdatabaset	basicAutht
basicAuthUsertbasicAuthPasswordttlsAuthtjsonDatat	isDefaulttwithCredentialsttypeLogoUrltdefaultsutestuDatasource {0} will be createdugrafana4.create_datasourcetprofileuNew data source {0} addedu"Data source {0} already up-to-dateuDatasource {0} will be updatedugrafana4.update_datasourceuidtignoreuorgIdureadOnlyuData source {0} updatedN(	t
isinstanceRRtNonet_get_json_datat__opts__tformattTrueR(RRR	R
RRR
t
basic_authtbasic_auth_usertbasic_auth_passwordttls_autht	json_datat
is_defaulttwith_credentialst
type_logo_urltorgnameRtrett
datasourcetdatatkey((sC/usr/lib/python2.7/site-packages/salt/states/grafana4_datasource.pytpresent9s\G"	





"cC@s�t|t�r"td|�}ni|d6dd6dd6id6}td|||�}|s�t|d<dj|�|d<|Stdr�d	j|�|d<|Std
|dd|�t|d<d
|d|<dj|�|d<|S(u1
    Ensure that a data source is present.

    name
        Name of the data source to remove.

    orgname
        Name of the organization from which the data source should be absent.

    profile
        Configuration profile used to connect to the Grafana instance.
        Default is 'grafana'.
    u
config.optionunameuresultucommentuchangesugrafana4.get_datasourceuData source {0} already absentutestuDatasource {0} will be deletedugrafana4.delete_datasourceuidRuAbsentuData source {0} was deletedN(RRRRRRR(RR'RR(R)((sC/usr/lib/python2.7/site-packages/salt/states/grafana4_datasource.pytabsent�s "


cK@sX|dkri}nx<|j�D].\}}|dkr"|j|�||<q"q"W|S(N(Rtitemstget(Rtkwargstktv((sC/usr/lib/python2.7/site-packages/salt/states/grafana4_datasource.pyR�s	N(t__doc__t
__future__RRRtsalt.ext.sixRtsalt.utils.dictdifferRRRR,R-R(((sC/usr/lib/python2.7/site-packages/salt/states/grafana4_datasource.pyt<module>-s(	n%

Zerion Mini Shell 1.0