Skip to content

Commit 59e7382

Browse files
authored
Merge pull request #239 from Xylakant/rebased/fasrc-add_oned_log_system_param
add param for oned log system
2 parents 3949677 + c270348 commit 59e7382

4 files changed

Lines changed: 29 additions & 1 deletion

File tree

manifests/init.pp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@
9494
#
9595
# ==== OpenNebula configuration parameters
9696
#
97+
# $oned_log_system - default 'file'
98+
# the log subsystem to use, valid values are [file, syslog]
99+
#
97100
# ===== OpenNebula Database configuration
98101
#
99102
# $oned_db - default oned
@@ -349,6 +352,7 @@
349352
$ha_setup = false,
350353
$puppetdb = false,
351354
$debug_level = '0',
355+
$oned_log_system = $one::params::oned_log_system,
352356
$oned_port = $one::params::oned_port,
353357
$oned_db = $one::params::oned_db,
354358
$oned_db_user = $one::params::oned_db_user,
@@ -498,6 +502,12 @@
498502
}
499503
}
500504

505+
# I'd use member() here but the stdlib version we're currently using doesn't know that,
506+
# so feel free to change once the stlib was updated to a more recent version
507+
if (($oned_log_system != 'file') and ($oned_log_system != 'syslog')) {
508+
fail("\"${oned_log_system}\" is not a valid logging subsystem. Valid values are [\"file\", \"syslog\"].")
509+
}
510+
501511
# check if version greater than or equal to 4.14 (used in templates)
502512
if ( versioncmp($one_version, '4.14') >= 0 ) {
503513
$version_gte_4_14 = true

manifests/params.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#
2222
class one::params {
2323
# OpenNebula parameters
24+
$oned_log_system = hiera('one::oned::oned_log_system', 'file')
2425
$oned_port = hiera('one::oned::port', '2633')
2526
$oned_listen_address = hiera('one::oned_listen_address', '0.0.0.0')
2627
$oned_db = hiera('one::oned::db', 'oned')

spec/classes/opennebula_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,23 @@
135135
it { should contain_file("#{onehome}/.ssh/id_dsa").with_content(sshprivkey) }
136136
it { should contain_file("#{onehome}/.ssh/id_dsa.pub").with_content(sshpubkey) }
137137
it { should contain_file("#{onehome}/.ssh/authorized_keys").with_content(sshpubkey) }
138+
it { should contain_file(oned_config).with_content(/^LOG = \[\n\s+system\s+=\s+"file"/m) }
139+
context 'with syslog logging' do
140+
let(:params) { {
141+
:oned => true,
142+
:oned_log_system => 'syslog'
143+
} }
144+
it { should contain_file(oned_config).with_content(/^LOG = \[\n\s+system\s+=\s+"syslog"/m) }
145+
end
146+
context 'with invalid logging subsystem' do
147+
let(:params) { {
148+
:oned => true,
149+
:oned_log_system => 'invalid'
150+
} }
151+
it do
152+
is_expected.to compile.and_raise_error(/"invalid" is not a valid logging subsystem. Valid values are \["file", "syslog"\]/)
153+
end
154+
end
138155
context 'with sqlite backend' do
139156
it { should contain_file(oned_config).with_content(/^DB = \[ backend = \"sqlite\"/) }
140157
end

templates/oned.conf.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
#*******************************************************************************
5656

5757
LOG = [
58-
system = "file",
58+
system = "<%= scope.lookupvar('one::oned_log_system') %>",
5959
debug_level = <%= @debug_level %>
6060
]
6161

0 commit comments

Comments
 (0)