Add sync_db param to gnocchi api class

This makes it cleaner to pass the flag from tht
rather than adding if checks.

Change-Id: I054d8bb57f605c8f4449fd78445a7c7ab3a8e49e
This commit is contained in:
Pradeep Kilambi
2016-04-01 14:27:22 -04:00
parent 855a56a90e
commit df012edec8
3 changed files with 23 additions and 0 deletions

View File

@@ -60,6 +60,10 @@
# to make gnocchi-api be a web app using apache mod_wsgi.
# Defaults to '$::gnocchi::params::api_service_name'
#
# [*sync_db*]
# (optional) Run gnocchi-upgrade db sync on api nodes after installing the package.
# Defaults to false
class gnocchi::api (
$manage_service = true,
$enabled = true,
@@ -74,6 +78,7 @@ class gnocchi::api (
$workers = $::processorcount,
$max_limit = 1000,
$service_name = $::gnocchi::params::api_service_name,
$sync_db = false,
) inherits gnocchi::params {
include ::gnocchi::policy
@@ -101,6 +106,10 @@ class gnocchi::api (
}
}
if $sync_db {
include ::gnocchi::db::sync
}
if $service_name == $::gnocchi::params::api_service_name {
service { 'gnocchi-api':
ensure => $service_ensure,

View File

@@ -0,0 +1,6 @@
---
fixes:
- Add a sync_db option to ::gnocchi::api class. This makes it easier
to control the db sync. The sync_db param is a boolean and set to
false by default for backward compatibility so db sync is not run
out of the box.

View File

@@ -69,6 +69,14 @@ describe 'gnocchi::api' do
end
end
context 'with sync_db set to true' do
before do
params.merge!({
:sync_db => true})
end
it { is_expected.to contain_class('gnocchi::db::sync') }
end
context 'with disabled service managing' do
before do
params.merge!({