Merge "Add mistral::executor class"
This commit is contained in:
commit
3594ef5505
90
manifests/executor.pp
Normal file
90
manifests/executor.pp
Normal file
@ -0,0 +1,90 @@
|
||||
# == Class: mistral::executor
|
||||
#
|
||||
# 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 executor 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 executor listens on. (string value)
|
||||
# Defaults to $::os_service_default.
|
||||
#
|
||||
# [*version*]
|
||||
# (Optional) The version of the executor. (string value)
|
||||
# Defaults to $::os_service_default.
|
||||
#
|
||||
# [*evaluation_interval*]
|
||||
# (Optional) How often will the executions be evaluated
|
||||
# (in minutes). For example for value 120 the interval
|
||||
# will be 2 hours (every 2 hours).
|
||||
# Defaults to $::os_service_default.
|
||||
#
|
||||
# [*older_than*]
|
||||
# (Optional) Evaluate from which time remove executions in minutes.
|
||||
# For example when older_than = 60, remove all executions
|
||||
# that finished a 60 minutes ago or more.
|
||||
# Minimum value is 1.
|
||||
# Note that only final state execution will remove (SUCCESS/ERROR).
|
||||
# Defaults to $::os_service_default.
|
||||
#
|
||||
class mistral::executor (
|
||||
$package_ensure = present,
|
||||
$manage_service = true,
|
||||
$enabled = true,
|
||||
$host = $::os_service_default,
|
||||
$topic = $::os_service_default,
|
||||
$version = $::os_service_default,
|
||||
$evaluation_interval = $::os_service_default,
|
||||
$older_than = $::os_service_default,
|
||||
) {
|
||||
|
||||
include ::mistral
|
||||
include ::mistral::params
|
||||
|
||||
package { 'mistral-executor':
|
||||
ensure => $package_ensure,
|
||||
name => $::mistral::params::executor_package_name,
|
||||
tag => ['openstack', 'mistral-package'],
|
||||
}
|
||||
|
||||
if $manage_service {
|
||||
if $enabled {
|
||||
$service_ensure = 'running'
|
||||
} else {
|
||||
$service_ensure = 'stopped'
|
||||
}
|
||||
}
|
||||
|
||||
service { 'mistral-executor':
|
||||
ensure => $service_ensure,
|
||||
name => $::mistral::params::executor_service_name,
|
||||
enable => $enabled,
|
||||
hasstatus => true,
|
||||
hasrestart => true,
|
||||
tag => 'mistral-service',
|
||||
}
|
||||
|
||||
mistral_config {
|
||||
'executor/host' : value => $host;
|
||||
'executor/topic' : value => $topic;
|
||||
'executor/version' : value => $version;
|
||||
'execution_expiration_policy/evaluation_interval' : value => $evaluation_interval;
|
||||
'execution_expiration_policy/older_than' : value => $older_than;
|
||||
}
|
||||
|
||||
}
|
@ -17,6 +17,8 @@ class mistral::params {
|
||||
$api_service_name = 'openstack-mistral-api'
|
||||
$engine_package_name = 'openstack-mistral-engine'
|
||||
$engine_service_name = 'openstack-mistral-engine'
|
||||
$executor_package_name = 'openstack-mistral-executor'
|
||||
$executor_service_name = 'openstack-mistral-executor'
|
||||
}
|
||||
'Debian': {
|
||||
$common_package_name = 'mistral'
|
||||
@ -24,6 +26,8 @@ class mistral::params {
|
||||
$api_service_name = 'mistral-api'
|
||||
$engine_package_name = 'mistral-engine'
|
||||
$engine_service_name = 'mistral-engine'
|
||||
$executor_package_name = 'mistral-executor'
|
||||
$executor_service_name = 'mistral-executor'
|
||||
}
|
||||
default: {
|
||||
fail("Unsupported osfamily: ${::osfamily} operatingsystem: \
|
||||
|
98
spec/classes/mistral_executor_spec.rb
Normal file
98
spec/classes/mistral_executor_spec.rb
Normal file
@ -0,0 +1,98 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'mistral::executor' do
|
||||
|
||||
let :params do
|
||||
{ :enabled => true,
|
||||
:manage_service => true,
|
||||
:host => true,
|
||||
:topic => true,
|
||||
:version => true,
|
||||
:evaluation_interval => 1234,
|
||||
:older_than => 60}
|
||||
end
|
||||
|
||||
shared_examples_for 'mistral-executor' do
|
||||
|
||||
context 'config params' do
|
||||
|
||||
it { is_expected.to contain_class('mistral') }
|
||||
it { is_expected.to contain_class('mistral::params') }
|
||||
|
||||
it { is_expected.to contain_mistral_config('executor/host').with_value( params[:host] ) }
|
||||
it { is_expected.to contain_mistral_config('executor/topic').with_value( params[:topic] ) }
|
||||
it { is_expected.to contain_mistral_config('executor/version').with_value( params[:version] ) }
|
||||
it { is_expected.to contain_mistral_config('execution_expiration_policy/evaluation_interval').with_value( params[:evaluation_interval] ) }
|
||||
it { is_expected.to contain_mistral_config('execution_expiration_policy/older_than').with_value( params[:older_than] ) }
|
||||
|
||||
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-executor service' do
|
||||
|
||||
is_expected.to contain_service('mistral-executor').with(
|
||||
:ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped',
|
||||
:name => platform_params[:executor_service_name],
|
||||
:enable => params[:enabled],
|
||||
:hasstatus => true,
|
||||
:hasrestart => true,
|
||||
:tag => 'mistral-service',
|
||||
)
|
||||
is_expected.to contain_service('mistral-executor').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-executor service' do
|
||||
|
||||
is_expected.to contain_service('mistral-executor').with(
|
||||
:ensure => nil,
|
||||
:name => platform_params[:executor_service_name],
|
||||
:enable => false,
|
||||
:hasstatus => true,
|
||||
:hasrestart => true,
|
||||
:tag => 'mistral-service',
|
||||
)
|
||||
is_expected.to contain_service('mistral-executor').that_subscribes_to(nil)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ :executor_service_name => 'mistral-executor' }
|
||||
end
|
||||
|
||||
it_configures 'mistral-executor'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ :executor_service_name => 'openstack-mistral-executor' }
|
||||
end
|
||||
|
||||
it_configures 'mistral-executor'
|
||||
end
|
||||
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user