- Configure websocket address
2017-01-02 Release 6.2.0
- Adds SSL/TLS support
+2017-01-03 Release 6.3.0
+- Add param to log karaf logs to either file or console
Valid options: An integer greater than 0.
+##### `log_mechanism`
+
+Logging mechanism for karaf logs. They are logged either to a file or console.
+When `log_mechanism` is `file`, log files are configured as per `log_max_size`
+and `log_max_rollover`.
+
+Default: `file`
+
+Valid options: `file`, `console`.
+
##### `enable_ha`
Enable or disable ODL High Availablity.
}
}
+ # set logging mechanism
+ if $opendaylight::log_mechanism == 'console' {
+ file_line {'rootlogger':
+ ensure => present,
+ path => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
+ line => 'log4j.rootLogger=INFO, stdout, osgi:*',
+ match => '^log4j.rootLogger.*$'
+ }
+ file_line { 'logappender':
+ ensure => present,
+ path => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
+ line => 'log4j.appender.stdout.direct=true',
+ after => 'log4j.appender.stdout=org.apache.log4j.ConsoleAppender',
+ match => '^log4j.appender.stdout.direct.*$',
+ append_on_no_match => true
+ }
+ }
# Set maximum ODL log file size
file_line { 'logmaxsize':
ensure => present,
# Full path to a public CA authority certificate file which signed
# OpenDaylight's certificate. Not needed if ODL certificate is self-signed.
# Optional. Defaults to undef.
+# [*log_mechanism*]
+# Sets logging mechanism for karaf logs
+#
# === Deprecated Parameters
#
# [*ha_node_index*]
$tls_trusted_certs = $::opendaylight::params::tls_trusted_certs,
$tls_key_file = $::opendaylight::params::tls_key_file,
$tls_cert_file = $::opendaylight::params::tls_cert_file,
- $tls_ca_cert_file = $::opendaylight::params::tls_ca_cert_file
+ $tls_ca_cert_file = $::opendaylight::params::tls_ca_cert_file,
+ $log_mechanism = $::opendaylight::params::log_mechanism,
) inherits ::opendaylight::params {
# Validate OS family
$tls_cert_file = undef
$tls_ca_cert_file = undef
$tls_trusted_certs = []
+ $log_mechanism = 'file'
}
{
"name": "opendaylight-opendaylight",
- "version": "6.2.0",
+ "version": "6.3.0",
"author": "Daniel Farrell",
"summary": "Puppet module that installs and configures the OpenDaylight SDN controller",
"license": "BSD-2-Clause",
end
end
- describe 'log file size and rollover' do
- context 'using default size and rollover' do
+ describe 'logging mechanism' do
+ context 'log to file using default size and rollover' do
# Call specialized helper fn to install OpenDaylight
install_odl
- # Call specialized helper fn for log file settings validations
- log_file_settings_validations
+ # Call specialized helper fn for log settings validations
+ log_settings_validations
end
- context 'customising size' do
+ context 'log to file customising size' do
# Call specialized helper fn to install OpenDaylight
install_odl(log_max_size: '1GB')
- # Call specialized helper fn for log file settings validations
- log_file_settings_validations(log_max_size: '1GB')
+ # Call specialized helper fn for log settings validations
+ log_settings_validations(log_max_size: '1GB')
end
- context 'customising rollover' do
+ context 'log to file customising rollover' do
# Call specialized helper fn to install OpenDaylight
install_odl(log_max_rollover: 3)
- # Call specialized helper fn for log file settings validations
- log_file_settings_validations(log_max_rollover: 3)
+ # Call specialized helper fn for log settings validations
+ log_settings_validations(log_max_rollover: 3)
end
- context 'customising size and rollover' do
+ context 'log to file customising size and rollover' do
# Call specialized helper fn to install OpenDaylight
install_odl(log_max_size: '1GB',
log_max_rollover: 3)
- # Call specialized helper fn for log file settings validations
- log_file_settings_validations(log_max_size: '1GB',
+ # Call specialized helper fn for log settings validations
+ log_settings_validations(log_max_size: '1GB',
log_max_rollover: 3)
end
+
+ context 'log to console' do
+ # Call specialized helper fn to install OpenDaylight
+ install_odl(log_mechanism: 'console')
+
+ # Call specialized helper fn for log settings validations
+ log_settings_validations(log_mechanism: 'console')
+ end
end
describe 'testing REST port config file' do
# Run tests that specialize in checking log file settings
# NB: Only testing defaults here, specialized log file settings tests elsewhere
# Note that this function is defined in spec_helper
- log_file_settings
+ log_settings
end
end
# Run tests that specialize in checking log file settings
# NB: Only testing defaults here, specialized log file settings tests elsewhere
# Note that this function is defined in spec_helper
- log_file_settings
+ log_settings
end
end
# Run tests that specialize in checking log file settings
# NB: Only testing defaults here, specialized log file settings tests elsewhere
# Note that this function is defined in spec_helper
- log_file_settings
+ log_settings
end
end
end
end
- # All custom log file size and rollover tests
- describe 'log file size and rollover' do
+ describe 'log mechanism settings' do
# Non-OS-type tests assume CentOS 7
# See issue #43 for reasoning:
# https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
osfamily = 'RedHat'
operatingsystem = 'CentOS'
operatingsystemmajrelease = '7'
- context 'using default size and rollover' do
+
+ # All custom log file size and rollover tests
+ context 'log to file using default size and rollover' do
let(:facts) {{
:osfamily => osfamily,
:operatingsystem => operatingsystem,
# Note that this function is defined in spec_helper
generic_tests
- # Run test specific to log file settings
- log_file_settings
+ # Run test specific to log settings
+ log_settings
end
- context 'customizing size' do
+ context 'log to file customizing size' do
let(:facts) {{
:osfamily => osfamily,
:operatingsystem => operatingsystem,
# Note that this function is defined in spec_helper
generic_tests
- # Run test specific to log file settings
- log_file_settings(log_max_size: '1GB')
+ # Run test specific to log settings
+ log_settings(log_max_size: '1GB')
end
- context 'customizing rollover' do
+ context 'log to file customizing rollover' do
let(:facts) {{
:osfamily => osfamily,
:operatingsystem => operatingsystem,
# Note that this function is defined in spec_helper
generic_tests
- # Run test specific to log file settings
- log_file_settings(log_max_rollover: 3)
+ # Run test specific to log settings
+ log_settings(log_max_rollover: 3)
end
- context 'customizing size and rollover' do
+ context 'log to file customizing size and rollover' do
let(:facts) {{
:osfamily => osfamily,
:operatingsystem => operatingsystem,
# Note that this function is defined in spec_helper
generic_tests
- # Run test specific to log file settings
- log_file_settings(log_max_size: '1GB',
+ # Run test specific to log settings
+ log_settings(log_max_size: '1GB',
log_max_rollover: 3)
end
+
+ context 'log to console' do
+ let(:facts) {{
+ :osfamily => osfamily,
+ :operatingsystem => operatingsystem,
+ :operatingsystemmajrelease => operatingsystemmajrelease,
+ }}
+
+ let(:params) {{
+ :log_mechanism => 'console',
+ }}
+
+ # Run shared tests applicable to all supported OSs
+ # Note that this function is defined in spec_helper
+ generic_tests
+
+ # Run test specific to log settings
+ log_settings(log_mechanism: 'console')
+ end
end
# All OVSDB HA enable/disable tests
end
# Shared tests that specialize in testing log file size and rollover
-def log_file_settings(options = {})
+def log_settings(options = {})
# Extraxt params. The dafault value should be same as in opendaylight::params
log_max_size = options.fetch(:log_max_size, '10GB')
log_max_rollover = options.fetch(:log_max_rollover, 2)
+ log_mechanism = options.fetch(:log_mechanism, 'file')
- it {
- should contain_file_line('logmaxsize').with(
- 'path' => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
- 'line' => "log4j.appender.out.maxFileSize=#{log_max_size}",
- 'match' => '^log4j.appender.out.maxFileSize.*$',
- )
- }
- it {
- should contain_file_line('logmaxrollover').with(
- 'path' => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
- 'line' => "log4j.appender.out.maxBackupIndex=#{log_max_rollover}",
- 'match' => '^log4j.appender.out.maxBackupIndex.*$',
- )
- }
+ if log_mechanism == 'console'
+ it {
+ should contain_file_line('rootlogger').with(
+ 'path' => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
+ 'line' => 'log4j.rootLogger=INFO, stdout, osgi:*',
+ 'match' => '^log4j.rootLogger.*$',
+ )
+ }
+ it {
+ should contain_file_line('logappender').with(
+ 'path' => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
+ 'line' => 'log4j.appender.stdout.direct=true',
+ 'after' => 'log4j.appender.stdout=org.apache.log4j.ConsoleAppender',
+ 'match' => '^log4j.appender.stdout.direct.*$',
+ 'append_on_no_match' => true
+ )
+ }
+ else
+ it {
+ should contain_file_line('logmaxsize').with(
+ 'path' => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
+ 'line' => "log4j.appender.out.maxFileSize=#{log_max_size}",
+ 'match' => '^log4j.appender.out.maxFileSize.*$',
+ )
+ }
+ it {
+ should contain_file_line('logmaxrollover').with(
+ 'path' => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
+ 'line' => "log4j.appender.out.maxBackupIndex=#{log_max_rollover}",
+ 'match' => '^log4j.appender.out.maxBackupIndex.*$',
+ )
+ }
+ end
end
# Shared tests that specialize in testing Karaf feature installs
snat_mechanism = options.fetch(:snat_mechanism, 'controller')
enable_tls = options.fetch(:enable_tls, false)
tls_keystore_password = options.fetch(:tls_keystore_password, 'dummypass')
+ log_mechanism = options.fetch(:log_mechanism, 'file')
# Build script for consumption by Puppet apply
it 'should work idempotently with no errors' do
snat_mechanism => #{snat_mechanism},
enable_tls => #{enable_tls},
tls_keystore_password => #{tls_keystore_password},
+ log_mechanism => #{log_mechanism},
}
EOS
end
# Shared function for validations related to log file settings
-def log_file_settings_validations(options = {})
+def log_settings_validations(options = {})
# Should contain log level config file with correct file size and rollover values
log_max_size = options.fetch(:log_max_size, '10GB')
log_max_rollover = options.fetch(:log_max_rollover, 2)
+ log_mechanism = options.fetch(:log_mechanism, 'file')
- describe file('/opt/opendaylight/etc/org.ops4j.pax.logging.cfg') do
- it { should be_file }
- it { should be_owned_by 'odl' }
- it { should be_grouped_into 'odl' }
- its(:content) { should match /^log4j.appender.out.maxFileSize=#{log_max_size}/ }
- its(:content) { should match /^log4j.appender.out.maxBackupIndex=#{log_max_rollover}/ }
+ if log_mechanism == 'console'
+ describe file('/opt/opendaylight/etc/org.ops4j.pax.logging.cfg') do
+ it { should be_file }
+ it { should be_owned_by 'odl' }
+ it { should be_grouped_into 'odl' }
+ its(:content) { should match /log4j.rootLogger=INFO, stdout, osgi:*/ }
+ its(:content) { should match /log4j.appender.stdout.direct=true/ }
+ end
+ else
+ describe file('/opt/opendaylight/etc/org.ops4j.pax.logging.cfg') do
+ it { should be_file }
+ it { should be_owned_by 'odl' }
+ it { should be_grouped_into 'odl' }
+ its(:content) { should match /^log4j.appender.out.maxFileSize=#{log_max_size}/ }
+ its(:content) { should match /^log4j.appender.out.maxBackupIndex=#{log_max_rollover}/ }
+ end
end
end