From 091116d509a431e8141e7fbd589657293289acdc Mon Sep 17 00:00:00 2001 From: Nate Potter Date: Mon, 2 Nov 2015 22:34:06 +0000 Subject: [PATCH] Allow customization of db sync command line Add $extra_params parameter to neutron::db::sync class to allow end users to add command line parameters to db sync command. Change-Id: Ideeeb70115bcec8526444c142b54890707bfbf61 Partial-bug: #1472740 --- manifests/db/sync.pp | 15 +++++++++++++-- spec/classes/neutron_db_sync_spec.rb | 17 +++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/manifests/db/sync.pp b/manifests/db/sync.pp index 54eb2cb36..57df04e54 100644 --- a/manifests/db/sync.pp +++ b/manifests/db/sync.pp @@ -1,7 +1,18 @@ # # Class to execute neutron dbsync # -class neutron::db::sync { +# ==Parameters +# +# [*extra_params*] +# (optional) String of extra command line parameters to append +# to the neutron-db-manage upgrade head command. These will be +# inserted in the command line between 'neutron-db-manage' and +# 'upgrade head'. +# Defaults to '--config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini' +# +class neutron::db::sync( + $extra_params = '--config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini', +) { include ::neutron::params @@ -12,7 +23,7 @@ class neutron::db::sync { Neutron_config<| title == 'database/connection' |> ~> Exec['neutron-db-sync'] exec { 'neutron-db-sync': - command => 'neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini upgrade head', + command => "neutron-db-manage ${extra_params} upgrade head", path => '/usr/bin', refreshonly => true, logoutput => on_failure, diff --git a/spec/classes/neutron_db_sync_spec.rb b/spec/classes/neutron_db_sync_spec.rb index dd6c4248f..7e796b925 100644 --- a/spec/classes/neutron_db_sync_spec.rb +++ b/spec/classes/neutron_db_sync_spec.rb @@ -13,6 +13,23 @@ describe 'neutron::db::sync' do ) end + describe "overriding extra_params" do + let :params do + { + :extra_params => '--config-file /etc/neutron/neutron.conf', + } + end + + it { + is_expected.to contain_exec('neutron-db-sync').with( + :command => 'neutron-db-manage --config-file /etc/neutron/neutron.conf upgrade head', + :path => '/usr/bin', + :refreshonly => 'true', + :logoutput => 'on_failure' + ) + } + end + end context 'on a RedHat osfamily' do