From 9babb26d31bc25477bb5223bc749901064ff57bb Mon Sep 17 00:00:00 2001 From: Nate Potter Date: Mon, 2 Nov 2015 22:04:35 +0000 Subject: [PATCH] Allow customization of db sync command line Add parameter to glance::db::sync class to allow end users to add command line parameters to the db sync command. Change-Id: I043dd9560f7d5eb7bc18721e759e5f61186f5cf7 Partial-bug: #1472740 --- manifests/db/sync.pp | 14 ++++++++++++-- spec/classes/glance_db_sync_spec.rb | 20 +++++++++++++++++++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/manifests/db/sync.pp b/manifests/db/sync.pp index 4a0b76f8..09986c0c 100644 --- a/manifests/db/sync.pp +++ b/manifests/db/sync.pp @@ -1,7 +1,17 @@ # # Class to execute glance dbsync # -class glance::db::sync { +# == Parameters +# +# [*extra_params*] +# (optional) String of extra command line parameters to append +# to the glance-manage db sync command. These will be inserted +# in the command line between 'glance-manage' and 'db sync'. +# Defaults to undef +# +class glance::db::sync( + $extra_params = undef, +) { include ::glance::params @@ -13,7 +23,7 @@ class glance::db::sync { Glance_cache_config<||> ~> Exec['glance-manage db_sync'] exec { 'glance-manage db_sync': - command => $::glance::params::db_sync_command, + command => "glance-manage ${extra_params} db_sync", path => '/usr/bin', user => 'glance', refreshonly => true, diff --git a/spec/classes/glance_db_sync_spec.rb b/spec/classes/glance_db_sync_spec.rb index c0e224ec..4edf7ec4 100644 --- a/spec/classes/glance_db_sync_spec.rb +++ b/spec/classes/glance_db_sync_spec.rb @@ -6,7 +6,7 @@ describe 'glance::db::sync' do it 'runs glance-manage db_sync' do is_expected.to contain_exec('glance-manage db_sync').with( - :command => 'glance-manage --config-file=/etc/glance/glance-registry.conf db_sync', + :command => 'glance-manage db_sync', :path => '/usr/bin', :user => 'glance', :refreshonly => 'true', @@ -14,6 +14,24 @@ describe 'glance::db::sync' do ) end + describe "overriding extra_params" do + let :params do + { + :extra_params => '--config-file /etc/glance/glance.conf', + } + end + + it {is_expected.to contain_exec('glance-manage db_sync').with( + :command => 'glance-manage --config-file /etc/glance/glance.conf db_sync', + :path => '/usr/bin', + :user => 'glance', + :refreshonly => 'true', + :logoutput => 'on_failure' + ) + } + end + + end context 'on a RedHat osfamily' do