From 0b0bd400659e5e545173417816ec346249f4860e Mon Sep 17 00:00:00 2001 From: Martin Schuppert Date: Wed, 14 Aug 2019 13:46:55 +0200 Subject: [PATCH] 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 --- manifests/compute/libvirt.pp | 13 +++++++++++++ .../libvirtd_log_filters-22e461e00f482d69.yaml | 7 +++++++ spec/classes/nova_compute_libvirt_spec.rb | 3 +++ 3 files changed, 23 insertions(+) create mode 100644 releasenotes/notes/libvirtd_log_filters-22e461e00f482d69.yaml diff --git a/manifests/compute/libvirt.pp b/manifests/compute/libvirt.pp index 2500daad5..eda807c89 100644 --- a/manifests/compute/libvirt.pp +++ b/manifests/compute/libvirt.pp @@ -174,6 +174,12 @@ # zero or negative value mean to disable memory usage statistics. # 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 ( $ensure_package = 'present', $libvirt_virt_type = 'kvm', @@ -207,6 +213,7 @@ class nova::compute::libvirt ( $nfs_mount_options = $::os_service_default, $num_pcie_ports = $::os_service_default, $mem_stats_period_seconds = $::os_service_default, + $log_filters = undef, ) inherits nova::params { include ::nova::deps @@ -243,6 +250,12 @@ class nova::compute::libvirt ( } } + if $log_filters { + libvirtd_config { + 'log_filters': value => "\"${log_filters}\""; + } + } + unless $rx_queue_size == $::os_service_default or $rx_queue_size in [256, 512, 1024] { fail("Invalid rx_queue_size parameter: ${rx_queue_size}") } diff --git a/releasenotes/notes/libvirtd_log_filters-22e461e00f482d69.yaml b/releasenotes/notes/libvirtd_log_filters-22e461e00f482d69.yaml new file mode 100644 index 000000000..6c7ea4c6d --- /dev/null +++ b/releasenotes/notes/libvirtd_log_filters-22e461e00f482d69.yaml @@ -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 diff --git a/spec/classes/nova_compute_libvirt_spec.rb b/spec/classes/nova_compute_libvirt_spec.rb index 3721f5916..ca15c72c8 100644 --- a/spec/classes/nova_compute_libvirt_spec.rb +++ b/spec/classes/nova_compute_libvirt_spec.rb @@ -68,6 +68,7 @@ describe 'nova::compute::libvirt' do it { is_expected.to contain_nova_config('libvirt/nfs_mount_options').with_ensure('')} it { is_expected.to contain_nova_config('libvirt/num_pcie_ports').with_ensure('')} it { is_expected.to contain_nova_config('libvirt/mem_stats_period_seconds').with_value('')} + it { is_expected.to contain_libvirtd_config('log_filters').with_ensure('absent')} end describe 'with params' do @@ -98,6 +99,7 @@ describe 'nova::compute::libvirt' do :nfs_mount_options => 'rw,intr,nolock', :num_pcie_ports => 16, :mem_stats_period_seconds => 20, + :log_filters => '1:qemu', } end @@ -127,6 +129,7 @@ describe 'nova::compute::libvirt' do it { is_expected.to contain_nova_config('libvirt/nfs_mount_options').with_value('rw,intr,nolock')} it { is_expected.to contain_nova_config('libvirt/num_pcie_ports').with_value(16)} 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 { is_expected.to contain_service('libvirt').with( :name => 'custom_service',