From 1b965fd70ba0cf8e4d7ed051e5c8dc790f9a2225 Mon Sep 17 00:00:00 2001 From: Nate Potter Date: Mon, 2 Nov 2015 22:19:21 +0000 Subject: [PATCH] Allow customization of db sync command line Add parameter to nova::db::sync class to allow end users to add command line parameters to the db sync command. Change-Id: I89dea475495d5903d953ff4492ad2e0f12a293c1 Partial-bug: #1472740 --- manifests/db/sync.pp | 14 ++++++++++++-- spec/classes/nova_db_sync_spec.rb | 19 ++++++++++++++++++- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/manifests/db/sync.pp b/manifests/db/sync.pp index 3e2ddb22c..64b9d9c41 100644 --- a/manifests/db/sync.pp +++ b/manifests/db/sync.pp @@ -1,7 +1,17 @@ # # Class to execute nova dbsync # -class nova::db::sync { +# ==Parameters +# +# [*extra_params*] +# (optional) String of extra command line parameters to append +# to the nova-manage db sync command. These will be inserted in +# the command line between 'nova-manage' and 'db sync'. +# Defaults to undef +# +class nova::db::sync( + $extra_params = undef, +) { include ::nova::params @@ -14,7 +24,7 @@ class nova::db::sync { Exec<| title == 'post-nova_config' |> ~> Exec['nova-db-sync'] exec { 'nova-db-sync': - command => '/usr/bin/nova-manage db sync', + command => "/usr/bin/nova-manage ${extra_params} db sync", refreshonly => true, logoutput => on_failure, } diff --git a/spec/classes/nova_db_sync_spec.rb b/spec/classes/nova_db_sync_spec.rb index 374b3da93..dc1a75a01 100644 --- a/spec/classes/nova_db_sync_spec.rb +++ b/spec/classes/nova_db_sync_spec.rb @@ -6,14 +6,31 @@ describe 'nova::db::sync' do it 'runs nova-db-sync' do is_expected.to contain_exec('nova-db-sync').with( - :command => '/usr/bin/nova-manage db sync', + :command => '/usr/bin/nova-manage db sync', :refreshonly => 'true', :logoutput => 'on_failure' ) end + describe "overriding extra_params" do + let :params do + { + :extra_params => '--config-file /etc/nova/nova.conf', + } + end + + it { + is_expected.to contain_exec('nova-db-sync').with( + :command => '/usr/bin/nova-manage --config-file /etc/nova/nova.conf db sync', + :refreshonly => 'true', + :logoutput => 'on_failure' + ) + } + end + end + context 'on a RedHat osfamily' do let :facts do {