Add support for event engine
Mistral now has an event engine used for triggering cron events. Let's use it. Change-Id: Icaef5e5732f98e9cc39ed1f024d715cee371acac
This commit is contained in:
parent
2fa3cd596f
commit
33c126e394
|
@ -0,0 +1,72 @@
|
|||
# == Class: mistral::engine
|
||||
#
|
||||
# Installs & configure the Mistral Engine service
|
||||
#
|
||||
# === 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'.
|
||||
#
|
||||
# [*host*]
|
||||
# (Optional) Name of the engine 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*]
|
||||
# (Optional) The message topic that the engine listens on.
|
||||
# Defaults to $::os_service_default.
|
||||
#
|
||||
# [*event_definitions_cfg_file*]
|
||||
# (Optional) The path to the event_definitions config file.
|
||||
# Defaults to $::os_service_default.
|
||||
#
|
||||
class mistral::event_engine (
|
||||
$package_ensure = present,
|
||||
$manage_service = true,
|
||||
$enabled = true,
|
||||
$host = $::os_service_default,
|
||||
$topic = $::os_service_default,
|
||||
$event_definitions_cfg_file = $::os_service_default,
|
||||
) {
|
||||
|
||||
include ::mistral::deps
|
||||
include ::mistral::params
|
||||
|
||||
package { 'mistral-event-engine':
|
||||
ensure => $package_ensure,
|
||||
name => $::mistral::params::event_engine_package_name,
|
||||
tag => ['openstack', 'mistral-package'],
|
||||
}
|
||||
|
||||
if $manage_service {
|
||||
if $enabled {
|
||||
$service_ensure = 'running'
|
||||
} else {
|
||||
$service_ensure = 'stopped'
|
||||
}
|
||||
}
|
||||
|
||||
service { 'mistral-event-engine':
|
||||
ensure => $service_ensure,
|
||||
name => $::mistral::params::event_engine_service_name,
|
||||
enable => $enabled,
|
||||
hasstatus => true,
|
||||
hasrestart => true,
|
||||
tag => 'mistral-service',
|
||||
}
|
||||
|
||||
mistral_config {
|
||||
'event_engine/host': value => $host;
|
||||
'event_engine/topic': value => $topic;
|
||||
'event_engine/event_definitions_cfg_file': value => $event_definitions_cfg_file;
|
||||
}
|
||||
|
||||
}
|
|
@ -18,6 +18,8 @@ class mistral::params {
|
|||
$engine_service_name = 'openstack-mistral-engine'
|
||||
$executor_package_name = 'openstack-mistral-executor'
|
||||
$executor_service_name = 'openstack-mistral-executor'
|
||||
$event_engine_package_name = 'openstack-mistral-event-engine'
|
||||
$event_engine_service_name = 'openstack-mistral-event-engine'
|
||||
$mistral_wsgi_script_path = '/var/www/cgi-bin/mistral'
|
||||
$mistral_wsgi_script_source = '/usr/bin/mistral-wsgi-api'
|
||||
}
|
||||
|
@ -29,6 +31,8 @@ class mistral::params {
|
|||
$engine_service_name = 'mistral-engine'
|
||||
$executor_package_name = 'mistral-executor'
|
||||
$executor_service_name = 'mistral-executor'
|
||||
$event_engine_package_name = 'mistral-event-engine'
|
||||
$event_engine_service_name = 'mistral-event-engine'
|
||||
$mistral_wsgi_script_path = '/usr/lib/cgi-bin/mistral'
|
||||
$mistral_wsgi_script_source = '/usr/bin/mistral-wsgi-api'
|
||||
}
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
features:
|
||||
- Add support for Mistral event engine.
|
||||
|
|
@ -55,6 +55,7 @@ describe 'basic mistral' do
|
|||
class { '::mistral::client': }
|
||||
class { '::mistral::engine': }
|
||||
class { '::mistral::executor': }
|
||||
class { '::mistral::event_engine': }
|
||||
}
|
||||
default: {
|
||||
fail("Unsupported osfamily (${::osfamily})")
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'mistral::event_engine' do
|
||||
|
||||
let :params do
|
||||
{ :enabled => true,
|
||||
:manage_service => true,
|
||||
:host => 'foo_host',
|
||||
:topic => 'foo_topic',
|
||||
:event_definitions_cfg_file => 'foo_cfg_file'}
|
||||
end
|
||||
|
||||
shared_examples_for 'mistral-event-engine' do
|
||||
|
||||
context 'config params' do
|
||||
|
||||
it { is_expected.to contain_class('mistral::params') }
|
||||
|
||||
it { is_expected.to contain_mistral_config('event_engine/host').with_value( params[:host] ) }
|
||||
it { is_expected.to contain_mistral_config('event_engine/topic').with_value( params[:topic] ) }
|
||||
it { is_expected.to contain_mistral_config('event_engine/event_definitions_cfg_file').with_value( params[:event_definitions_cfg_file] ) }
|
||||
|
||||
end
|
||||
|
||||
[{:enabled => true}, {:enabled => false}].each do |param_hash|
|
||||
context "when service should be #{param_hash[:enabled] ? 'enabled' : 'disabled'}" do
|
||||
before do
|
||||
params.merge!(param_hash)
|
||||
end
|
||||
|
||||
it 'configures mistral-event-engine service' do
|
||||
|
||||
is_expected.to contain_service('mistral-event-engine').with(
|
||||
:ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped',
|
||||
:name => platform_params[:event_engine_service_name],
|
||||
:enable => params[:enabled],
|
||||
:hasstatus => true,
|
||||
:hasrestart => true,
|
||||
:tag => 'mistral-service',
|
||||
)
|
||||
is_expected.to contain_service('mistral-event-engine').that_subscribes_to(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with disabled service managing' do
|
||||
before do
|
||||
params.merge!({
|
||||
:manage_service => false,
|
||||
:enabled => false })
|
||||
end
|
||||
|
||||
it 'configures mistral-event-engine service' do
|
||||
|
||||
is_expected.to contain_service('mistral-event-engine').with(
|
||||
:ensure => nil,
|
||||
:name => platform_params[:event_engine_service_name],
|
||||
:enable => false,
|
||||
:hasstatus => true,
|
||||
:hasrestart => true,
|
||||
:tag => 'mistral-service',
|
||||
)
|
||||
is_expected.to contain_service('mistral-event-engine').that_subscribes_to(nil)
|
||||
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
|
||||
|
||||
let(:platform_params) do
|
||||
case facts[:osfamily]
|
||||
when 'Debian'
|
||||
{ :event_engine_service_name => 'mistral-event-engine' }
|
||||
when 'RedHat'
|
||||
{ :event_engine_service_name => 'openstack-mistral-event-engine' }
|
||||
end
|
||||
end
|
||||
|
||||
it_configures 'mistral-event-engine'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue