From 5553f8df5051d817d8ef7e05e7c595a48912e355 Mon Sep 17 00:00:00 2001 From: Vinay Kapalavai Date: Thu, 6 Jun 2019 20:38:04 +0000 Subject: [PATCH] Revert "Refactor collectd/gnocchi integration" This reverts commit 2a9f0d89f10216f5d3915555f1b57faa9cddf8bc. Closes-Bug: #1831893 Change-Id: I8a06c25d9ef73d72c5ea30086ffa340d82ab1dfe --- manifests/profile/base/metrics/collectd.pp | 61 +----------------- .../profile/base/metrics/collectd/gnocchi.pp | 37 ++--------- templates/collectd/collectd-gnocchi.conf.erb | 62 +++++++++++++++++++ 3 files changed, 69 insertions(+), 91 deletions(-) create mode 100644 templates/collectd/collectd-gnocchi.conf.erb diff --git a/manifests/profile/base/metrics/collectd.pp b/manifests/profile/base/metrics/collectd.pp index 8b94bd249..38ad82ccd 100644 --- a/manifests/profile/base/metrics/collectd.pp +++ b/manifests/profile/base/metrics/collectd.pp @@ -142,57 +142,6 @@ # (Optional) Boolean. Whether let collectd enable manage repositories. # If it is set to true the epel repository will be used # -# [*amqp_transport_name*] -# (Optional) String. Name of the transport. -# Default to 'metrics' -# -# [*amqp_host*] -# (Optional) String. Hostname or IP address of the AMQP 1.0 intermediary. -# Defaults to the undef -# -# [*amqp_port*] -# (Optional) String. Service name or port number on which the AMQP 1.0 -# intermediary accepts connections. This argument must be a string, -# even if the numeric form is used. -# Defaults to undef -# -# [*amqp_user*] -# (Optional) String. User part of credentials used to authenticate to the -# AMQP 1.0 intermediary. -# Defaults to undef -# -# [*amqp_password*] -# (Optional) String. Password part of credentials used to authenticate -# to the AMQP 1.0 intermediary. -# Defaults to undef -# -# [*amqp_address*] -# (Optional) String. This option specifies the prefix for the send-to value -# in the message. -# Defaults to 'collectd' -# -# [*amqp_retry_delay*] -# (Optional) Number. When the AMQP1 connection is lost, defines the time -# in seconds to wait before attempting to reconnect. If not set 1 second -# is the implicit default. -# Defaults to undef -# -# [*amqp_interval*] -# (Optional) Number. Interval on which metrics should be sent to AMQP -# intermediary. If not set the default for all collectd plugins is used. -# Defaults to undef -# -# [*amqp_instances*] -# (Optional) Hash of hashes. Each inner hash represent Instance block in plugin -# configuration file. Key of outter hash represents instance name. -# 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')), @@ -223,20 +172,12 @@ class tripleo::profile::base::metrics::collectd ( $gnocchi_resource_type = 'collectd', $gnocchi_batch_size = 10, $service_names = hiera('service_names', []), - $collectd_manage_repo = false, - $python_read_plugins = [] + $collectd_manage_repo = false ) { 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 } diff --git a/manifests/profile/base/metrics/collectd/gnocchi.pp b/manifests/profile/base/metrics/collectd/gnocchi.pp index 06ec79bae..4a6253f3a 100644 --- a/manifests/profile/base/metrics/collectd/gnocchi.pp +++ b/manifests/profile/base/metrics/collectd/gnocchi.pp @@ -139,39 +139,14 @@ define tripleo::profile::base::metrics::collectd::gnocchi ( ) { include ::collectd - package { 'python-collectd-gnocchi': + package { ['python-collectd-gnocchi', 'collectd-python']: ensure => $ensure, } - $_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.') + collectd::plugin { 'python': + ensure => $ensure, + order => $order, + content => template('tripleo/collectd/collectd-gnocchi.conf.erb'), + require => Package['python-collectd-gnocchi'] } - - $config = $conf.filter |$key, $value| { $value != undef } - ::collectd::plugin::python::module { 'collectd_gnocchi': - config => [$config] - } - } diff --git a/templates/collectd/collectd-gnocchi.conf.erb b/templates/collectd/collectd-gnocchi.conf.erb new file mode 100644 index 000000000..a0aab160a --- /dev/null +++ b/templates/collectd/collectd-gnocchi.conf.erb @@ -0,0 +1,62 @@ + + Import "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 -%> + +