Support dedicated mistral-notifier
mistral by default requires a dedicated notifier service. Change-Id: I546e0b38c69c8e5514e2bfe22396cc78ecbcf18e Signed-off-by: Takashi Kajinami <kajinamit@oss.nttdata.com>
This commit is contained in:
@@ -4,12 +4,24 @@
|
|||||||
#
|
#
|
||||||
# === Parameters
|
# === Parameters
|
||||||
#
|
#
|
||||||
|
# [*package_ensure*]
|
||||||
|
# (Optional) Ensure state for package.
|
||||||
|
# Defaults to present
|
||||||
|
#
|
||||||
|
# [*enabled*]
|
||||||
|
# (optional) Should the service be enabled.
|
||||||
|
# Defaults to true.
|
||||||
|
#
|
||||||
|
# [*manage_service*]
|
||||||
|
# (optional) Whether the service should be managed by Puppet.
|
||||||
|
# Defaults to true.
|
||||||
|
#
|
||||||
# [*type*]
|
# [*type*]
|
||||||
# (Optional) Type of notifier. Use local to run the notifier within
|
# (Optional) Type of notifier. Use local to run the notifier within
|
||||||
# the engine server. Use remote if the notifier is launched as a separate
|
# the engine server. Use remote if the notifier is launched as a separate
|
||||||
# server to process events.
|
# server to process events.
|
||||||
# (string value)
|
# (string value)
|
||||||
# Defaults to $facts['os_service_default'].
|
# Defaults to 'remote'.
|
||||||
#
|
#
|
||||||
# [*host*]
|
# [*host*]
|
||||||
# (Optional) Name of the notifier node. This can be an opaque identifier.
|
# (Optional) Name of the notifier node. This can be an opaque identifier.
|
||||||
@@ -30,15 +42,53 @@
|
|||||||
# Defaults to $facts['os_service_default'].
|
# Defaults to $facts['os_service_default'].
|
||||||
#
|
#
|
||||||
class mistral::notifier(
|
class mistral::notifier(
|
||||||
$type = $facts['os_service_default'],
|
$package_ensure = present,
|
||||||
$host = $facts['os_service_default'],
|
Boolean $manage_service = true,
|
||||||
$topic = $facts['os_service_default'],
|
Boolean $enabled = true,
|
||||||
$notify_publishers = $facts['os_service_default'],
|
Enum['local', 'remote'] $type = 'remote',
|
||||||
|
$host = $facts['os_service_default'],
|
||||||
|
$topic = $facts['os_service_default'],
|
||||||
|
$notify_publishers = $facts['os_service_default'],
|
||||||
) {
|
) {
|
||||||
|
|
||||||
include mistral::deps
|
include mistral::deps
|
||||||
include mistral::params
|
include mistral::params
|
||||||
|
|
||||||
|
if $::mistral::params::notifier_package_name {
|
||||||
|
package { 'mistral-notifier':
|
||||||
|
ensure => $package_ensure,
|
||||||
|
name => $::mistral::params::notifier_package_name,
|
||||||
|
tag => ['openstack', 'mistral-package'],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if $manage_service {
|
||||||
|
$enabled_real = $type ? {
|
||||||
|
'remote' => $enabled,
|
||||||
|
default => false,
|
||||||
|
}
|
||||||
|
|
||||||
|
if $enabled_real {
|
||||||
|
$service_ensure = 'running'
|
||||||
|
} else {
|
||||||
|
$service_ensure = 'stopped'
|
||||||
|
}
|
||||||
|
|
||||||
|
if $::mistral::params::notifier_service_name {
|
||||||
|
service { 'mistral-notifier':
|
||||||
|
ensure => $service_ensure,
|
||||||
|
name => $::mistral::params::notifier_service_name,
|
||||||
|
enable => $enabled_real,
|
||||||
|
hasstatus => true,
|
||||||
|
hasrestart => true,
|
||||||
|
tag => 'mistral-service',
|
||||||
|
}
|
||||||
|
Service['mistral-notifier'] -> Service<| title == 'mistral-engine' |>
|
||||||
|
} else {
|
||||||
|
warning('mistral-notifier service is not available')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mistral_config {
|
mistral_config {
|
||||||
'notifier/type': value => $type;
|
'notifier/type': value => $type;
|
||||||
'notifier/host': value => $host;
|
'notifier/host': value => $host;
|
||||||
|
@@ -22,6 +22,8 @@ class mistral::params {
|
|||||||
$executor_service_name = 'openstack-mistral-executor'
|
$executor_service_name = 'openstack-mistral-executor'
|
||||||
$event_engine_package_name = 'openstack-mistral-event-engine'
|
$event_engine_package_name = 'openstack-mistral-event-engine'
|
||||||
$event_engine_service_name = 'openstack-mistral-event-engine'
|
$event_engine_service_name = 'openstack-mistral-event-engine'
|
||||||
|
$notifier_package_name = 'openstack-mistral-notifier'
|
||||||
|
$notifier_service_name = 'openstack-mistral-notifier'
|
||||||
$mistral_wsgi_script_path = '/var/www/cgi-bin/mistral'
|
$mistral_wsgi_script_path = '/var/www/cgi-bin/mistral'
|
||||||
$mistral_wsgi_script_source = '/usr/bin/mistral-wsgi-api'
|
$mistral_wsgi_script_source = '/usr/bin/mistral-wsgi-api'
|
||||||
}
|
}
|
||||||
@@ -35,6 +37,8 @@ class mistral::params {
|
|||||||
$executor_service_name = 'mistral-executor'
|
$executor_service_name = 'mistral-executor'
|
||||||
$event_engine_package_name = 'mistral-event-engine'
|
$event_engine_package_name = 'mistral-event-engine'
|
||||||
$event_engine_service_name = 'mistral-event-engine'
|
$event_engine_service_name = 'mistral-event-engine'
|
||||||
|
$notifier_package_name = undef
|
||||||
|
$notifier_service_name = undef
|
||||||
$mistral_wsgi_script_path = '/usr/lib/cgi-bin/mistral'
|
$mistral_wsgi_script_path = '/usr/lib/cgi-bin/mistral'
|
||||||
$mistral_wsgi_script_source = '/usr/bin/mistral-wsgi-api'
|
$mistral_wsgi_script_source = '/usr/bin/mistral-wsgi-api'
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
The ``mistral::notifier`` class now installs and configures
|
||||||
|
the dedicated ``mistral-notifier`` service.
|
@@ -3,28 +3,95 @@ require 'spec_helper'
|
|||||||
describe 'mistral::notifier' do
|
describe 'mistral::notifier' do
|
||||||
|
|
||||||
shared_examples_for 'mistral::notifier' do
|
shared_examples_for 'mistral::notifier' do
|
||||||
it 'configure notifier default params' do
|
context 'with defaults' do
|
||||||
is_expected.to contain_mistral_config('notifier/type').with_value('<SERVICE DEFAULT>')
|
it 'configure notifier default params' do
|
||||||
is_expected.to contain_mistral_config('notifier/host').with_value('<SERVICE DEFAULT>')
|
is_expected.to contain_mistral_config('notifier/type').with_value('remote')
|
||||||
is_expected.to contain_mistral_config('notifier/topic').with_value('<SERVICE DEFAULT>')
|
is_expected.to contain_mistral_config('notifier/host').with_value('<SERVICE DEFAULT>')
|
||||||
is_expected.to contain_mistral_config('notifier/notify').with_value('<SERVICE DEFAULT>')
|
is_expected.to contain_mistral_config('notifier/topic').with_value('<SERVICE DEFAULT>')
|
||||||
|
is_expected.to contain_mistral_config('notifier/notify').with_value('<SERVICE DEFAULT>')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'installs mistral-notifier package' do
|
||||||
|
if platform_params.has_key?(:notifier_package_name)
|
||||||
|
is_expected.to contain_package('mistral-notifier').with(
|
||||||
|
:ensure => 'present',
|
||||||
|
:name => platform_params[:notifier_package_name],
|
||||||
|
:tag => ['openstack', 'mistral-package']
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'configures mistral-notifier service' do
|
||||||
|
if platform_params.has_key?(:notifier_service_name)
|
||||||
|
is_expected.to contain_service('mistral-notifier').with(
|
||||||
|
:ensure => 'running',
|
||||||
|
:name => platform_params[:notifier_service_name],
|
||||||
|
:enable => true,
|
||||||
|
:hasstatus => true,
|
||||||
|
:hasrestart => true,
|
||||||
|
:tag => 'mistral-service',
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with specific parameters' do
|
context 'with specific parameters' do
|
||||||
let :params do
|
let :params do
|
||||||
{ :type => "remote",
|
{ :type => 'local',
|
||||||
:host => "localhost",
|
:host => 'localhost',
|
||||||
:topic => "mistral-event-stream",
|
:topic => 'mistral-event-stream',
|
||||||
:notify_publishers => "[{'type': 'noop'}]",
|
:notify_publishers => '[{\'type\': \'noop\'}]',
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'configure notifier params' do
|
it 'configure notifier params' do
|
||||||
is_expected.to contain_mistral_config('notifier/type').with_value('remote')
|
is_expected.to contain_mistral_config('notifier/type').with_value('local')
|
||||||
is_expected.to contain_mistral_config('notifier/host').with_value('localhost')
|
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/topic').with_value('mistral-event-stream')
|
||||||
is_expected.to contain_mistral_config('notifier/notify').with_value("[{'type': 'noop'}]")
|
is_expected.to contain_mistral_config('notifier/notify').with_value("[{'type': 'noop'}]")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'disables mistral-notifier service' do
|
||||||
|
if platform_params.has_key?(:notifier_service_name)
|
||||||
|
is_expected.to contain_service('mistral-notifier').with(
|
||||||
|
:ensure => 'stopped',
|
||||||
|
:name => platform_params[:notifier_service_name],
|
||||||
|
:enable => false,
|
||||||
|
:hasstatus => true,
|
||||||
|
:hasrestart => true,
|
||||||
|
:tag => 'mistral-service',
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with service disabled' do
|
||||||
|
let :params do
|
||||||
|
{ :enabled => false }
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'configures mistral-notifier service' do
|
||||||
|
if platform_params.has_key?(:notifier_service_name)
|
||||||
|
is_expected.to contain_service('mistral-notifier').with(
|
||||||
|
:ensure => 'stopped',
|
||||||
|
:name => platform_params[:notifier_service_name],
|
||||||
|
:enable => false,
|
||||||
|
:hasstatus => true,
|
||||||
|
:hasrestart => true,
|
||||||
|
:tag => 'mistral-service',
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with service unmanaged' do
|
||||||
|
let :params do
|
||||||
|
{ :manage_service => false }
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does not configure mistral-notifier service' do
|
||||||
|
is_expected.to_not contain_service('mistral-notifier')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -36,6 +103,18 @@ describe 'mistral::notifier' do
|
|||||||
facts.merge!(OSDefaults.get_facts())
|
facts.merge!(OSDefaults.get_facts())
|
||||||
end
|
end
|
||||||
|
|
||||||
|
let (:platform_params) do
|
||||||
|
case facts[:os]['family']
|
||||||
|
when 'Debian'
|
||||||
|
{}
|
||||||
|
when 'RedHat'
|
||||||
|
{
|
||||||
|
:notifier_package_name => 'openstack-mistral-notifier',
|
||||||
|
:notifier_service_name => 'openstack-mistral-notifier'
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it_configures 'mistral::notifier'
|
it_configures 'mistral::notifier'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user