Add support for ceilometer-polling agent
Add ability to use new ceilometer-polling agent instead of ceilometer-central, ceilometer-compute or ceilometer-ipmi. Specify central_namespace, compute_namespace and ipmi_namespace parameters to set namespaces Change-Id: I066f601a5234cb689c98e8eea2b5790bdaa5b8b5
This commit is contained in:
parent
bc443c3248
commit
85c742cd83
@ -41,14 +41,38 @@ node default {
|
||||
auth_password => 'tralalerotralala'
|
||||
}
|
||||
|
||||
# Install compute agent
|
||||
# default: enable
|
||||
class { 'ceilometer::agent::compute':
|
||||
# Install polling agent
|
||||
# Can be used instead of central, compute or ipmi agent
|
||||
# class { 'ceilometer::agent::polling':
|
||||
# central_namespace => true,
|
||||
# compute_namespace => false,
|
||||
# ipmi_namespace => false
|
||||
# }
|
||||
# class { 'ceilometer::agent::polling':
|
||||
# central_namespace => false,
|
||||
# compute_namespace => true,
|
||||
# ipmi_namespace => false
|
||||
# }
|
||||
# class { 'ceilometer::agent::polling':
|
||||
# central_namespace => false,
|
||||
# compute_namespace => false,
|
||||
# ipmi_namespace => true
|
||||
# }
|
||||
# As default use central and compute polling namespaces
|
||||
class { 'ceilometer::agent::polling':
|
||||
central_namespace => true,
|
||||
compute_namespace => true,
|
||||
ipmi_namespace => false,
|
||||
}
|
||||
|
||||
# Install central agent
|
||||
class { 'ceilometer::agent::central':
|
||||
}
|
||||
# Install compute agent (deprecated)
|
||||
# default: enable
|
||||
# class { 'ceilometer::agent::compute':
|
||||
# }
|
||||
|
||||
# Install central agent (deprecated)
|
||||
# class { 'ceilometer::agent::central':
|
||||
# }
|
||||
|
||||
# Install alarm notifier
|
||||
class { 'ceilometer::alarm::notifier':
|
||||
|
@ -20,6 +20,8 @@ class ceilometer::agent::compute (
|
||||
$package_ensure = 'present',
|
||||
) inherits ceilometer {
|
||||
|
||||
warning('This class is deprecated. Please use ceilometer::agent::polling with compute namespace instead.')
|
||||
|
||||
include ceilometer::params
|
||||
|
||||
Ceilometer_config<||> ~> Service['ceilometer-agent-compute']
|
||||
|
132
manifests/agent/polling.pp
Normal file
132
manifests/agent/polling.pp
Normal file
@ -0,0 +1,132 @@
|
||||
# Installs/configures the ceilometer polling agent
|
||||
#
|
||||
# == Parameters
|
||||
# [*enabled*]
|
||||
# (optional) Should the service be enabled.
|
||||
# Defaults to true.
|
||||
#
|
||||
# [*manage_service*]
|
||||
# (optional) Whether the service should be managed by Puppet.
|
||||
# Defaults to true.
|
||||
#
|
||||
# [*package_ensure*]
|
||||
# (optional) ensure state for package.
|
||||
# Defaults to 'present'
|
||||
#
|
||||
# [*central_namespace*]
|
||||
# (optional) Use central namespace for polling agent.
|
||||
# Defaults to true.
|
||||
#
|
||||
# [*compute_namespace*]
|
||||
# (optional) Use compute namespace for polling agent.
|
||||
# Defaults to true.
|
||||
#
|
||||
# [*ipmi_namespace*]
|
||||
# (optional) Use ipmi namespace for polling agent.
|
||||
# Defaults to true.
|
||||
#
|
||||
# [*coordination_url*]
|
||||
# (optional) The url to use for distributed group membership coordination.
|
||||
# Defaults to undef.
|
||||
#
|
||||
|
||||
class ceilometer::agent::polling (
|
||||
$manage_service = true,
|
||||
$enabled = true,
|
||||
$package_ensure = 'present',
|
||||
$central_namespace = true,
|
||||
$compute_namespace = true,
|
||||
$ipmi_namespace = true,
|
||||
$coordination_url = undef,
|
||||
) inherits ceilometer {
|
||||
|
||||
include ceilometer::params
|
||||
|
||||
if $central_namespace {
|
||||
$central_namespace_name = 'central'
|
||||
}
|
||||
|
||||
if $compute_namespace {
|
||||
if $::ceilometer::params::libvirt_group {
|
||||
User['ceilometer'] {
|
||||
groups => ['nova', $::ceilometer::params::libvirt_group]
|
||||
}
|
||||
} else {
|
||||
User['ceilometer'] {
|
||||
groups => ['nova']
|
||||
}
|
||||
}
|
||||
|
||||
#NOTE(dprince): This is using a custom (inline) file_line provider
|
||||
# until this lands upstream:
|
||||
# https://github.com/puppetlabs/puppetlabs-stdlib/pull/174
|
||||
Nova_config<| |> {
|
||||
before +> File_line_after[
|
||||
'nova-notification-driver-common',
|
||||
'nova-notification-driver-ceilometer'
|
||||
],
|
||||
}
|
||||
|
||||
file_line_after {
|
||||
'nova-notification-driver-common':
|
||||
line =>
|
||||
'notification_driver=nova.openstack.common.notifier.rpc_notifier',
|
||||
path => '/etc/nova/nova.conf',
|
||||
after => '^\s*\[DEFAULT\]',
|
||||
notify => Service['nova-compute'];
|
||||
'nova-notification-driver-ceilometer':
|
||||
line => 'notification_driver=ceilometer.compute.nova_notifier',
|
||||
path => '/etc/nova/nova.conf',
|
||||
after => '^\s*\[DEFAULT\]',
|
||||
notify => Service['nova-compute'];
|
||||
}
|
||||
|
||||
$compute_namespace_name = 'compute'
|
||||
|
||||
Package['nova-common'] -> Package['ceilometer-common']
|
||||
}
|
||||
|
||||
if $ipmi_namespace {
|
||||
$ipmi_namespace_name = 'ipmi'
|
||||
}
|
||||
|
||||
if $manage_service {
|
||||
if $enabled {
|
||||
$service_ensure = 'running'
|
||||
} else {
|
||||
$service_ensure = 'stopped'
|
||||
}
|
||||
}
|
||||
|
||||
$namespaces = [$central_namespace_name, $compute_namespace_name, $ipmi_namespace_name]
|
||||
$namespaces_real = inline_template('<%= @namespaces.find_all {|x| x !~ /^undef/ }.join "," %>')
|
||||
|
||||
package { 'ceilometer-polling':
|
||||
ensure => $package_ensure,
|
||||
name => $::ceilometer::params::agent_polling_package_name,
|
||||
}
|
||||
|
||||
if $namespaces_real {
|
||||
ceilometer_config {
|
||||
'DEFAULT/polling_namespaces': value => $namespaces_real
|
||||
}
|
||||
}
|
||||
|
||||
Ceilometer_config<||> ~> Service['ceilometer-polling']
|
||||
Package['ceilometer-polling'] -> Service['ceilometer-polling']
|
||||
Package['ceilometer-common'] -> Service['ceilometer-polling']
|
||||
|
||||
service { 'ceilometer-polling':
|
||||
ensure => $service_ensure,
|
||||
name => $::ceilometer::params::agent_polling_service_name,
|
||||
enable => $enabled,
|
||||
hasstatus => true,
|
||||
hasrestart => true,
|
||||
}
|
||||
|
||||
if $coordination_url {
|
||||
ceilometer_config {
|
||||
'coordination/backend_url': value => $coordination_url
|
||||
}
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ class ceilometer::params {
|
||||
# package names
|
||||
$agent_central_package_name = 'openstack-ceilometer-central'
|
||||
$agent_compute_package_name = 'openstack-ceilometer-compute'
|
||||
$agent_polling_package_name = 'openstack-ceilometer-polling'
|
||||
$api_package_name = 'openstack-ceilometer-api'
|
||||
$collector_package_name = 'openstack-ceilometer-collector'
|
||||
$agent_notification_package_name = 'openstack-ceilometer-notification'
|
||||
@ -20,6 +21,7 @@ class ceilometer::params {
|
||||
# service names
|
||||
$agent_central_service_name = 'openstack-ceilometer-central'
|
||||
$agent_compute_service_name = 'openstack-ceilometer-compute'
|
||||
$agent_polling_service_name = 'openstack-ceilometer-polling'
|
||||
$api_service_name = 'openstack-ceilometer-api'
|
||||
$collector_service_name = 'openstack-ceilometer-collector'
|
||||
$alarm_notifier_service_name = 'openstack-ceilometer-alarm-notifier'
|
||||
@ -35,6 +37,7 @@ class ceilometer::params {
|
||||
# package names
|
||||
$agent_central_package_name = 'ceilometer-agent-central'
|
||||
$agent_compute_package_name = 'ceilometer-agent-compute'
|
||||
$agent_polling_package_name = 'ceilometer-polling'
|
||||
$api_package_name = 'ceilometer-api'
|
||||
$collector_package_name = 'ceilometer-collector'
|
||||
$agent_notification_package_name = 'ceilometer-agent-notification'
|
||||
@ -44,6 +47,7 @@ class ceilometer::params {
|
||||
# service names
|
||||
$agent_central_service_name = 'ceilometer-agent-central'
|
||||
$agent_compute_service_name = 'ceilometer-agent-compute'
|
||||
$agent_polling_service_name = 'ceilometer-polling'
|
||||
$collector_service_name = 'ceilometer-collector'
|
||||
$api_service_name = 'ceilometer-api'
|
||||
$agent_notification_service_name = 'ceilometer-agent-notification'
|
||||
|
156
spec/classes/ceilometer_agent_polling_spec.rb
Normal file
156
spec/classes/ceilometer_agent_polling_spec.rb
Normal file
@ -0,0 +1,156 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'ceilometer::agent::polling' do
|
||||
|
||||
let :pre_condition do
|
||||
"include nova\n" +
|
||||
"include nova::compute\n" +
|
||||
"class { 'ceilometer': metering_secret => 's3cr3t' }"
|
||||
end
|
||||
|
||||
let :params do
|
||||
{ :enabled => true,
|
||||
:manage_service => true,
|
||||
:package_ensure => 'latest',
|
||||
:central_namespace => true,
|
||||
:compute_namespace => true,
|
||||
:ipmi_namespace => true,
|
||||
:coordination_url => 'redis://localhost:6379',
|
||||
}
|
||||
end
|
||||
|
||||
shared_examples_for 'ceilometer-polling' do
|
||||
|
||||
it { should contain_class('ceilometer::params') }
|
||||
|
||||
context 'when compute_namespace => true' do
|
||||
it 'adds ceilometer user to nova group and, if required, to libvirt group' do
|
||||
if platform_params[:libvirt_group]
|
||||
should contain_user('ceilometer').with_groups(['nova', "#{platform_params[:libvirt_group]}"])
|
||||
else
|
||||
should contain_user('ceilometer').with_groups('nova')
|
||||
end
|
||||
end
|
||||
|
||||
it 'ensures nova-common is installed before the package ceilometer-common' do
|
||||
should contain_package('nova-common').with(
|
||||
:before => /Package\[ceilometer-common\]/
|
||||
)
|
||||
end
|
||||
|
||||
it 'configures nova notification driver' do
|
||||
should contain_file_line_after('nova-notification-driver-common').with(
|
||||
:line => 'notification_driver=nova.openstack.common.notifier.rpc_notifier',
|
||||
:path => '/etc/nova/nova.conf',
|
||||
:notify => 'Service[nova-compute]'
|
||||
)
|
||||
should contain_file_line_after('nova-notification-driver-ceilometer').with(
|
||||
:line => 'notification_driver=ceilometer.compute.nova_notifier',
|
||||
:path => '/etc/nova/nova.conf',
|
||||
:notify => 'Service[nova-compute]'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
it 'installs ceilometer-polling package' do
|
||||
should contain_package('ceilometer-polling').with(
|
||||
:ensure => 'latest',
|
||||
:name => platform_params[:agent_package_name],
|
||||
:before => /Service\[ceilometer-polling\]/
|
||||
)
|
||||
end
|
||||
|
||||
it 'configures central agent' do
|
||||
should contain_ceilometer_config('DEFAULT/polling_namespaces').with_value('central,compute,ipmi')
|
||||
end
|
||||
|
||||
it 'ensures ceilometer-common is installed before the service' do
|
||||
should contain_package('ceilometer-common').with(
|
||||
:before => /Service\[ceilometer-polling\]/
|
||||
)
|
||||
end
|
||||
|
||||
[{:enabled => true}, {:enabled => false}].each do |param_hash|
|
||||
context "when service should be #{param_hash[:enabled] ? 'enabled' : 'disabled'}" do
|
||||
before do
|
||||
params.merge!(param_hash)
|
||||
end
|
||||
|
||||
it 'configures ceilometer-polling service' do
|
||||
should contain_service('ceilometer-polling').with(
|
||||
:ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped',
|
||||
:name => platform_params[:agent_service_name],
|
||||
:enable => params[:enabled],
|
||||
:hasstatus => true,
|
||||
:hasrestart => true
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with disabled service managing' do
|
||||
before do
|
||||
params.merge!({
|
||||
:manage_service => false,
|
||||
:enabled => false })
|
||||
end
|
||||
|
||||
it 'configures ceilometer-polling service' do
|
||||
should contain_service('ceilometer-polling').with(
|
||||
:ensure => nil,
|
||||
:name => platform_params[:agent_service_name],
|
||||
:enable => false,
|
||||
:hasstatus => true,
|
||||
:hasrestart => true
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
it 'configures central agent' do
|
||||
should contain_ceilometer_config('coordination/backend_url').with_value( params[:coordination_url] )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ :agent_package_name => 'ceilometer-polling',
|
||||
:agent_service_name => 'ceilometer-polling' }
|
||||
end
|
||||
|
||||
context 'on Ubuntu operating systems' do
|
||||
before do
|
||||
facts.merge!( :operatingsystem => 'Ubuntu' )
|
||||
platform_params.merge!( :libvirt_group => 'libvirtd' )
|
||||
end
|
||||
|
||||
it_configures 'ceilometer-polling'
|
||||
end
|
||||
|
||||
context 'on other operating systems' do
|
||||
before do
|
||||
platform_params.merge!( :libvirt_group => 'libvirt' )
|
||||
end
|
||||
|
||||
it_configures 'ceilometer-polling'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ :agent_package_name => 'openstack-ceilometer-polling',
|
||||
:agent_service_name => 'openstack-ceilometer-polling' }
|
||||
end
|
||||
|
||||
it_configures 'ceilometer-polling'
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user