Browse Source

Cleanup listen option from libvirtd service file

This patch ensures that listen option is removed from service file when
libvirt>=5.6 is used, since the option might be left if the deployment
is updated or upgraded from old version.

Related-Bug: #1898553
Related-Bug: #1880619
Change-Id: Ifb0f5e1d7db31885636f689166ff666b049e9414
(cherry picked from commit 2058576291)
changes/18/758018/2
Takashi Kajinami 10 months ago
parent
commit
8ab5642322
  1. 82
      manifests/migration/libvirt.pp
  2. 40
      spec/classes/nova_migration_libvirt_spec.rb

82
manifests/migration/libvirt.pp

@ -237,53 +237,61 @@ class nova::migration::libvirt(
}
}
if versioncmp($libvirt_version, '5.6') >= 0 {
# Since libvirt >= 5.6 and libvirtd is managed by systemd,
# system socket should be activated by systemd, not by --listen option
$manage_services = pick($::nova::compute::libvirt::manage_libvirt_services, true)
if $transport_real == 'tls' or $transport_real == 'tcp' {
if versioncmp($libvirt_version, '5.6') >= 0 {
# Since libvirt >= 5.6 and libvirtd is managed by systemd,
# system socket should be activated by systemd, not by --listen option
$manage_services = pick($::nova::compute::libvirt::manage_libvirt_services, true)
if $manage_services {
if $transport_real == 'tls' {
service { 'libvirtd-tls':
if $manage_services {
service { "libvirtd-${transport_real}":
ensure => 'running',
name => 'libvirtd-tls.socket',
name => "libvirtd-${transport_real}.socket",
enable => true,
require => Anchor['nova::config::end']
}
Service['libvirtd-tls'] -> Service<| title == 'libvirt' |>
} elsif $transport_real == 'tcp' {
service { 'libvirtd-tcp':
ensure => 'running',
name => 'libvirtd-tcp.socket',
enable => true,
require => Anchor['nova::config::end']
}
Service['libvirtd-tcp'] -> Service<| title == 'libvirt' |>
Service["libvirtd-${transport_real}"] -> Service<| title == 'libvirt' |>
}
# --listen option should be disabled in newer libvirt
$libvirtd_service_listen = false
} else {
# For older libvirt --listen option should be used.
$libvirtd_service_listen = true
}
} else {
# For older libvirt --listen option should be used.
if $transport_real == 'tls' or $transport_real == 'tcp' {
case $::osfamily {
'RedHat': {
file_line { '/etc/sysconfig/libvirtd libvirtd args':
path => '/etc/sysconfig/libvirtd',
line => 'LIBVIRTD_ARGS="--listen"',
match => '^LIBVIRTD_ARGS=',
tag => 'libvirt-file_line',
}
case $::osfamily {
'RedHat': {
if $libvirtd_service_listen {
$libvirtd_args = '"--listen"'
} else {
$libvirtd_args = ''
}
'Debian': {
file_line { "/etc/default/${::nova::compute::libvirt::libvirt_service_name} libvirtd opts":
path => "/etc/default/${::nova::compute::libvirt::libvirt_service_name}",
line => 'libvirtd_opts="-l"',
match => 'libvirtd_opts=',
tag => 'libvirt-file_line',
}
file_line { '/etc/sysconfig/libvirtd libvirtd args':
path => '/etc/sysconfig/libvirtd',
line => "LIBVIRTD_ARGS=${libvirtd_args}",
match => '^LIBVIRTD_ARGS=',
tag => 'libvirt-file_line',
}
default: {
warning("Unsupported osfamily: ${::osfamily}, make sure you are configuring this yourself")
}
'Debian': {
if $libvirtd_service_listen {
$libvirtd_opts = '"-l"'
} else {
$libvirtd_opts = ''
}
file_line { "/etc/default/${::nova::compute::libvirt::libvirt_service_name} libvirtd opts":
path => "/etc/default/${::nova::compute::libvirt::libvirt_service_name}",
line => "libvirtd_opts=${libvirtd_opts}",
match => 'libvirtd_opts=',
tag => 'libvirt-file_line',
}
}
default: {
warning("Unsupported osfamily: ${::osfamily}, make sure you are configuring this yourself")
}
}
}

40
spec/classes/nova_migration_libvirt_spec.rb

@ -263,7 +263,12 @@ describe 'nova::migration::libvirt' do
:libvirt_version => '6.0' }
end
it { is_expected.to_not contain_file_line('/etc/default/libvirtd libvirtd opts') }
it { is_expected.to contain_file_line('/etc/default/libvirtd libvirtd opts').with(
:path => '/etc/default/libvirtd',
:line => 'libvirtd_opts=',
:match => 'libvirtd_opts=',
:tag => 'libvirt-file_line',
) }
it { is_expected.to contain_service('libvirtd-tls').with(
:name => 'libvirtd-tls.socket',
:ensure => 'running',
@ -277,7 +282,12 @@ describe 'nova::migration::libvirt' do
:libvirt_version => '6.0' }
end
it { is_expected.to_not contain_file_line('/etc/default/libvirtd libvirtd opts') }
it { is_expected.to contain_file_line('/etc/default/libvirtd libvirtd opts').with(
:path => '/etc/default/libvirtd',
:line => 'libvirtd_opts=',
:match => 'libvirtd_opts=',
:tag => 'libvirt-file_line',
) }
it { is_expected.to contain_service('libvirtd-tcp').with(
:name => 'libvirtd-tcp.socket',
:ensure => 'running',
@ -289,10 +299,10 @@ describe 'nova::migration::libvirt' do
shared_examples_for 'nova migration with libvirt in RedHat' do
context 'with libvirt < 5.6' do
let :params do
{ :transport => 'tls',
:libvirt_version => '4.5' }
end
let :params do
{ :transport => 'tls',
:libvirt_version => '4.5' }
end
it { is_expected.to contain_file_line('/etc/sysconfig/libvirtd libvirtd args').with(
:path => '/etc/sysconfig/libvirtd',
@ -312,12 +322,17 @@ describe 'nova::migration::libvirt' do
:libvirt_version => '5.6' }
end
it { is_expected.to_not contain_file_line('/etc/sysconfig/libvirtd libvirtd args') }
it { is_expected.to contain_file_line('/etc/sysconfig/libvirtd libvirtd args').with(
:path => '/etc/sysconfig/libvirtd',
:line => 'LIBVIRTD_ARGS=',
:match => '^LIBVIRTD_ARGS=',
:tag => 'libvirt-file_line',
)}
it { is_expected.to contain_service('libvirtd-tls').with(
:name => 'libvirtd-tls.socket',
:ensure => 'running',
:enable => true,
)}
)}
end
context 'with tcp transport' do
@ -326,12 +341,17 @@ describe 'nova::migration::libvirt' do
:libvirt_version => '5.6' }
end
it { is_expected.to_not contain_file_line('/etc/sysconfig/libvirtd libvirtd args') }
it { is_expected.to contain_file_line('/etc/sysconfig/libvirtd libvirtd args').with(
:path => '/etc/sysconfig/libvirtd',
:line => 'LIBVIRTD_ARGS=',
:match => '^LIBVIRTD_ARGS=',
:tag => 'libvirt-file_line',
)}
it { is_expected.to contain_service('libvirtd-tcp').with(
:name => 'libvirtd-tcp.socket',
:ensure => 'running',
:enable => true,
)}
)}
end
end
end

Loading…
Cancel
Save