From 8a1e5f96b38c0a2e7e93b78b388adbba9a8ae06e Mon Sep 17 00:00:00 2001 From: Nate Potter Date: Mon, 2 Nov 2015 18:31:54 +0000 Subject: [PATCH] Allow customization of db sync command line Add parameter to cinder::db::sync class to allow end users to add command line parameters to the db sync command. Change-Id: I34d9de89aae007d6b9f8644a8ba936bc0cf0c04c Partial-bug: #1472740 --- manifests/db/sync.pp | 14 ++++++++++++-- spec/classes/cinder_db_sync_spec.rb | 21 ++++++++++++++++++++- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/manifests/db/sync.pp b/manifests/db/sync.pp index 58644243..40552e23 100644 --- a/manifests/db/sync.pp +++ b/manifests/db/sync.pp @@ -1,7 +1,17 @@ # # Class to execute cinder dbsync # -class cinder::db::sync { +# == Parameters +# +# [*extra_params*] +# (optional) String of extra command line parameters to append +# to the cinder-manage db sync command. These will be inserted +# in the command line between 'cinder-manage' and 'db sync'. +# Defaults to undef +# +class cinder::db::sync( + $extra_params = undef, +) { include ::cinder::params @@ -12,7 +22,7 @@ class cinder::db::sync { Cinder_config <| title == 'database/connection' |> ~> Exec['cinder-manage db_sync'] exec { 'cinder-manage db_sync': - command => $::cinder::params::db_sync_command, + command => "cinder-manage ${extra_params} db sync", path => '/usr/bin', user => 'cinder', refreshonly => true, diff --git a/spec/classes/cinder_db_sync_spec.rb b/spec/classes/cinder_db_sync_spec.rb index 98761d4a..238b0980 100644 --- a/spec/classes/cinder_db_sync_spec.rb +++ b/spec/classes/cinder_db_sync_spec.rb @@ -6,7 +6,7 @@ describe 'cinder::db::sync' do it 'runs cinder-manage db_sync' do is_expected.to contain_exec('cinder-manage db_sync').with( - :command => 'cinder-manage db sync', + :command => 'cinder-manage db sync', :user => 'cinder', :path => '/usr/bin', :refreshonly => 'true', @@ -14,8 +14,27 @@ describe 'cinder::db::sync' do ) end + describe "overriding extra_params" do + let :params do + { + :extra_params => '--config-file /etc/cinder/cinder.conf', + } + end + + it { + is_expected.to contain_exec('cinder-manage db_sync').with( + :command => 'cinder-manage --config-file /etc/cinder/cinder.conf db sync', + :user => 'cinder', + :path => '/usr/bin', + :refreshonly => 'true', + :logoutput => 'on_failure' + ) + } + end + end + context 'on a RedHat osfamily' do let :facts do {