Merge "Adding manage_service parameter to all services"

This commit is contained in:
Jenkins 2014-03-31 20:42:03 +00:00 committed by Gerrit Code Review
commit 6e63bc4b1a
7 changed files with 99 additions and 14 deletions

View File

@ -0,0 +1,40 @@
# Example: managing cinder controller services with pacemaker
#
# By setting enabled to false, these services will not be started at boot. By setting
# manage_service to false, puppet will not kill these services on every run. This
# allows the Pacemaker resource manager to dynamically determine on which node each
# service should run.
#
# The puppet commands below would ideally be applied to at least three nodes.
#
# Note that cinder-api is associated with the virtual IP address as
# it is called from external services. The remaining services connect to the
# database and/or message broker independently.
#
# Example pacemaker resource configuration commands (configured once per cluster):
#
# sudo pcs resource create cinder_vip ocf:heartbeat:IPaddr2 params ip=192.0.2.3 \
# cidr_netmask=24 op monitor interval=10s
#
# sudo pcs resource create cinder_api_service lsb:openstack-cinder-api
# sudo pcs resource create cinder_scheduler_service lsb:openstack-cinder-scheduler
#
# sudo pcs constraint colocation add cinder_api_service with cinder_vip
class { 'cinder':
sql_connection => 'mysql://cinder:secret_block_password@openstack-controller.example.com/cinder',
}
class { 'cinder::api':
keystone_password => 'CINDER_PW',
keystone_user => 'cinder',
enabled => false,
manage_service => false,
}
class { 'cinder::scheduler':
scheduler_driver => 'cinder.scheduler.simple.SimpleScheduler',
enabled => false,
manage_service => false,
}

View File

@ -60,6 +60,10 @@
# (optional) The state of the service # (optional) The state of the service
# Defaults to true # Defaults to true
# #
# [*manage_service*]
# (optional) Whether to start/stop the service
# Defaults to true
#
# [*ratelimits*] # [*ratelimits*]
# (optional) The state of the service # (optional) The state of the service
# Defaults to undef. If undefined the default ratelimiting values are used. # Defaults to undef. If undefined the default ratelimiting values are used.
@ -83,6 +87,7 @@ class cinder::api (
$package_ensure = 'present', $package_ensure = 'present',
$bind_host = '0.0.0.0', $bind_host = '0.0.0.0',
$enabled = true, $enabled = true,
$manage_service = true,
$ratelimits = undef, $ratelimits = undef,
$ratelimits_factory = $ratelimits_factory =
'cinder.api.v1.limits:RateLimitingMiddleware.factory' 'cinder.api.v1.limits:RateLimitingMiddleware.factory'
@ -115,9 +120,13 @@ class cinder::api (
logoutput => 'on_failure', logoutput => 'on_failure',
require => Package['cinder'], require => Package['cinder'],
} }
$ensure = 'running' if $manage_service {
$ensure = 'running'
}
} else { } else {
$ensure = 'stopped' if $manage_service {
$ensure = 'stopped'
}
} }
service { 'cinder-api': service { 'cinder-api':

View File

@ -2,7 +2,8 @@
class cinder::scheduler ( class cinder::scheduler (
$scheduler_driver = false, $scheduler_driver = false,
$package_ensure = 'present', $package_ensure = 'present',
$enabled = true $enabled = true,
$manage_service = true
) { ) {
include cinder::params include cinder::params
@ -27,10 +28,12 @@ class cinder::scheduler (
} }
} }
if $enabled { if $manage_service {
$ensure = 'running' if $enabled {
} else { $ensure = 'running'
$ensure = 'stopped' } else {
$ensure = 'stopped'
}
} }
service { 'cinder-scheduler': service { 'cinder-scheduler':

View File

@ -1,7 +1,8 @@
# $volume_name_template = volume-%s # $volume_name_template = volume-%s
class cinder::volume ( class cinder::volume (
$package_ensure = 'present', $package_ensure = 'present',
$enabled = true $enabled = true,
$manage_service = true
) { ) {
include cinder::params include cinder::params
@ -21,10 +22,12 @@ class cinder::volume (
} }
} }
if $enabled { if $manage_service {
$ensure = 'running' if $enabled {
} else { $ensure = 'running'
$ensure = 'stopped' } else {
$ensure = 'stopped'
}
} }
service { 'cinder-volume': service { 'cinder-volume':
@ -34,5 +37,4 @@ class cinder::volume (
hasstatus => true, hasstatus => true,
require => Package['cinder'], require => Package['cinder'],
} }
} }

View File

@ -15,7 +15,8 @@ describe 'cinder::api' do
end end
it { should contain_service('cinder-api').with( it { should contain_service('cinder-api').with(
'hasstatus' => true 'hasstatus' => true,
'ensure' => 'running'
)} )}
it 'should configure cinder api correctly' do it 'should configure cinder api correctly' do
@ -138,11 +139,23 @@ describe 'cinder::api' do
let :params do let :params do
req_params.merge({'enabled' => false}) req_params.merge({'enabled' => false})
end end
it 'should stop the service' do
should contain_service('cinder-api').with_ensure('stopped')
end
it 'should contain db_sync exec' do it 'should contain db_sync exec' do
should_not contain_exec('cinder-manage db_sync') should_not contain_exec('cinder-manage db_sync')
end end
end end
describe 'with manage_service false' do
let :params do
req_params.merge({'manage_service' => false})
end
it 'should not change the state of the service' do
should contain_service('cinder-api').without_ensure
end
end
describe 'with ratelimits' do describe 'with ratelimits' do
let :params do let :params do
req_params.merge({ :ratelimits => '(GET, "*", .*, 100, MINUTE);(POST, "*", .*, 200, MINUTE)' }) req_params.merge({ :ratelimits => '(GET, "*", .*, 100, MINUTE);(POST, "*", .*, 200, MINUTE)' })

View File

@ -38,6 +38,16 @@ describe 'cinder::scheduler' do
it { should contain_cinder_config('DEFAULT/scheduler_driver').with_value('cinder.scheduler.filter_scheduler.FilterScheduler') } it { should contain_cinder_config('DEFAULT/scheduler_driver').with_value('cinder.scheduler.filter_scheduler.FilterScheduler') }
it { should contain_package('cinder-scheduler').with_ensure('present') } it { should contain_package('cinder-scheduler').with_ensure('present') }
end end
describe 'with manage_service false' do
let :params do
{ 'manage_service' => false
}
end
it 'should not change the state of the service' do
should contain_service('cinder-scheduler').without_ensure
end
end
end end

View File

@ -15,4 +15,12 @@ describe 'cinder::volume' do
'hasstatus' => true 'hasstatus' => true
)} )}
describe 'with manage_service false' do
let :params do
{ 'manage_service' => false }
end
it 'should not change the state of the service' do
should contain_service('cinder-volume').without_ensure
end
end
end end