Skip to content

Commit c270348

Browse files
author
Felix Gilcher
committed
add more specs, parameter documentation, validation
* added specs that test that the param works * added parameter validation and specs for that * added the docstring for the new parameter
1 parent 06f752d commit c270348

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

manifests/init.pp

Lines changed: 9 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
@@ -499,6 +502,12 @@
499502
}
500503
}
501504

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+
502511
# check if version greater than or equal to 4.14 (used in templates)
503512
if ( versioncmp($one_version, '4.14') >= 0 ) {
504513
$version_gte_4_14 = true

spec/classes/opennebula_spec.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,22 @@
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) }
138138
it { should contain_file(oned_config).with_content(/^LOG = \[\n\s+system\s+=\s+"file"/m) }
139-
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
140155
context 'with sqlite backend' do
141156
it { should contain_file(oned_config).with_content(/^DB = \[ backend = \"sqlite\"/) }
142157
end

0 commit comments

Comments
 (0)