Merge "Refactor collectd/gnocchi integration"

This commit is contained in:
Zuul 2019-03-27 02:56:43 +00:00 committed by Gerrit Code Review
commit e1c0ef7d9f
3 changed files with 45 additions and 69 deletions

View File

@ -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
}

View File

@ -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]
}
}

View File

@ -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>