1
0
Fork 0

Update grafana3_datasource parameters

This patch removes parameters that are not used and not documented.
It also fix issue when passing parameters to _get_json_data.
This commit is contained in:
Guillaume Thouvenin 2016-11-03 10:40:29 +01:00
parent ecf143a398
commit ab1023453d
2 changed files with 21 additions and 13 deletions

View File

@ -8,8 +8,8 @@ Token auth setup
.. code-block:: yaml .. code-block:: yaml
grafana_version: 3
grafana: grafana:
grafana_version: 3
grafana_timeout: 5 grafana_timeout: 5
grafana_token: qwertyuiop grafana_token: qwertyuiop
grafana_url: 'https://url.com' grafana_url: 'https://url.com'
@ -18,8 +18,8 @@ Basic auth setup
.. code-block:: yaml .. code-block:: yaml
grafana_version: 3
grafana: grafana:
grafana_version: 3
grafana_timeout: 5 grafana_timeout: 5
grafana_user: grafana grafana_user: grafana
grafana_password: qwertyuiop grafana_password: qwertyuiop
@ -61,9 +61,6 @@ def present(name,
basic_auth_user='', basic_auth_user='',
basic_auth_password='', basic_auth_password='',
is_default=False, is_default=False,
type_logo_url='public/app/plugins/datasource/graphite/img/graphite_logo.png',
with_credentials=False,
json_data=None,
profile='grafana'): profile='grafana'):
''' '''
Ensure that a data source is present. Ensure that a data source is present.
@ -74,6 +71,9 @@ def present(name,
type type
Which type of data source it is ('graphite', 'influxdb' etc.). Which type of data source it is ('graphite', 'influxdb' etc.).
access
Use proxy or direct. Default: proxy
url url
The URL to the data source API. The URL to the data source API.
@ -83,6 +83,9 @@ def present(name,
password password
Optional - password to authenticate with the data source Optional - password to authenticate with the data source
database
Optional - database to use with the data source
basic_auth basic_auth
Optional - set to True to use HTTP basic auth to authenticate with the Optional - set to True to use HTTP basic auth to authenticate with the
data source. data source.
@ -94,15 +97,22 @@ def present(name,
Optional - HTTP basic auth password. Optional - HTTP basic auth password.
is_default is_default
Default: False Optional - Set data source as default. Default: False
''' '''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)
ret = {'name': name, 'result': None, 'comment': None, 'changes': None} ret = {'name': name, 'result': None, 'comment': None, 'changes': None}
datasource = _get_datasource(profile, name) datasource = _get_datasource(profile, name)
data = _get_json_data(name, type, url, access, user, password, database, data = _get_json_data(name, type, url,
basic_auth, basic_auth_user, basic_auth_password, is_default, json_data) access=access,
user=user,
password=password,
database=database,
basic_auth=basic_auth,
basic_auth_user=basic_auth_user,
basic_auth_password=basic_auth_password,
is_default=is_default)
if datasource: if datasource:
if profile.get('grafana_token', False): if profile.get('grafana_token', False):
@ -237,9 +247,8 @@ def _get_json_data(name,
basic_auth_user='', basic_auth_user='',
basic_auth_password='', basic_auth_password='',
is_default=False, is_default=False,
type_logo_url='public/app/plugins/datasource/graphite/img/graphite_logo.png', type_logo_url='public/app/plugins/datasource/influxdb/img/influxdb_logo.svg',
with_credentials=False, with_credentials=False):
json_data=None):
return { return {
'name': name, 'name': name,
'type': type, 'type': type,
@ -254,7 +263,6 @@ def _get_json_data(name,
'isDefault': is_default, 'isDefault': is_default,
'typeLogoUrl': type_logo_url, 'typeLogoUrl': type_logo_url,
'withCredentials': with_credentials, 'withCredentials': with_credentials,
'jsonData': json_data,
} }

View File

@ -23,7 +23,7 @@ grafana_client_datasource_{{ datasource_name }}:
- password: {{ datasource.password }} - password: {{ datasource.password }}
{%- endif %} {%- endif %}
{%- if datasource.get('is_default', false) %} {%- if datasource.get('is_default', false) %}
- is_default: {{ datasource.is_default }} - is_default: {{ datasource.is_default|lower }}
{%- endif %} {%- endif %}
{%- if datasource.database is defined %} {%- if datasource.database is defined %}
- database: {{ datasource.database }} - database: {{ datasource.database }}