From 59cf993b60ef8ccdf25ed8bbbca517f0704031ce Mon Sep 17 00:00:00 2001 From: Dougal Matthews Date: Fri, 2 Mar 2018 15:48:46 +0000 Subject: [PATCH] Allow configuring the new notifier settings This change adds four new parameters for the new notifier added in the Mistral Rocky release. Change-Id: I005a49d21842661e944f45d44f08bf6bcec0a2a5 --- manifests/notifier.pp | 46 +++++++++++++++++++ .../add-notfier-support-1e0645068547f64f.yaml | 3 ++ spec/classes/mistral_notifier_spec.rb | 43 +++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 manifests/notifier.pp create mode 100644 releasenotes/notes/add-notfier-support-1e0645068547f64f.yaml create mode 100644 spec/classes/mistral_notifier_spec.rb diff --git a/manifests/notifier.pp b/manifests/notifier.pp new file mode 100644 index 0000000..ec6e924 --- /dev/null +++ b/manifests/notifier.pp @@ -0,0 +1,46 @@ +# == Class: mistral::notifier +# +# Configure the mistral notifier +# +# === Parameters +# +# [*type*] +# Type of notifier. Use local to run the notifier within the +# engine server. Use remote if the notifier is launched as +# a separate server to process events. +# (string value) +# Defaults to $::os_service_default. +# [*host*] +# Name of the notifier node. This can be an opaque +# identifier. It is not necessarily a hostname, +# FQDN, or IP address. +# (string value) +# Defaults to $::os_service_default. +# [*topic*] +# The message topic that the notifier server listens on. +# (string value) +# Defaults to $::os_service_default. +# [*notify_publishers*] +# List of publishers to publish notification. +# Note: This maps to the mistral config option `notify` but this is reserved +# in Puppet. +# (list of dicts) +# Defaults to $::os_service_default. + +class mistral::notifier( + $type = $::os_service_default, + $host = $::os_service_default, + $topic = $::os_service_default, + $notify_publishers = $::os_service_default, +) { + + include ::mistral::deps + include ::mistral::params + + mistral_config { + 'notifier/type': value => $type; + 'notifier/host': value => $host; + 'notifier/topic': value => $topic; + 'notifier/notify': value => $notify_publishers; + } +} diff --git a/releasenotes/notes/add-notfier-support-1e0645068547f64f.yaml b/releasenotes/notes/add-notfier-support-1e0645068547f64f.yaml new file mode 100644 index 0000000..69ceda8 --- /dev/null +++ b/releasenotes/notes/add-notfier-support-1e0645068547f64f.yaml @@ -0,0 +1,3 @@ +--- +features: + - Add new parameters that allow configuring notifier settings. diff --git a/spec/classes/mistral_notifier_spec.rb b/spec/classes/mistral_notifier_spec.rb new file mode 100644 index 0000000..5fd1aad --- /dev/null +++ b/spec/classes/mistral_notifier_spec.rb @@ -0,0 +1,43 @@ +require 'spec_helper' + +describe 'mistral::notifier' do + + shared_examples_for 'mistral notifier' do + it 'configure notifier default params' do + is_expected.to contain_mistral_config('notifier/type').with_value('') + is_expected.to contain_mistral_config('notifier/host').with_value('') + is_expected.to contain_mistral_config('notifier/topic').with_value('') + is_expected.to contain_mistral_config('notifier/notify').with_value('') + end + + context 'with specific parameters' do + let :params do + { :type => "remote", + :host => "localhost", + :topic => "mistral-event-stream", + :notify_publishers => "[{'type': 'noop'}]", + } + end + + it 'configure notifier params' do + is_expected.to contain_mistral_config('notifier/type').with_value('remote') + is_expected.to contain_mistral_config('notifier/host').with_value('localhost') + is_expected.to contain_mistral_config('notifier/topic').with_value('mistral-event-stream') + is_expected.to contain_mistral_config('notifier/notify').with_value("[{'type': 'noop'}]") + end + end + end + + on_supported_os({ + :supported_os => OSDefaults.get_supported_os + }).each do |os,facts| + context "on #{os}" do + let (:facts) do + facts.merge!(OSDefaults.get_facts()) + end + + it_configures 'mistral notifier' + end + end + +end