Create a sync_db boolean for Heat.

Other components offer the option to decide whether or not to run the
db sync command. Heat was missing this feature. This commit add this
feature for Heat.

Change-Id: I06b669123fe08e02c66ee34dab78a943ff5de90c
This commit is contained in:
Yanis Guenane 2015-04-04 13:40:45 +02:00
parent bbeb24c51a
commit 744f4bbcf5
9 changed files with 68 additions and 12 deletions

View File

@ -95,7 +95,7 @@ class heat::api (
hasrestart => true, hasrestart => true,
require => [Package['heat-common'], require => [Package['heat-common'],
Package['heat-api']], Package['heat-api']],
subscribe => Exec['heat-dbsync'], subscribe => $::heat::subscribe_sync_db,
} }
heat_config { heat_config {

View File

@ -98,7 +98,7 @@ class heat::api_cfn (
enable => $enabled, enable => $enabled,
hasstatus => true, hasstatus => true,
hasrestart => true, hasrestart => true,
subscribe => Exec['heat-dbsync'], subscribe => $::heat::subscribe_sync_db,
} }
heat_config { heat_config {

View File

@ -98,7 +98,7 @@ class heat::api_cloudwatch (
enable => $enabled, enable => $enabled,
hasstatus => true, hasstatus => true,
hasrestart => true, hasrestart => true,
subscribe => Exec['heat-dbsync'], subscribe => $::heat::subscribe_sync_db,
} }
heat_config { heat_config {

View File

@ -67,6 +67,7 @@ class heat::engine (
$configure_delegated_roles = true, #DEPRECATED $configure_delegated_roles = true, #DEPRECATED
) { ) {
include ::heat
include ::heat::params include ::heat::params
Heat_config<||> ~> Service['heat-engine'] Heat_config<||> ~> Service['heat-engine']
@ -77,7 +78,7 @@ class heat::engine (
ensure => installed, ensure => installed,
name => $::heat::params::engine_package_name, name => $::heat::params::engine_package_name,
tag => 'openstack', tag => 'openstack',
notify => Exec['heat-dbsync'], notify => $::heat::subscribe_sync_db,
} }
if $manage_service { if $manage_service {
@ -104,7 +105,7 @@ class heat::engine (
require => [ File['/etc/heat/heat.conf'], require => [ File['/etc/heat/heat.conf'],
Package['heat-common'], Package['heat-common'],
Package['heat-engine']], Package['heat-engine']],
subscribe => Exec['heat-dbsync'], subscribe => $::heat::subscribe_sync_db,
} }
heat_config { heat_config {

View File

@ -164,6 +164,10 @@
# (Optional) Enable the stack-abandon feature. # (Optional) Enable the stack-abandon feature.
# Defaults to undef # Defaults to undef
# #
# [*sync_db*]
# (Optional) Run db sync on nodes after connection setting has been set.
# Defaults to true
#
# === Deprecated Parameters # === Deprecated Parameters
# #
# [*mysql_module*] # [*mysql_module*]
@ -229,6 +233,7 @@ class heat(
$region_name = undef, $region_name = undef,
$enable_stack_adopt = undef, $enable_stack_adopt = undef,
$enable_stack_abandon = undef, $enable_stack_abandon = undef,
$sync_db = true,
# Deprecated parameters # Deprecated parameters
$mysql_module = undef, $mysql_module = undef,
$sql_connection = undef, $sql_connection = undef,
@ -506,14 +511,17 @@ class heat(
value => $database_idle_timeout; value => $database_idle_timeout;
} }
Heat_config['database/connection'] ~> Exec['heat-dbsync'] if $sync_db {
$subscribe_sync_db = Exec['heat-dbsync']
Heat_config['database/connection'] ~> Exec['heat-dbsync']
exec { 'heat-dbsync': exec { 'heat-dbsync':
command => $::heat::params::dbsync_command, command => $::heat::params::dbsync_command,
path => '/usr/bin', path => '/usr/bin',
user => 'heat', user => 'heat',
refreshonly => true, refreshonly => true,
logoutput => on_failure, logoutput => on_failure,
}
} }
} }

View File

@ -100,6 +100,17 @@ describe 'heat::api_cfn' do
is_expected.to contain_service('heat-api-cfn').that_subscribes_to('Exec[heat-dbsync]') is_expected.to contain_service('heat-api-cfn').that_subscribes_to('Exec[heat-dbsync]')
end end
end end
context 'with $sync_db set to false in ::heat' do
let :pre_condition do
"class {'heat': sync_db => false}"
end
it 'configures heat-api-cfn service to not subscribe to the dbsync resource' do
is_expected.to contain_service('heat-api-cfn').that_subscribes_to(nil)
end
end
end end

View File

@ -100,6 +100,17 @@ describe 'heat::api_cloudwatch' do
is_expected.to contain_service('heat-api-cloudwatch').that_subscribes_to('Exec[heat-dbsync]') is_expected.to contain_service('heat-api-cloudwatch').that_subscribes_to('Exec[heat-dbsync]')
end end
end end
context 'with $sync_db set to false in ::heat' do
let :pre_condition do
"class {'heat': sync_db => false}"
end
it 'configures heat-api-cloudwatch service to not subscribe to the dbsync resource' do
is_expected.to contain_service('heat-api-cloudwatch').that_subscribes_to(nil)
end
end
end end
context 'on Debian platforms' do context 'on Debian platforms' do

View File

@ -103,6 +103,16 @@ describe 'heat::api' do
is_expected.to contain_service('heat-api').that_subscribes_to('Exec[heat-dbsync]') is_expected.to contain_service('heat-api').that_subscribes_to('Exec[heat-dbsync]')
end end
end end
context 'with $sync_db set to false in ::heat' do
let :pre_condition do
"class {'heat': sync_db => false}"
end
it 'configures heat-api service to not subscribe to the dbsync resource' do
is_expected.to contain_service('heat-api').that_subscribes_to(nil)
end
end
end end
context 'on Debian platforms' do context 'on Debian platforms' do

View File

@ -99,6 +99,21 @@ describe 'heat::engine' do
:subscribe => 'Exec[heat-dbsync]' :subscribe => 'Exec[heat-dbsync]'
) } ) }
end end
context 'with $sync_db set to false in ::heat' do
let :pre_condition do
"class {'heat': sync_db => false}"
end
it 'configures heat-engine service to not subscribe to the dbsync resource' do
is_expected.to contain_service('heat-engine').that_subscribes_to(nil)
end
it 'configures the heat-engine package to not be notified by the dbsync resource ' do
is_expected.to contain_package('heat-engine').with(
:notify => nil,
)
end
end
end end
context 'on Debian platforms' do context 'on Debian platforms' do