From d88dc6659c45f1011a09ecb05794eb35f7ac834d Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Thu, 23 Nov 2023 02:08:32 +0900 Subject: [PATCH] libvirt-guests: Improve parameter coverage This introduces support for a few more parameters in libvirt-guests service. Change-Id: I99ddef51ef60ae1b1bc6c43643cce7596457b598 --- manifests/compute/libvirt_guests.pp | 96 ++++++++++++++++++- ...ibvirt-guests-params-e895c3e8d59384a3.yaml | 10 ++ .../nova_compute_libvirt_guests_spec.rb | 66 ++++++++++++- 3 files changed, 166 insertions(+), 6 deletions(-) create mode 100644 releasenotes/notes/libvirt-guests-params-e895c3e8d59384a3.yaml diff --git a/manifests/compute/libvirt_guests.pp b/manifests/compute/libvirt_guests.pp index cc957c232..9b753a5c2 100644 --- a/manifests/compute/libvirt_guests.pp +++ b/manifests/compute/libvirt_guests.pp @@ -33,6 +33,18 @@ # value suitable for your guests. # Defaults to 'shutdown' # +# [*start_delay*] +# (optional) Number of seconds to wait between each guest start. Set 0 to +# allow parallel startup. +# Defaults to undef +# +# [*parallel_shutdown*] +# (optional) Number of guests will be shutdown concurrently, taking effect +# when "ON_SHUTDOWN" is set to "shutdown". If set to 0, guests will be +# shutdown one after another. Number of guests on shutdown at any time will +# not exceed number set in this variable. +# Defaults to undef +# # [*shutdown_timeout*] # (optional) Number of seconds we're willing to wait for a guest to shut # down. If parallel shutdown is enabled, this timeout applies as a timeout @@ -41,6 +53,16 @@ # not respond to a shutdown request). # Defaults to undef # +# [*bypass_cache*] +# (optional) Try to bypass the file system cache when saving and restoring +# guests, even though this may give slower operation for some file systems. +# Defaults to false +# +# [*sync_time*] +# (optional) Try to sync guest time on domain resume. Be aware, that this +# requires guest agent support for time synchronization running in the guest. +# Defaults to false +# # [*manage_service*] # (optional) Whether to start/stop the service # Defaults to false @@ -48,9 +70,13 @@ class nova::compute::libvirt_guests ( Boolean $enabled = false, $package_ensure = 'present', - $shutdown_timeout = undef, $on_boot = 'ignore', $on_shutdown = 'shutdown', + $start_delay = undef, + $parallel_shutdown = undef, + $shutdown_timeout = undef, + Boolean $bypass_cache = false, + Boolean $sync_time = false, Boolean $manage_service = false, ) { include nova::params @@ -81,6 +107,40 @@ class nova::compute::libvirt_guests ( tag => 'libvirt-guests-file_line', } + if $start_delay { + file_line { 'libvirt-guests START_DELAY': + path => $::nova::params::libvirt_guests_environment_file, + line => "START_DELAY=${start_delay}", + match => '^START_DELAY=.*', + tag => 'libvirt-guests-file_line', + } + } else { + file_line { 'libvirt-guests START_DELAY': + ensure => absent, + path => $::nova::params::libvirt_guests_environment_file, + match => '^START_DELAY=.*', + match_for_absence => true, + tag => 'libvirt-guests-file_line', + } + } + + if $parallel_shutdown { + file_line { 'libvirt-guests PARALLEL_SHUTDOWN': + path => $::nova::params::libvirt_guests_environment_file, + line => "PARALLEL_SHUTDOWN=${parallel_shutdown}", + match => '^PARALLEL_SHUTDOWN=.*', + tag => 'libvirt-guests-file_line', + } + } else { + file_line { 'libvirt-guests PARALLEL_SHUTDOWN': + ensure => absent, + path => $::nova::params::libvirt_guests_environment_file, + match => '^PARALLEL_SHUTDOWN=.*', + match_for_absence => true, + tag => 'libvirt-guests-file_line', + } + } + if $shutdown_timeout { file_line { 'libvirt-guests SHUTDOWN_TIMEOUT': path => $::nova::params::libvirt_guests_environment_file, @@ -98,6 +158,40 @@ class nova::compute::libvirt_guests ( } } + if $bypass_cache { + file_line { 'libvirt-guests BYPASS_CACHE': + path => $::nova::params::libvirt_guests_environment_file, + line => 'BYPASS_CACHE=1', + match => '^BYPASS_CACHE=.*', + tag => 'libvirt-guests-file_line', + } + } else { + file_line { 'libvirt-guests BYPASS_CACHE': + ensure => absent, + path => $::nova::params::libvirt_guests_environment_file, + match => '^BYPASS_CACHE=.*', + match_for_absence => true, + tag => 'libvirt-guests-file_line', + } + } + + if $sync_time { + file_line { 'libvirt-guests SYNC_TIME': + path => $::nova::params::libvirt_guests_environment_file, + line => 'SYNC_TIME=1', + match => '^SYNC_TIME=.*', + tag => 'libvirt-guests-file_line', + } + } else { + file_line { 'libvirt-guests SYNC_TIME': + ensure => absent, + path => $::nova::params::libvirt_guests_environment_file, + match => '^SYNC_TIME=.*', + match_for_absence => true, + tag => 'libvirt-guests-file_line', + } + } + package { 'libvirt-client': ensure => $package_ensure, name => $::nova::params::libvirt_client_package_name, diff --git a/releasenotes/notes/libvirt-guests-params-e895c3e8d59384a3.yaml b/releasenotes/notes/libvirt-guests-params-e895c3e8d59384a3.yaml new file mode 100644 index 000000000..a28a9d875 --- /dev/null +++ b/releasenotes/notes/libvirt-guests-params-e895c3e8d59384a3.yaml @@ -0,0 +1,10 @@ +--- +features: + - | + The ``nova::compute::libvirt_guests`` class now supports the following + parameters. + + - ``start_delay`` + - ``parallel_shutdown`` + - ``bypass_cache`` + - ``sync_time`` diff --git a/spec/classes/nova_compute_libvirt_guests_spec.rb b/spec/classes/nova_compute_libvirt_guests_spec.rb index c9d5eb99b..f7bd42d80 100644 --- a/spec/classes/nova_compute_libvirt_guests_spec.rb +++ b/spec/classes/nova_compute_libvirt_guests_spec.rb @@ -20,6 +20,13 @@ describe 'nova::compute::libvirt_guests' do :match => '^ON_SHUTDOWN=.*', :tag => 'libvirt-guests-file_line' ) } + it { is_expected.to contain_file_line('libvirt-guests START_DELAY').with( + :ensure => 'absent', + :path => platform_params[:libvirt_guests_environment_file], + :match => '^START_DELAY=.*', + :match_for_absence => true, + :tag => 'libvirt-guests-file_line' + ) } it { is_expected.to contain_file_line('libvirt-guests SHUTDOWN_TIMEOUT').with( :ensure => 'absent', :path => platform_params[:libvirt_guests_environment_file], @@ -27,6 +34,27 @@ describe 'nova::compute::libvirt_guests' do :match_for_absence => true, :tag => 'libvirt-guests-file_line' ) } + it { is_expected.to contain_file_line('libvirt-guests PARALLEL_SHUTDOWN').with( + :ensure => 'absent', + :path => platform_params[:libvirt_guests_environment_file], + :match => '^PARALLEL_SHUTDOWN=.*', + :match_for_absence => true, + :tag => 'libvirt-guests-file_line' + ) } + it { is_expected.to contain_file_line('libvirt-guests BYPASS_CACHE').with( + :ensure => 'absent', + :path => platform_params[:libvirt_guests_environment_file], + :match => '^BYPASS_CACHE=.*', + :match_for_absence => true, + :tag => 'libvirt-guests-file_line' + ) } + it { is_expected.to contain_file_line('libvirt-guests SYNC_TIME').with( + :ensure => 'absent', + :path => platform_params[:libvirt_guests_environment_file], + :match => '^SYNC_TIME=.*', + :match_for_absence => true, + :tag => 'libvirt-guests-file_line' + ) } it { is_expected.to contain_package('libvirt-client').with( :name => platform_params[:libvirt_client_package_name], @@ -39,11 +67,15 @@ describe 'nova::compute::libvirt_guests' do context 'with params' do let :params do { - :enabled => true, - :manage_service => true, - :on_boot => 'start', - :on_shutdown => 'suspend', - :shutdown_timeout => 300, + :enabled => true, + :manage_service => true, + :on_boot => 'start', + :on_shutdown => 'suspend', + :start_delay => 0, + :shutdown_timeout => 300, + :parallel_shutdown => 0, + :bypass_cache => true, + :sync_time => true, } end @@ -59,12 +91,36 @@ describe 'nova::compute::libvirt_guests' do :match => '^ON_SHUTDOWN=.*', :tag => 'libvirt-guests-file_line' ) } + it { is_expected.to contain_file_line('libvirt-guests START_DELAY').with( + :path => platform_params[:libvirt_guests_environment_file], + :line => 'START_DELAY=0', + :match => '^START_DELAY=.*', + :tag => 'libvirt-guests-file_line' + ) } it { is_expected.to contain_file_line('libvirt-guests SHUTDOWN_TIMEOUT').with( :path => platform_params[:libvirt_guests_environment_file], :line => "SHUTDOWN_TIMEOUT=300", :match => '^SHUTDOWN_TIMEOUT=.*', :tag => 'libvirt-guests-file_line' ) } + it { is_expected.to contain_file_line('libvirt-guests PARALLEL_SHUTDOWN').with( + :path => platform_params[:libvirt_guests_environment_file], + :line => "PARALLEL_SHUTDOWN=0", + :match => '^PARALLEL_SHUTDOWN=.*', + :tag => 'libvirt-guests-file_line' + ) } + it { is_expected.to contain_file_line('libvirt-guests BYPASS_CACHE').with( + :path => platform_params[:libvirt_guests_environment_file], + :line => "BYPASS_CACHE=1", + :match => '^BYPASS_CACHE=.*', + :tag => 'libvirt-guests-file_line' + ) } + it { is_expected.to contain_file_line('libvirt-guests SYNC_TIME').with( + :path => platform_params[:libvirt_guests_environment_file], + :line => "SYNC_TIME=1", + :match => '^SYNC_TIME=.*', + :tag => 'libvirt-guests-file_line' + ) } it { is_expected.to contain_package('libvirt-client').with( :name => platform_params[:libvirt_client_package_name],