From 9cf46cbf926cc0db197d61305f93ac938df25464 Mon Sep 17 00:00:00 2001 From: Pradeep Kilambi Date: Mon, 16 Jan 2017 13:15:03 -0500 Subject: [PATCH] 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 --- manifests/agent/compute.pp | 19 ++++++++++--- manifests/agent/polling.pp | 27 ++++++++++++++----- ...ce-discovery-methods-5d4dde0ebf4cec28.yaml | 9 +++++++ spec/classes/ceilometer_agent_compute_spec.rb | 16 +++++++++++ spec/classes/ceilometer_agent_polling_spec.rb | 15 +++++++++++ 5 files changed, 76 insertions(+), 10 deletions(-) create mode 100644 releasenotes/notes/add-instance-discovery-methods-5d4dde0ebf4cec28.yaml diff --git a/manifests/agent/compute.pp b/manifests/agent/compute.pp index f4ce50c6..c7714a01 100644 --- a/manifests/agent/compute.pp +++ b/manifests/agent/compute.pp @@ -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'] diff --git a/manifests/agent/polling.pp b/manifests/agent/polling.pp index ae24c04e..801de26b 100644 --- a/manifests/agent/polling.pp +++ b/manifests/agent/polling.pp @@ -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 { diff --git a/releasenotes/notes/add-instance-discovery-methods-5d4dde0ebf4cec28.yaml b/releasenotes/notes/add-instance-discovery-methods-5d4dde0ebf4cec28.yaml new file mode 100644 index 00000000..379c2bb2 --- /dev/null +++ b/releasenotes/notes/add-instance-discovery-methods-5d4dde0ebf4cec28.yaml @@ -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. diff --git a/spec/classes/ceilometer_agent_compute_spec.rb b/spec/classes/ceilometer_agent_compute_spec.rb index 6824e385..2aed15ac 100644 --- a/spec/classes/ceilometer_agent_compute_spec.rb +++ b/spec/classes/ceilometer_agent_compute_spec.rb @@ -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('') + 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!({ diff --git a/spec/classes/ceilometer_agent_polling_spec.rb b/spec/classes/ceilometer_agent_polling_spec.rb index 3848e5d8..cf236357 100644 --- a/spec/classes/ceilometer_agent_polling_spec.rb +++ b/spec/classes/ceilometer_agent_polling_spec.rb @@ -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('') + 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!({