From 8d7be7ac236624690334fca22d0d158de65f1878 Mon Sep 17 00:00:00 2001 From: Alexey Deryugin Date: Thu, 12 May 2016 16:07:56 +0300 Subject: [PATCH] Use oslo module for logging Additonal changes: * switch logging related parameters to $::os_service_default as they are used in oslo::log * update unit tests Change-Id: I1884387b438e3885986d031f95ba323e57aac7ab --- manifests/conductor.pp | 48 ++++++-------------------- manifests/guestagent.pp | 48 ++++++-------------------- manifests/taskmanager.pp | 48 ++++++-------------------- spec/classes/trove_conductor_spec.rb | 8 +++-- spec/classes/trove_guestagent_spec.rb | 8 +++-- spec/classes/trove_taskmanager_spec.rb | 8 +++-- 6 files changed, 51 insertions(+), 117 deletions(-) diff --git a/manifests/conductor.pp b/manifests/conductor.pp index 905e84cc..c1bb8651 100644 --- a/manifests/conductor.pp +++ b/manifests/conductor.pp @@ -66,12 +66,12 @@ class trove::conductor( $enabled = true, $manage_service = true, $ensure_package = 'present', - $verbose = false, - $debug = false, + $verbose = $::os_service_default, + $debug = $::os_service_default, $log_file = '/var/log/trove/trove-conductor.log', $log_dir = '/var/log/trove', - $use_syslog = false, - $log_facility = 'LOG_USER', + $use_syslog = $::os_service_default, + $log_facility = $::os_service_default, $auth_url = 'http://localhost:5000/v2.0', $conductor_manager = 'trove.conductor.manager.Manager', $workers = $::processorcount, @@ -101,8 +101,6 @@ class trove::conductor( # basic service config trove_conductor_config { - 'DEFAULT/verbose': value => $verbose; - 'DEFAULT/debug': value => $debug; 'DEFAULT/trove_auth_url': value => $auth_url; 'DEFAULT/nova_proxy_admin_user': value => $::trove::nova_proxy_admin_user; 'DEFAULT/nova_proxy_admin_tenant_name': value => $::trove::nova_proxy_admin_tenant_name; @@ -144,37 +142,13 @@ class trove::conductor( } } - # Logging - if $log_file { - trove_conductor_config { - 'DEFAULT/log_file': value => $log_file; - } - } else { - trove_conductor_config { - 'DEFAULT/log_file': ensure => absent; - } - } - - if $log_dir { - trove_conductor_config { - 'DEFAULT/log_dir': value => $log_dir; - } - } else { - trove_conductor_config { - 'DEFAULT/log_dir': ensure => absent; - } - } - - # Syslog - if $use_syslog { - trove_conductor_config { - 'DEFAULT/use_syslog' : value => true; - 'DEFAULT/syslog_log_facility' : value => $log_facility; - } - } else { - trove_conductor_config { - 'DEFAULT/use_syslog': value => false; - } + oslo::log { 'trove_conductor_config': + debug => $debug, + verbose => $verbose, + log_file => $log_file, + log_dir => $log_dir, + use_syslog => $use_syslog, + syslog_log_facility => $log_facility } trove::generic_service { 'conductor': diff --git a/manifests/guestagent.pp b/manifests/guestagent.pp index a4afcd87..89886e91 100644 --- a/manifests/guestagent.pp +++ b/manifests/guestagent.pp @@ -79,12 +79,12 @@ class trove::guestagent( $enabled = true, $manage_service = true, $ensure_package = 'present', - $verbose = false, - $debug = false, + $verbose = $::os_service_default, + $debug = $::os_service_default, $log_file = '/var/log/trove/guestagent.log', $log_dir = '/var/log/trove', - $use_syslog = false, - $log_facility = 'LOG_USER', + $use_syslog = $::os_service_default, + $log_facility = $::os_service_default, $auth_url = 'http://localhost:5000/v2.0', $swift_url = 'http://localhost:8080/v1/AUTH_', $control_exchange = 'trove', @@ -98,8 +98,6 @@ class trove::guestagent( # basic service config trove_guestagent_config { - 'DEFAULT/verbose': value => $verbose; - 'DEFAULT/debug': value => $debug; 'DEFAULT/trove_auth_url': value => $auth_url; 'DEFAULT/swift_url': value => $swift_url; } @@ -144,37 +142,13 @@ class trove::guestagent( } } - # Logging - if $log_file { - trove_guestagent_config { - 'DEFAULT/log_file': value => $log_file; - } - } else { - trove_guestagent_config { - 'DEFAULT/log_file': ensure => absent; - } - } - - if $log_dir { - trove_guestagent_config { - 'DEFAULT/log_dir': value => $log_dir; - } - } else { - trove_guestagent_config { - 'DEFAULT/log_dir': ensure => absent; - } - } - - # Syslog - if $use_syslog { - trove_guestagent_config { - 'DEFAULT/use_syslog' : value => true; - 'DEFAULT/syslog_log_facility' : value => $log_facility; - } - } else { - trove_guestagent_config { - 'DEFAULT/use_syslog': value => false; - } + oslo::log { 'trove_guestagent_config': + debug => $debug, + verbose => $verbose, + log_file => $log_file, + log_dir => $log_dir, + use_syslog => $use_syslog, + syslog_log_facility => $log_facility } trove::generic_service { 'guestagent': diff --git a/manifests/taskmanager.pp b/manifests/taskmanager.pp index 6595ec47..8157175c 100644 --- a/manifests/taskmanager.pp +++ b/manifests/taskmanager.pp @@ -88,12 +88,12 @@ class trove::taskmanager( $enabled = true, $manage_service = true, - $debug = false, - $verbose = false, + $debug = $::os_service_default, + $verbose = $::os_service_default, $log_file = '/var/log/trove/trove-taskmanager.log', $log_dir = '/var/log/trove', - $use_syslog = false, - $log_facility = 'LOG_USER', + $use_syslog = $::os_service_default, + $log_facility = $::os_service_default, $auth_url = 'http://localhost:5000/v2.0', $heat_url = false, $ensure_package = 'present', @@ -126,8 +126,6 @@ class trove::taskmanager( # basic service config trove_taskmanager_config { - 'DEFAULT/verbose': value => $verbose; - 'DEFAULT/debug': value => $debug; 'DEFAULT/trove_auth_url': value => $auth_url; 'DEFAULT/nova_proxy_admin_user': value => $::trove::nova_proxy_admin_user; 'DEFAULT/nova_proxy_admin_pass': value => $::trove::nova_proxy_admin_pass; @@ -209,37 +207,13 @@ class trove::taskmanager( } } - # Logging - if $log_file { - trove_taskmanager_config { - 'DEFAULT/log_file': value => $log_file; - } - } else { - trove_taskmanager_config { - 'DEFAULT/log_file': ensure => absent; - } - } - - if $log_dir { - trove_taskmanager_config { - 'DEFAULT/log_dir': value => $log_dir; - } - } else { - trove_taskmanager_config { - 'DEFAULT/log_dir': ensure => absent; - } - } - - # Syslog - if $use_syslog { - trove_taskmanager_config { - 'DEFAULT/use_syslog' : value => true; - 'DEFAULT/syslog_log_facility' : value => $log_facility; - } - } else { - trove_taskmanager_config { - 'DEFAULT/use_syslog': value => false; - } + oslo::log { 'trove_taskmanager_config': + debug => $debug, + verbose => $verbose, + log_file => $log_file, + log_dir => $log_dir, + use_syslog => $use_syslog, + syslog_log_facility => $log_facility } trove::generic_service { 'taskmanager': diff --git a/spec/classes/trove_conductor_spec.rb b/spec/classes/trove_conductor_spec.rb index 0dfc2c5c..71bda2d3 100644 --- a/spec/classes/trove_conductor_spec.rb +++ b/spec/classes/trove_conductor_spec.rb @@ -26,8 +26,12 @@ describe 'trove::conductor' do end it 'configures trove-conductor with default parameters' do - is_expected.to contain_trove_conductor_config('DEFAULT/verbose').with_value(false) - is_expected.to contain_trove_conductor_config('DEFAULT/debug').with_value(false) + is_expected.to contain_trove_conductor_config('DEFAULT/verbose').with_value('') + is_expected.to contain_trove_conductor_config('DEFAULT/debug').with_value('') + is_expected.to contain_trove_conductor_config('DEFAULT/use_syslog').with_value('') + is_expected.to contain_trove_conductor_config('DEFAULT/syslog_log_facility').with_value('') + is_expected.to contain_trove_conductor_config('DEFAULT/log_file').with_value('/var/log/trove/trove-conductor.log') + is_expected.to contain_trove_conductor_config('DEFAULT/log_dir').with_value('/var/log/trove') is_expected.to contain_trove_conductor_config('DEFAULT/nova_proxy_admin_user').with_value('admin') is_expected.to contain_trove_conductor_config('DEFAULT/nova_proxy_admin_pass').with_value('verysecrete') is_expected.to contain_trove_conductor_config('DEFAULT/nova_proxy_admin_tenant_name').with_value('admin') diff --git a/spec/classes/trove_guestagent_spec.rb b/spec/classes/trove_guestagent_spec.rb index 06cf1658..59265dc3 100644 --- a/spec/classes/trove_guestagent_spec.rb +++ b/spec/classes/trove_guestagent_spec.rb @@ -27,8 +27,12 @@ describe 'trove::guestagent' do end it 'configures trove-guestagent with default parameters' do - is_expected.to contain_trove_guestagent_config('DEFAULT/verbose').with_value(false) - is_expected.to contain_trove_guestagent_config('DEFAULT/debug').with_value(false) + is_expected.to contain_trove_guestagent_config('DEFAULT/verbose').with_value('') + is_expected.to contain_trove_guestagent_config('DEFAULT/debug').with_value('') + is_expected.to contain_trove_guestagent_config('DEFAULT/use_syslog').with_value('') + is_expected.to contain_trove_guestagent_config('DEFAULT/syslog_log_facility').with_value('') + is_expected.to contain_trove_guestagent_config('DEFAULT/log_file').with_value('/var/log/trove/guestagent.log') + is_expected.to contain_trove_guestagent_config('DEFAULT/log_dir').with_value('/var/log/trove') is_expected.to contain_trove_guestagent_config('DEFAULT/os_region_name').with_value('RegionOne') is_expected.to contain_trove_guestagent_config('oslo_messaging_notifications/driver').with_value('') is_expected.to contain_trove_guestagent_config('oslo_messaging_notifications/topics').with_value('') diff --git a/spec/classes/trove_taskmanager_spec.rb b/spec/classes/trove_taskmanager_spec.rb index 32c7333a..4f79b059 100644 --- a/spec/classes/trove_taskmanager_spec.rb +++ b/spec/classes/trove_taskmanager_spec.rb @@ -51,8 +51,12 @@ describe 'trove::taskmanager' do end it 'configures trove-taskmanager with default parameters' do - is_expected.to contain_trove_taskmanager_config('DEFAULT/verbose').with_value(false) - is_expected.to contain_trove_taskmanager_config('DEFAULT/debug').with_value(false) + is_expected.to contain_trove_taskmanager_config('DEFAULT/verbose').with_value('') + is_expected.to contain_trove_taskmanager_config('DEFAULT/debug').with_value('') + is_expected.to contain_trove_taskmanager_config('DEFAULT/use_syslog').with_value('') + is_expected.to contain_trove_taskmanager_config('DEFAULT/syslog_log_facility').with_value('') + is_expected.to contain_trove_taskmanager_config('DEFAULT/log_file').with_value('/var/log/trove/trove-taskmanager.log') + is_expected.to contain_trove_taskmanager_config('DEFAULT/log_dir').with_value('/var/log/trove') is_expected.to contain_trove_taskmanager_config('DEFAULT/nova_proxy_admin_user').with_value('admin') is_expected.to contain_trove_taskmanager_config('DEFAULT/nova_proxy_admin_pass').with_value('verysecrete') is_expected.to contain_trove_taskmanager_config('DEFAULT/nova_proxy_admin_tenant_name').with_value('admin')