Refactor collectd/gnocchi integration
Current implementation of collect_gnocchi plugin configuration blocks usage of other python-based plugins. This patch leverages puppet-collectd classes properly to enable configuration of more than one python-based plugin together. Change-Id: I248859bf0e4b70e3a057e96b5fb74be64f4008ed
This commit is contained in:
parent
c9d107c368
commit
cfa969dac6
@ -188,6 +188,11 @@
|
||||
# The 'address' value concatenated with the 'name' given will be used
|
||||
# as the send-to address for communications over the messaging link.
|
||||
# Defaults to {}.
|
||||
#
|
||||
# [*python_read_plugins*]
|
||||
# (Optional) List of strings. List of third party python packages to install.
|
||||
# Defaults to [].
|
||||
#
|
||||
class tripleo::profile::base::metrics::collectd (
|
||||
$step = Integer(hiera('step')),
|
||||
|
||||
@ -227,12 +232,20 @@ class tripleo::profile::base::metrics::collectd (
|
||||
$amqp_retry_delay = undef,
|
||||
$amqp_interval = undef,
|
||||
$service_names = hiera('service_names', []),
|
||||
$collectd_manage_repo = false
|
||||
$collectd_manage_repo = false,
|
||||
$python_read_plugins = []
|
||||
) {
|
||||
if $step >= 3 {
|
||||
class {'::collectd':
|
||||
manage_repo => $collectd_manage_repo
|
||||
}
|
||||
|
||||
include ::collectd::plugin::python
|
||||
$python_packages = concat(['collectd-python'], $python_read_plugins)
|
||||
package { $python_packages:
|
||||
ensure => 'present'
|
||||
}
|
||||
|
||||
if $enable_file_logging {
|
||||
include ::collectd::plugin::logfile
|
||||
}
|
||||
|
@ -139,14 +139,39 @@ define tripleo::profile::base::metrics::collectd::gnocchi (
|
||||
) {
|
||||
include ::collectd
|
||||
|
||||
package { ['python-collectd-gnocchi', 'collectd-python']:
|
||||
package { 'python-collectd-gnocchi':
|
||||
ensure => $ensure,
|
||||
}
|
||||
|
||||
collectd::plugin { 'python':
|
||||
ensure => $ensure,
|
||||
order => $order,
|
||||
content => template('tripleo/collectd/collectd-gnocchi.conf.erb'),
|
||||
require => Package['python-collectd-gnocchi']
|
||||
$_conf = {'Auth_Mode' => $auth_mode, 'ResourceType' => $resource_type, 'BatchSize' => $batch_size}
|
||||
if $auth_mode == 'basic' {
|
||||
$conf = merge($_conf, {
|
||||
'Endpoint' => "${protocol}://${server}:${port}",
|
||||
'User' => $user
|
||||
})
|
||||
} elsif $auth_mode == 'keystone' {
|
||||
$conf = merge($_conf, {
|
||||
'Auth_Url' => $keystone_auth_url,
|
||||
'Username' => $keystone_user_name,
|
||||
'User_Id' => $keystone_user_id,
|
||||
'Project_Id' => $keystone_project_id,
|
||||
'Project_Name' => $keystone_project_name,
|
||||
'Password' => $keystone_password,
|
||||
'User_Domain_Id' => $keystone_user_domain_id,
|
||||
'User_Domain_Name' => $keystone_user_domain_name,
|
||||
'Project_Domain_Id' => $keystone_project_domain_id,
|
||||
'Project_Domain_Name' => $keystone_project_domain_name,
|
||||
'Region_Name' => $keystone_region_name,
|
||||
'Interface' => $keystone_interface,
|
||||
'Endpoint' => $keystone_endpoint
|
||||
})
|
||||
} else {
|
||||
fail('Invalid auth mode for collect_gnocchi plugin.')
|
||||
}
|
||||
|
||||
$config = $conf.filter |$key, $value| { $value != undef }
|
||||
::collectd::plugin::python::module { 'collectd_gnocchi':
|
||||
config => [$config]
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,62 +0,0 @@
|
||||
<Plugin "python">
|
||||
Import "collectd_gnocchi"
|
||||
<Module "collectd_gnocchi">
|
||||
<%- if @auth_mode == 'basic' %>
|
||||
### Basic authentication
|
||||
Endpoint "<%= @protocol %>://<%= @server %>:<%= @port %>"
|
||||
<%- if @user %>
|
||||
User "<%= @user %>"
|
||||
<%- end -%>
|
||||
<%- elsif @auth_mode == 'keystone' %>
|
||||
### Keystone authentication
|
||||
Auth_Mode "keystone"
|
||||
Auth_Url "<%= @keystone_auth_url %>"
|
||||
<%- if @keystone_user_name %>
|
||||
Username "<%= @keystone_user_name %>"
|
||||
<%- end -%>
|
||||
<%- if @keystone_user_id %>
|
||||
User_Id "<%= @keystone_user_id %>"
|
||||
<%- end -%>
|
||||
<%- if @keystone_project_id %>
|
||||
Project_Id "<%= @keystone_project_id %>"
|
||||
<%- end -%>
|
||||
<%- if @keystone_project_name %>
|
||||
Project_Name "<%= @keystone_project_name %>"
|
||||
<%- end -%>
|
||||
<%- if @keystone_password %>
|
||||
Password "<%= @keystone_password %>"
|
||||
<%- end -%>
|
||||
<%- if @keystone_user_domain_id %>
|
||||
User_Domain_Id "<%= @keystone_user_domain_id %>"
|
||||
<%- end -%>
|
||||
<%- if @keystone_user_domain_name %>
|
||||
User_Domain_Name "<%= @keystone_user_domain_name %>"
|
||||
<%- end -%>
|
||||
<%- if @keystone_project_domain_id %>
|
||||
Project_Domain_Id "<%= @keystone_project_domain_id %>"
|
||||
<%- end -%>
|
||||
<%- if @keystone_project_domain_name %>
|
||||
Project_Domain_Name "<%= @keystone_project_domain_name %>"
|
||||
<%- end -%>
|
||||
<%- if @keystone_region_name %>
|
||||
Region_Name "<%= @keystone_region_name %>"
|
||||
<%- end -%>
|
||||
<%- if @keystone_interface %>
|
||||
Interface "<%= @keystone_interface %>"
|
||||
<%- end -%>
|
||||
<%- if @keystone_endpoint %>
|
||||
Endpoint "<%= @keystone_endpoint %>"
|
||||
<%- end -%>
|
||||
<%- end -%>
|
||||
|
||||
<%- if @resource_type %>
|
||||
## Default resource type created by the plugin in Gnocchi
|
||||
## to store hosts
|
||||
ResourceType "<%= @resource_type %>"
|
||||
<%- end -%>
|
||||
<%- if @batch_size %>
|
||||
## Minimum number of values to batch
|
||||
BatchSize <%= @batch_size %>
|
||||
<%- end -%>
|
||||
</Module>
|
||||
</Plugin>
|
Loading…
x
Reference in New Issue
Block a user