Simplify the plugin UI for InfluxDB parameters

This change disables the InfluxDB parameters when the 'local node' mode
is selected. In that case, all the required parameters are already
provided by the InfluxDB-Grafana plugin so the LMA collector gets them
from Hiera directly.

Change-Id: I627e8b5ae202783b24e31acb827915d91a3f8de5
This commit is contained in:
Simon Pasquier 2015-05-12 18:17:53 +02:00
parent 38641d8d60
commit ee0e0ada8d
2 changed files with 21 additions and 8 deletions

View File

@ -86,6 +86,9 @@ case $influxdb_mode {
'remote','local': {
if $influxdb_mode == 'remote' {
$influxdb_server = $lma_collector['influxdb_address']
$influxdb_database = $lma_collector['influxdb_database']
$influxdb_user = $lma_collector['influxdb_user']
$influxdb_password = $lma_collector['influxdb_password']
}
else {
$influxdb_node_name = $lma_collector['influxdb_node_name']
@ -93,7 +96,17 @@ case $influxdb_mode {
if size($influxdb_nodes) < 1 {
fail("Could not find node '${influxdb_node_name}' in the environment")
}
$influxdb_grafana = hiera('influxdb_grafana', false)
if ! $influxdb_grafana {
fail('Could not get the InfluxDB parameters. The InfluxDB-Grafana plugin is probably not installed.')
}
elsif ! $influxdb_grafana['metadata']['enabled'] {
fail('Could not get the InfluxDB parameters. The InfluxDB-Grafana plugin is probably not enabled for this environment.')
}
$influxdb_server = $influxdb_nodes[0]['internal_address']
$influxdb_database = $influxdb_grafana['influxdb_dbname']
$influxdb_user = $influxdb_grafana['influxdb_username']
$influxdb_password = $influxdb_grafana['influxdb_userpass']
}
class { 'lma_collector::collectd::base':
@ -101,9 +114,9 @@ case $influxdb_mode {
class { 'lma_collector::influxdb':
server => $influxdb_server,
database => $lma_collector['influxdb_database'],
user => $lma_collector['influxdb_user'],
password => $lma_collector['influxdb_password'],
database => $influxdb_database,
user => $influxdb_user,
password => $influxdb_password,
}
}
'disabled': {
@ -133,6 +146,6 @@ case $elasticsearch_mode {
}
class { 'lma_collector::elasticsearch':
server => $es_server,
server => $es_server,
require => Class['lma_collector'],
}

View File

@ -94,8 +94,8 @@ attributes:
regex: &not_empty_parameter
source: '\S'
error: "Invalid value"
restrictions: &disable_influxdb_control
- condition: "settings:lma_collector.influxdb_mode.value == 'disabled'"
restrictions: &disable_influxdb_parameters
- condition: "settings:lma_collector.influxdb_mode.value != 'remote'"
action: "disable"
influxdb_user:
value: 'lma'
@ -104,7 +104,7 @@ attributes:
weight: 80
type: "text"
regex: *not_empty_parameter
restrictions: *disable_influxdb_control
restrictions: *disable_influxdb_parameters
influxdb_password:
value: 'lmapass'
label: 'InfluxDB password'
@ -112,4 +112,4 @@ attributes:
weight: 85
type: "password"
regex: *not_empty_parameter
restrictions: *disable_influxdb_control
restrictions: *disable_influxdb_parameters