Browse Source

Added support for messaging urls

Ceilometer supports multiple notifications. The config
entry in ceilometer.conf allows for a multi-value for
notification/messaging_urls.

Change-Id: Ic1791c7021bf2dbb06269317b8495eebc8d6e7ed
Closes-Bug: 1564061
changes/46/304346/8
Matthew J Black 6 years ago
parent
commit
fd4485d64e
  1. 10
      lib/puppet/provider/ceilometer_config/ini_setting.rb
  2. 13
      lib/puppet/provider/ceilometer_config/openstackconfig.rb
  3. 14
      lib/puppet/type/ceilometer_config.rb
  4. 8
      manifests/agent/notification.pp
  5. 4
      manifests/config.pp
  6. 4
      releasenotes/notes/added_messaging_urls-fbf1309bf1bfafa4.yaml
  7. 6
      releasenotes/notes/ceilometer_notifications_messaging_urls-62b27d617a49c609.yaml
  8. 13
      spec/classes/ceilometer_agent_notification_spec.rb
  9. 2
      spec/unit/provider/ceilometer_config/openstackconfig_spec.rb
  10. 4
      spec/unit/type/ceilometer_config_spec.rb

10
lib/puppet/provider/ceilometer_config/ini_setting.rb

@ -1,10 +0,0 @@
Puppet::Type.type(:ceilometer_config).provide(
:ini_setting,
:parent => Puppet::Type.type(:openstack_config).provider(:ini_setting)
) do
def self.file_path
'/etc/ceilometer/ceilometer.conf'
end
end

13
lib/puppet/provider/ceilometer_config/openstackconfig.rb

@ -0,0 +1,13 @@
Puppet::Type.type(:ceilometer_config).provide(
:openstackconfig,
:parent => Puppet::Type.type(:openstack_config).provider(:ruby)
) do
def self.file_path
'/etc/ceilometer/ceilometer.conf'
end
def file_path
self.class.file_path
end
end

14
lib/puppet/type/ceilometer_config.rb

@ -7,8 +7,20 @@ Puppet::Type.newtype(:ceilometer_config) do
newvalues(/\S+\/\S+/)
end
newproperty(:value) do
newproperty(:value, :array_matching => :all) do
desc 'The value of the setting to be defined.'
def insync?(is)
puts is
return true if @should.empty?
return false unless is.is_a? Array
return false unless is.length == @should.length
# we don't care about the order of items in array, hence
# it is necessary to override insync
return (
is & @should == is or
is & @should.map(&:to_s) == is
)
end
munge do |value|
value = value.to_s.strip
value.capitalize! if value =~ /^(true|false)$/i

8
manifests/agent/notification.pp

@ -48,6 +48,11 @@
# (Optional) Number of workers for notification service (integer value).
# Defaults to $::os_service_default.
#
# [*messaging_urls*]
# (Optional) Messaging urls to listen for notifications. (Array of urls)
# The format should be transport://user:pass@host1:port[,hostN:portN]/virtual_host
# Defaults to $::os_service_default.
#
# [*package_ensure*]
# (Optional) ensure state for package.
# Defaults to 'present'.
@ -59,6 +64,7 @@ class ceilometer::agent::notification (
$store_events = false,
$disable_non_metric_meters = $::os_service_default,
$notification_workers = $::os_service_default,
$messaging_urls = $::os_service_default,
$package_ensure = 'present',
) {
@ -99,6 +105,6 @@ class ceilometer::agent::notification (
'notification/store_events' : value => $store_events;
'notification/disable_non_metric_meters': value => $disable_non_metric_meters;
'notification/workers' : value => $notification_workers;
'notification/messaging_urls' : value => $messaging_urls;
}
}

4
manifests/config.pp

@ -26,8 +26,8 @@
# or Puppet catalog compilation will fail with duplicate resources.
#
class ceilometer::config (
$ceilometer_config = {},
$ceilometer_api_paste_ini = {},
$ceilometer_config = {},
$ceilometer_api_paste_ini = {},
) {
validate_hash($ceilometer_config)

4
releasenotes/notes/added_messaging_urls-fbf1309bf1bfafa4.yaml

@ -0,0 +1,4 @@
---
features:
- Added messaging_urls parameter to ceilometer agents notification.
The parameter accepts an array.

6
releasenotes/notes/ceilometer_notifications_messaging_urls-62b27d617a49c609.yaml

@ -0,0 +1,6 @@
---
features:
- Switched ceilometer_config from ini_setting type to openstack_config type.
- Added the ability to pass in messaging_urls into notifications agent. This
will allow a user to configure ceilometer to talk to different virtualhosts
or entirely different messaging queues.

13
spec/classes/ceilometer_agent_notification_spec.rb

@ -98,6 +98,19 @@ describe 'ceilometer::agent::notification' do
end
end
context 'with multiple messaging urls' do
before do
params.merge!({
:messaging_urls => ['rabbit://rabbit_user:password@localhost/nova',
'rabbit://rabbit_user:password@localhost/neutron'] })
end
it 'configures two messaging urls' do
is_expected.to contain_ceilometer_config('notification/messaging_urls').with_value(
['rabbit://rabbit_user:password@localhost/nova', 'rabbit://rabbit_user:password@localhost/neutron']
)
end
end
end
context 'on Debian platforms' do

2
spec/unit/provider/ceilometer_config/ini_setting_spec.rb → spec/unit/provider/ceilometer_config/openstackconfig_spec.rb

@ -23,7 +23,7 @@ $LOAD_PATH.push(
require 'spec_helper'
provider_class = Puppet::Type.type(:ceilometer_config).provider(:ini_setting)
provider_class = Puppet::Type.type(:ceilometer_config).provider(:openstackconfig)
describe provider_class do

4
spec/unit/type/ceilometer_config_spec.rb

@ -30,12 +30,12 @@ describe 'Puppet::Type.type(:ceilometer_config)' do
it 'should accept a valid value' do
@ceilometer_config[:value] = 'bar'
expect(@ceilometer_config[:value]).to eq('bar')
expect(@ceilometer_config[:value]).to eq(['bar'])
end
it 'should not accept a value with whitespace' do
@ceilometer_config[:value] = 'b ar'
expect(@ceilometer_config[:value]).to eq('b ar')
expect(@ceilometer_config[:value]).to eq(['b ar'])
end
it 'should accept valid ensure values' do

Loading…
Cancel
Save