]> review.fuel-infra Code Review - puppet-modules/puppet-ceilometer.git/commitdiff
Introduce ceilometer:config to manage custom options
authorXingchao Yu <xingchao@unitedstack.com>
Thu, 3 Apr 2014 11:24:03 +0000 (19:24 +0800)
committerXingchao Yu <xingchao@unitedstack.com>
Tue, 22 Apr 2014 03:39:24 +0000 (11:39 +0800)
This ceilometer::config is aim to use ceilometer_config resource
to manage custom configurations in ceilometer.conf.

This will make end user easy to add their own custom options
in Hiera data.

Fully implements blueprint ceilometer-custom-config

Change-Id: I82b38ca26d4d99471a74b2c116e4c4133262187c

manifests/config.pp [new file with mode: 0644]
spec/classes/ceilometer_config_spec.rb [new file with mode: 0644]

diff --git a/manifests/config.pp b/manifests/config.pp
new file mode 100644 (file)
index 0000000..c1d1332
--- /dev/null
@@ -0,0 +1,31 @@
+# == Class: ceilometer::config
+#
+# This class is used to manage arbitrary ceilometer configurations.
+#
+# === Parameters
+#
+# [*ceilometer_config*]
+#   (optional) Allow configuration of ceilometer.conf.
+#
+#   The value is an hash of ceilometer_config resource. Example:
+#   { 'DEFAULT/foo' => { value => 'fooValue'},
+#     'DEFAULT/bar' => { value => 'barValue'}
+#   }
+#
+#   In yaml format, Example:
+#   ceilometer_config:
+#     DEFAULT/foo:
+#       value: fooValue
+#     DEFAULT/bar:
+#       value: barValue
+#
+#   NOTE: The configuration MUST NOT be already handled by this module
+#   or Puppet catalog compilation will fail with duplicate resources.
+#
+class ceilometer::config (
+  $ceilometer_config         = {},
+) {
+  validate_hash($ceilometer_config)
+
+  create_resources('ceilometer_config', $ceilometer_config)
+}
diff --git a/spec/classes/ceilometer_config_spec.rb b/spec/classes/ceilometer_config_spec.rb
new file mode 100644 (file)
index 0000000..33e9603
--- /dev/null
@@ -0,0 +1,29 @@
+require 'spec_helper'
+
+describe 'ceilometer::config' do
+
+  let :params do
+    { :ceilometer_config  => {
+                              'api/host' => { 'value' => '0.0.0.0'},
+                              'api/port' => { 'value' => '8777'},
+                             },
+    }
+  end
+
+    it 'with [api] options ceilometer_config ' do
+      should contain_ceilometer_config('api/host').with_value('0.0.0.0')
+      should contain_ceilometer_config('api/port').with_value('8777')
+    end
+
+  describe 'with [rpc_notifier2] options ceilometer_config' do
+    before do
+      params.merge!({
+        :ceilometer_config => { 'rpc_notifier2/topics' => { 'value' => 'notifications'},},
+      })
+    end
+    it 'should configure rpc_notifier2 topics correctly' do
+      should contain_ceilometer_config('rpc_notifier2/topics').with_value('notifications')
+    end
+
+  end
+end