Adds log_filters parameter to nova::compute::libvirt

Defines a filter to select a different logging level
for a given category log outputs, as specified in
https://libvirt.org/logging.html. Default undef

Change-Id: Ic48afe856ae60654d6cebf627b12509881933c59
Related-Bug: #1840140
(cherry picked from commit 0b0bd40065)
(cherry picked from commit 749e4fbb25)
(cherry picked from commit bb8ff6cdc4)
This commit is contained in:
Martin Schuppert 2019-08-14 13:46:55 +02:00
parent 88cff3858f
commit 78e70e16e2
3 changed files with 23 additions and 0 deletions

View File

@ -153,6 +153,12 @@
# zero or negative value mean to disable memory usage statistics. # zero or negative value mean to disable memory usage statistics.
# Defaults to $::os_service_default # Defaults to $::os_service_default
# #
# [*log_filters*]
# (optional) Defines a filter to select a different logging level
# for a given category log outputs, as specified in
# https://libvirt.org/logging.html
# Defaults to undef
#
class nova::compute::libvirt ( class nova::compute::libvirt (
$ensure_package = 'present', $ensure_package = 'present',
$libvirt_virt_type = 'kvm', $libvirt_virt_type = 'kvm',
@ -182,6 +188,7 @@ class nova::compute::libvirt (
$volume_use_multipath = $::os_service_default, $volume_use_multipath = $::os_service_default,
$nfs_mount_options = $::os_service_default, $nfs_mount_options = $::os_service_default,
$mem_stats_period_seconds = $::os_service_default, $mem_stats_period_seconds = $::os_service_default,
$log_filters = undef,
) inherits nova::params { ) inherits nova::params {
include ::nova::deps include ::nova::deps
@ -218,6 +225,12 @@ class nova::compute::libvirt (
} }
} }
if $log_filters {
libvirtd_config {
'log_filters': value => "\"${log_filters}\"";
}
}
# manage_libvirt_services is here for backward compatibility to support # manage_libvirt_services is here for backward compatibility to support
# deployments that do not include nova::compute::libvirt::services # deployments that do not include nova::compute::libvirt::services
# #

View File

@ -0,0 +1,7 @@
---
features:
- |
Adds log_filters parameter to nova::compute::libvirt.
Defines a filter to select a different logging level
for a given category log outputs, as specified in
https://libvirt.org/logging.html . Default undef

View File

@ -63,6 +63,7 @@ describe 'nova::compute::libvirt' do
it { is_expected.to contain_nova_config('libvirt/volume_use_multipath').with_value('<SERVICE DEFAULT>')} it { is_expected.to contain_nova_config('libvirt/volume_use_multipath').with_value('<SERVICE DEFAULT>')}
it { is_expected.to contain_nova_config('libvirt/nfs_mount_options').with_ensure('<SERVICE DEFAULT>')} it { is_expected.to contain_nova_config('libvirt/nfs_mount_options').with_ensure('<SERVICE DEFAULT>')}
it { is_expected.to contain_nova_config('libvirt/mem_stats_period_seconds').with_value('<SERVICE DEFAULT>')} it { is_expected.to contain_nova_config('libvirt/mem_stats_period_seconds').with_value('<SERVICE DEFAULT>')}
it { is_expected.to contain_libvirtd_config('log_filters').with_ensure('absent')}
end end
describe 'with params' do describe 'with params' do
@ -90,6 +91,7 @@ describe 'nova::compute::libvirt' do
:volume_use_multipath => false, :volume_use_multipath => false,
:nfs_mount_options => 'rw,intr,nolock', :nfs_mount_options => 'rw,intr,nolock',
:mem_stats_period_seconds => 20, :mem_stats_period_seconds => 20,
:log_filters => '1:qemu',
} }
end end
@ -116,6 +118,7 @@ describe 'nova::compute::libvirt' do
it { is_expected.to contain_nova_config('libvirt/volume_use_multipath').with_value(false)} it { is_expected.to contain_nova_config('libvirt/volume_use_multipath').with_value(false)}
it { is_expected.to contain_nova_config('libvirt/nfs_mount_options').with_value('rw,intr,nolock')} it { is_expected.to contain_nova_config('libvirt/nfs_mount_options').with_value('rw,intr,nolock')}
it { is_expected.to contain_nova_config('libvirt/mem_stats_period_seconds').with_value(20)} it { is_expected.to contain_nova_config('libvirt/mem_stats_period_seconds').with_value(20)}
it { is_expected.to contain_libvirtd_config('log_filters').with_value("\"#{params[:log_filters]}\"")}
it { it {
is_expected.to contain_service('libvirt').with( is_expected.to contain_service('libvirt').with(
:name => 'custom_service', :name => 'custom_service',