Implement applier and decision-engine
Change-Id: I00854d1281c083df36997e2c907e3a7bd353551d
This commit is contained in:
parent
c5ddc31f46
commit
11d3887da2
87
manifests/applier.pp
Normal file
87
manifests/applier.pp
Normal file
@ -0,0 +1,87 @@
|
||||
# == Class: watcher::applier
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*package_ensure*]
|
||||
# (Optional) The state of the package.
|
||||
# Defaults to 'present'.
|
||||
#
|
||||
# [*enabled*]
|
||||
# (Optional) The state of the service
|
||||
# Defaults to 'true'.
|
||||
#
|
||||
# [*manage_service*]
|
||||
# (Optional) Whether to start/stop the service.
|
||||
# Defaults to 'true'.
|
||||
#
|
||||
# [*applier_workers*]
|
||||
# (Optional) Number of workers for watcher applier service.
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*applier_conductor_topic*]
|
||||
# (Optional) The topic name used forcontrol events, this topic used
|
||||
# for rpc call
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*applier_status_topic*]
|
||||
# (Optional) The topic name used for status events, this topic is used
|
||||
# so as to notifythe others components of the system
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*applier_publisher_id*]
|
||||
# (Optional) The identifier used by watcher module on the message broker
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*applier_workflow_engine*]
|
||||
# (Optional) Select the engine to use to execute the workflow
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
class watcher::applier (
|
||||
$package_ensure = 'present',
|
||||
$enabled = true,
|
||||
$manage_service = true,
|
||||
$applier_workers = $::os_service_default,
|
||||
$applier_conductor_topic = $::os_service_default,
|
||||
$applier_status_topic = $::os_service_default,
|
||||
$applier_publisher_id = $::os_service_default,
|
||||
$applier_workflow_engine = $::os_service_default,
|
||||
) {
|
||||
|
||||
include ::watcher::params
|
||||
include ::watcher::deps
|
||||
|
||||
Watcher_config<||> ~> Service['watcher-applier']
|
||||
|
||||
Package['watcher-applier'] -> Service['watcher-applier']
|
||||
package { 'watcher-applier':
|
||||
ensure => $package_ensure,
|
||||
name => $::watcher::params::applier_package_name,
|
||||
tag => ['openstack', 'watcher-package'],
|
||||
}
|
||||
|
||||
if $manage_service {
|
||||
if $enabled {
|
||||
$service_ensure = 'running'
|
||||
} else {
|
||||
$service_ensure = 'stopped'
|
||||
}
|
||||
}
|
||||
|
||||
service { 'watcher-applier':
|
||||
ensure => $service_ensure,
|
||||
name => $::watcher::params::applier_service_name,
|
||||
enable => $enabled,
|
||||
hasstatus => true,
|
||||
hasrestart => true,
|
||||
tag => ['watcher-service'],
|
||||
}
|
||||
|
||||
watcher_config {
|
||||
'watcher_applier/workers': value => $applier_workers;
|
||||
'watcher_applier/conductor_topic': value => $applier_conductor_topic;
|
||||
'watcher_applier/status_topic': value => $applier_status_topic;
|
||||
'watcher_applier/publisher_id': value => $applier_publisher_id;
|
||||
'watcher_applier/workflow_engine': value => $applier_workflow_engine;
|
||||
}
|
||||
|
||||
}
|
82
manifests/decision_engine.pp
Normal file
82
manifests/decision_engine.pp
Normal file
@ -0,0 +1,82 @@
|
||||
# == Class: watcher::decision_engine
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*package_ensure*]
|
||||
# (Optional) The state of the package.
|
||||
# Defaults to 'present'.
|
||||
#
|
||||
# [*enabled*]
|
||||
# (Optional) The state of the service
|
||||
# Defaults to 'true'.
|
||||
#
|
||||
# [*manage_service*]
|
||||
# (Optional) Whether to start/stop the service.
|
||||
# Defaults to 'true'.
|
||||
#
|
||||
# [*decision_engine_conductor_topic*]
|
||||
# (Optional) The topic name used forcontrol events, this topic used
|
||||
# for rpc call
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*decision_engine_status_topic*]
|
||||
# (Optional) The topic name used for status events, this topic is used
|
||||
# so as to notifythe others components of the system
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*decision_engine_publisher_id*]
|
||||
# (Optional) The identifier used by watcher module on the message broker
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*decision_engine_workers*]
|
||||
# (Optional) The maximum number of threads that can be used to execute
|
||||
# strategies
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
class watcher::decision_engine (
|
||||
$package_ensure = 'present',
|
||||
$enabled = true,
|
||||
$manage_service = true,
|
||||
$decision_engine_conductor_topic = $::os_service_default,
|
||||
$decision_engine_status_topic = $::os_service_default,
|
||||
$decision_engine_publisher_id = $::os_service_default,
|
||||
$decision_engine_workers = $::os_service_default,
|
||||
) {
|
||||
|
||||
include ::watcher::params
|
||||
include ::watcher::deps
|
||||
|
||||
Watcher_config<||> ~> Service['watcher-decision-engine']
|
||||
|
||||
Package['watcher-decision-engine'] -> Service['watcher-decision-engine']
|
||||
package { 'watcher-decision-engine':
|
||||
ensure => $package_ensure,
|
||||
name => $::watcher::params::decision_engine_package_name,
|
||||
tag => ['openstack', 'watcher-package'],
|
||||
}
|
||||
|
||||
if $manage_service {
|
||||
if $enabled {
|
||||
$service_ensure = 'running'
|
||||
} else {
|
||||
$service_ensure = 'stopped'
|
||||
}
|
||||
}
|
||||
|
||||
service { 'watcher-decision-engine':
|
||||
ensure => $service_ensure,
|
||||
name => $::watcher::params::decision_engine_service_name,
|
||||
enable => $enabled,
|
||||
hasstatus => true,
|
||||
hasrestart => true,
|
||||
tag => ['watcher-service'],
|
||||
}
|
||||
|
||||
watcher_config {
|
||||
'watcher_decision_engine/conductor_topic': value => $decision_engine_conductor_topic;
|
||||
'watcher_decision_engine/status_topic': value => $decision_engine_status_topic;
|
||||
'watcher_decision_engine/publisher_id': value => $decision_engine_publisher_id;
|
||||
'watcher_decision_engine/max_workers': value => $decision_engine_workers;
|
||||
}
|
||||
|
||||
}
|
@ -5,14 +5,22 @@ class watcher::params {
|
||||
|
||||
case $::osfamily {
|
||||
'RedHat': {
|
||||
$api_service_name = 'openstack-watcher-api'
|
||||
$api_package_name = 'openstack-watcher-api'
|
||||
$common_package_name = 'openstack-watcher-common'
|
||||
$api_service_name = 'openstack-watcher-api'
|
||||
$api_package_name = 'openstack-watcher-api'
|
||||
$common_package_name = 'openstack-watcher-common'
|
||||
$applier_package_name = 'openstack-watcher-applier'
|
||||
$applier_service_name = 'openstack-watcher-applier'
|
||||
$decision_engine_package_name = 'openstack-watcher-decision-engine'
|
||||
$decision_engine_service_name = 'openstack-watcher-decision-engine'
|
||||
}
|
||||
'Debian': {
|
||||
$api_service_name = 'watcher-api'
|
||||
$api_package_name = 'watcher-api'
|
||||
$common_package_name = 'watcher-common'
|
||||
$api_service_name = 'watcher-api'
|
||||
$api_package_name = 'watcher-api'
|
||||
$common_package_name = 'watcher-common'
|
||||
$applier_package_name = 'watcher-applier'
|
||||
$applier_service_name = 'watcher-applier'
|
||||
$decision_engine_package_name = 'watcher-decision-engine'
|
||||
$decision_engine_service_name = 'watcher-decision-engine'
|
||||
}
|
||||
default: {
|
||||
fail("Unsupported osfamily: ${::osfamily} operatingsystem")
|
||||
|
@ -54,6 +54,12 @@ describe 'basic watcher' do
|
||||
create_db_schema => true,
|
||||
upgrade_db => true,
|
||||
}
|
||||
class { '::watcher::applier':
|
||||
applier_workers => '2',
|
||||
}
|
||||
class { '::watcher::decision_engine':
|
||||
decision_engine_workers => '2',
|
||||
}
|
||||
}
|
||||
EOS
|
||||
|
||||
|
93
spec/classes/watcher_applier_spec.rb
Normal file
93
spec/classes/watcher_applier_spec.rb
Normal file
@ -0,0 +1,93 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'watcher::applier' do
|
||||
|
||||
shared_examples 'watcher-applier' do
|
||||
|
||||
context 'with default parameters' do
|
||||
|
||||
it 'installs packages' do
|
||||
is_expected.to contain_package('watcher-applier').with(
|
||||
:name => platform_params[:watcher_applier_package],
|
||||
:ensure => 'present',
|
||||
:tag => ['openstack', 'watcher-package']
|
||||
)
|
||||
end
|
||||
|
||||
it 'configures watcher applier service' do
|
||||
is_expected.to contain_watcher_config('watcher_applier/workers').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_watcher_config('watcher_applier/conductor_topic').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_watcher_config('watcher_applier/status_topic').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_watcher_config('watcher_applier/publisher_id').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_watcher_config('watcher_applier/workflow_engine').with_value('<SERVICE DEFAULT>')
|
||||
end
|
||||
end
|
||||
|
||||
[{:enabled => true}, {:enabled => false}].each do |param_hash|
|
||||
context "when service should be #{param_hash[:enabled] ? 'enabled' : 'disabled'}" do
|
||||
let :params do
|
||||
{ :enabled => true,
|
||||
:manage_service => true,
|
||||
}
|
||||
end
|
||||
before do
|
||||
params.merge!(param_hash)
|
||||
end
|
||||
|
||||
it 'configures watcher applier service' do
|
||||
is_expected.to contain_service('watcher-applier').with(
|
||||
:ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped',
|
||||
:name => platform_params[:applier_service_name],
|
||||
:enable => params[:enabled],
|
||||
:hasstatus => true,
|
||||
:hasrestart => true,
|
||||
:tag => ['watcher-service'],
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with overridden parameters' do
|
||||
let :params do
|
||||
{
|
||||
:package_ensure => '2012.1.1-15.el6',
|
||||
:applier_workers => '10',
|
||||
:applier_conductor_topic => 'applier123',
|
||||
:applier_status_topic => 'someStatus',
|
||||
:applier_publisher_id => '20120101',
|
||||
:applier_workflow_engine => 'taskFloooow',
|
||||
}
|
||||
end
|
||||
it 'configures watcher applier' do
|
||||
is_expected.to contain_watcher_config('watcher_applier/workers').with_value('10')
|
||||
is_expected.to contain_watcher_config('watcher_applier/conductor_topic').with_value('applier123')
|
||||
is_expected.to contain_watcher_config('watcher_applier/status_topic').with_value('someStatus')
|
||||
is_expected.to contain_watcher_config('watcher_applier/publisher_id').with_value('20120101')
|
||||
is_expected.to contain_watcher_config('watcher_applier/workflow_engine').with_value('taskFloooow')
|
||||
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'
|
||||
{ :watcher_applier_package => 'watcher-applier',
|
||||
:applier_service_name => 'watcher-applier',
|
||||
}
|
||||
when 'RedHat'
|
||||
{ :watcher_applier_package => 'openstack-watcher-applier',
|
||||
:applier_service_name => 'openstack-watcher-applier',
|
||||
}
|
||||
end
|
||||
end
|
||||
it_behaves_like 'watcher-applier'
|
||||
end
|
||||
end
|
||||
end
|
91
spec/classes/watcher_decision_engine_spec.rb
Normal file
91
spec/classes/watcher_decision_engine_spec.rb
Normal file
@ -0,0 +1,91 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'watcher::decision_engine' do
|
||||
|
||||
shared_examples 'watcher-decision-engine' do
|
||||
|
||||
context 'with default parameters' do
|
||||
|
||||
it 'installs packages' do
|
||||
is_expected.to contain_package('watcher-decision-engine').with(
|
||||
:name => platform_params[:watcher_decision_engine_package],
|
||||
:ensure => 'present',
|
||||
:tag => ['openstack', 'watcher-package']
|
||||
)
|
||||
end
|
||||
|
||||
it 'configures watcher decision engine service' do
|
||||
is_expected.to contain_watcher_config('watcher_decision_engine/conductor_topic').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_watcher_config('watcher_decision_engine/status_topic').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_watcher_config('watcher_decision_engine/publisher_id').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_watcher_config('watcher_decision_engine/max_workers').with_value('<SERVICE DEFAULT>')
|
||||
end
|
||||
end
|
||||
|
||||
[{:enabled => true}, {:enabled => false}].each do |param_hash|
|
||||
context "when service should be #{param_hash[:enabled] ? 'enabled' : 'disabled'}" do
|
||||
let :params do
|
||||
{ :enabled => true,
|
||||
:manage_service => true,
|
||||
}
|
||||
end
|
||||
before do
|
||||
params.merge!(param_hash)
|
||||
end
|
||||
|
||||
it 'configures watcher decision engine service' do
|
||||
is_expected.to contain_service('watcher-decision-engine').with(
|
||||
:ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped',
|
||||
:name => platform_params[:decision_engine_service_name],
|
||||
:enable => params[:enabled],
|
||||
:hasstatus => true,
|
||||
:hasrestart => true,
|
||||
:tag => ['watcher-service'],
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with overridden parameters' do
|
||||
let :params do
|
||||
{
|
||||
:package_ensure => '2012.1.1-15.el6',
|
||||
:decision_engine_conductor_topic => 'test_conductor_topic',
|
||||
:decision_engine_status_topic => 'niceTopic',
|
||||
:decision_engine_publisher_id => '123456',
|
||||
:decision_engine_workers => '10',
|
||||
}
|
||||
end
|
||||
it 'configures watcher decision engine' do
|
||||
is_expected.to contain_watcher_config('watcher_decision_engine/conductor_topic').with_value('test_conductor_topic')
|
||||
is_expected.to contain_watcher_config('watcher_decision_engine/status_topic').with_value('niceTopic')
|
||||
is_expected.to contain_watcher_config('watcher_decision_engine/publisher_id').with_value('123456')
|
||||
is_expected.to contain_watcher_config('watcher_decision_engine/max_workers').with_value('10')
|
||||
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'
|
||||
{ :watcher_decision_engine_package => 'watcher-decision-engine',
|
||||
:decision_engine_service_name => 'watcher-decision-engine',
|
||||
}
|
||||
when 'RedHat'
|
||||
{ :watcher_decision_engine_package => 'openstack-watcher-decision-engine',
|
||||
:decision_engine_service_name => 'openstack-watcher-decision-engine',
|
||||
}
|
||||
end
|
||||
end
|
||||
it_behaves_like 'watcher-decision-engine'
|
||||
end
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user