Configure compute params in config

Add a way to pass instance_discovery_method param to
override in the ceilo compute agent config.

Change-Id: Id7bd49510c0be76ed3f940c91108659beb440afb
This commit is contained in:
Pradeep Kilambi 2017-01-16 13:15:03 -05:00
parent 306c6d660d
commit 9cf46cbf92
5 changed files with 76 additions and 10 deletions

View File

@ -17,16 +17,29 @@
# (Optional) ensure state for package.
# Defaults to 'present'.
#
# [*instance_discovery_method*]
# (Optional) method to discovery instances running on compute node
# Defaults to $::os_service_default
# * naive: poll nova to get all instances
# * workload_partitioning: poll nova to get instances of the compute
# * libvirt_metadata: get instances from libvirt metadata
# but without instance metadata (recommended for Gnocchi backend).
#
class ceilometer::agent::compute (
$manage_service = true,
$enabled = true,
$package_ensure = 'present',
$manage_service = true,
$enabled = true,
$package_ensure = 'present',
$instance_discovery_method = $::os_service_default,
) inherits ceilometer {
warning('This class is deprecated. Please use ceilometer::agent::polling with compute namespace instead.')
include ::ceilometer::params
ceilometer_config {
'compute/instance_discovery_method': value => $instance_discovery_method,
}
Ceilometer_config<||> ~> Service['ceilometer-agent-compute']
Package['ceilometer-agent-compute'] -> Service['ceilometer-agent-compute']

View File

@ -32,14 +32,23 @@
# (Optional) The url to use for distributed group membership coordination.
# Defaults to undef.
#
# [*instance_discovery_method*]
# (Optional) method to discovery instances running on compute node
# Defaults to $::os_service_default
# * naive: poll nova to get all instances
# * workload_partitioning: poll nova to get instances of the compute
# * libvirt_metadata: get instances from libvirt metadata
# but without instance metadata (recommended for Gnocchi backend).
#
class ceilometer::agent::polling (
$manage_service = true,
$enabled = true,
$package_ensure = 'present',
$central_namespace = true,
$compute_namespace = true,
$ipmi_namespace = true,
$coordination_url = undef,
$manage_service = true,
$enabled = true,
$package_ensure = 'present',
$central_namespace = true,
$compute_namespace = true,
$ipmi_namespace = true,
$coordination_url = undef,
$instance_discovery_method = $::os_service_default,
) inherits ceilometer {
include ::ceilometer::deps
@ -65,6 +74,10 @@ class ceilometer::agent::polling (
Package <| title == 'ceilometer-common' |> -> User['ceilometer']
Package <| title == 'nova-common' |> -> Package['ceilometer-common']
ceilometer_config {
'compute/instance_discovery_method': value => $instance_discovery_method,
}
}
if $ipmi_namespace {

View File

@ -0,0 +1,9 @@
---
features:
- Add instance_discovery_method to ceilometer agent compute and polling
classes so this option is configurable.
upgrade:
- When upgrading, ensure that you dont have both the agent compute as well
as the polling classes initialized as that would trigger a duplicate
declaration. Ceilometer::agent::compute is deprecated and will be removed
in pike release.

View File

@ -28,6 +28,10 @@ describe 'ceilometer::agent::compute' do
)
end
it 'configures agent compute default instance discovery' do
is_expected.to contain_ceilometer_config('compute/instance_discovery_method').with_value('<SERVICE DEFAULT>')
end
it 'adds ceilometer user to nova group and, if required, to libvirt group' do
if platform_params[:libvirt_group]
is_expected.to contain_user('ceilometer').with_groups(['nova', "#{platform_params[:libvirt_group]}"])
@ -68,6 +72,18 @@ describe 'ceilometer::agent::compute' do
end
end
context 'when setting instance_discovery_method' do
before do
params.merge!({ :instance_discovery_method => 'naive' })
end
it 'configures agent compute instance discovery' do
is_expected.to contain_ceilometer_config('compute/instance_discovery_method').with_value('naive')
end
end
context 'with disabled service managing' do
before do
params.merge!({

View File

@ -38,6 +38,10 @@ describe 'ceilometer::agent::polling' do
:before => /Package\[ceilometer-common\]/
)
end
it 'configures agent compute' do
is_expected.to contain_ceilometer_config('compute/instance_discovery_method').with_value('<SERVICE DEFAULT>')
end
end
it 'installs ceilometer-polling package' do
@ -71,6 +75,17 @@ describe 'ceilometer::agent::polling' do
end
end
context 'when setting instance_discovery_method' do
before do
params.merge!({ :instance_discovery_method => 'naive' })
end
it 'configures agent compute instance discovery' do
is_expected.to contain_ceilometer_config('compute/instance_discovery_method').with_value('naive')
end
end
context 'with central and ipmi polling namespaces disabled' do
before do
params.merge!({