Merge "Drop support for old libvirt package"

This commit is contained in:
Zuul
2022-02-15 14:45:01 +00:00
committed by Gerrit Code Review
6 changed files with 130 additions and 290 deletions

View File

@@ -62,6 +62,10 @@ class nova::compute::libvirt::qemu(
include nova::deps
require nova::compute::libvirt
if versioncmp($libvirt_version, '4.5') < 0 {
fail('libvirt verson < 4.5 is no longer supported')
}
Anchor['nova::config::begin']
-> Augeas<| tag == 'qemu-conf-augeas'|>
-> Anchor['nova::config::end']
@@ -107,11 +111,7 @@ class nova::compute::libvirt::qemu(
} else {
$augues_memory_backing_dir_changes = []
}
if versioncmp($libvirt_version, '4.5') >= 0 {
$augues_nbd_tls_changes = ["set nbd_tls ${nbd_tls_value}"]
} else {
$augues_nbd_tls_changes = []
}
$augues_nbd_tls_changes = ["set nbd_tls ${nbd_tls_value}"]
$augues_changes = concat($augues_changes_default, $augues_group_changes, $augues_memory_backing_dir_changes, $augues_nbd_tls_changes)
@@ -122,7 +122,7 @@ class nova::compute::libvirt::qemu(
}
} else {
$augues_changes_default = [
$augues_changes = [
'rm max_files',
'rm max_processes',
'rm group',
@@ -130,14 +130,8 @@ class nova::compute::libvirt::qemu(
'rm vnc_tls_x509_verify',
'rm default_tls_x509_verify',
'rm memory_backing_dir',
'rm nbd_tls',
]
if versioncmp($libvirt_version, '4.5') >= 0 {
$augues_nbd_tls_changes = ['rm nbd_tls']
} else {
$augues_nbd_tls_changes = []
}
$augues_changes = concat($augues_changes_default, $augues_nbd_tls_changes)
augeas { 'qemu-conf-limits':
context => '/files/etc/libvirt/qemu.conf',

View File

@@ -8,20 +8,14 @@
class nova::compute::libvirt::version {
case $facts['os']['family'] {
'RedHat': {
if versioncmp($facts['os']['release']['full'], '8') >= 0 {
$default = '5.6'
} elsif versioncmp($facts['os']['release']['full'], '7.6') >= 0 {
$default = '4.5'
if versioncmp($facts['os']['release']['full'], '9') >= 0 {
$default = '7.0'
} else {
$default = '3.9'
$default = '5.6'
}
}
'Debian': {
if versioncmp($facts['os']['release']['full'], '18.04') >= 0 {
$default = '6.0'
} else {
$default = '4.0'
}
$default = '6.0'
}
default: {
fail("Class['nova::compute::libvirt::version']: Unsupported osfamily: ${::osfamily}")

View File

@@ -308,79 +308,61 @@ class nova::migration::libvirt(
})
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 and !$modular_libvirt_real {
# libvirtd.service should be stopped before socket service is started.
# Otherwise, socket service fails to start.
exec { 'stop libvirtd.service':
path => ['/sbin', '/usr/sbin', '/bin', '/usr/bin'],
command => 'systemctl -q stop libvirtd.service',
unless => "systemctl -q is-active libvirtd-${transport_real}.socket",
require => Anchor['nova::install::end']
}
service { "libvirtd-${transport_real}":
ensure => 'running',
name => "libvirtd-${transport_real}.socket",
enable => true,
require => Anchor['nova::config::end']
}
Exec['stop libvirtd.service'] -> 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
if versioncmp($libvirt_version, '5.6') < 0 {
fail('libvirt verson < 5.6 is no longer supported')
}
# Since libvirt >= 5.6, system socket of libvirt should be activated
# by systemd, not by --listen option
$manage_services = pick($::nova::compute::libvirt::manage_libvirt_services, true)
case $::osfamily {
'RedHat': {
if $libvirtd_service_listen {
$libvirtd_args = '"--listen"'
} else {
$libvirtd_args = ''
}
# NOTE(tkajinam): Since libvirt 8.1.0, the sysconfig files are
# no longer provided by packages.
file { '/etc/sysconfig/libvirtd':
ensure => present,
path => '/etc/sysconfig/libvirtd',
tag => 'libvirt-file',
}
file_line { '/etc/sysconfig/libvirtd libvirtd args':
path => '/etc/sysconfig/libvirtd',
line => "LIBVIRTD_ARGS=${libvirtd_args}",
match => '^LIBVIRTD_ARGS=',
tag => 'libvirt-file_line',
}
if $manage_services and !$modular_libvirt_real {
# libvirtd.service should be stopped before socket service is started.
# Otherwise, socket service fails to start.
exec { 'stop libvirtd.service':
path => ['/sbin', '/usr/sbin', '/bin', '/usr/bin'],
command => 'systemctl -q stop libvirtd.service',
unless => "systemctl -q is-active libvirtd-${transport_real}.socket",
require => Anchor['nova::install::end']
}
'Debian': {
if $libvirtd_service_listen {
$libvirtd_opts = '"-l"'
} else {
$libvirtd_opts = ''
}
file_line { '/etc/default/libvirtd libvirtd opts':
path => '/etc/default/libvirtd',
line => "libvirtd_opts=${libvirtd_opts}",
match => 'libvirtd_opts=',
tag => 'libvirt-file_line',
}
service { "libvirtd-${transport_real}":
ensure => 'running',
name => "libvirtd-${transport_real}.socket",
enable => true,
require => Anchor['nova::config::end']
}
default: {
warning("Unsupported osfamily: ${::osfamily}, make sure you are configuring this yourself")
Exec['stop libvirtd.service'] -> Service["libvirtd-${transport_real}"] -> Service<| title == 'libvirt' |>
}
}
case $::osfamily {
'RedHat': {
# NOTE(tkajinam): Since libvirt 8.1.0, the sysconfig files are
# no longer provided by packages.
file { '/etc/sysconfig/libvirtd':
ensure => present,
path => '/etc/sysconfig/libvirtd',
tag => 'libvirt-file',
}
file_line { '/etc/sysconfig/libvirtd libvirtd args':
path => '/etc/sysconfig/libvirtd',
line => 'LIBVIRTD_ARGS=',
match => '^LIBVIRTD_ARGS=',
tag => 'libvirt-file_line',
}
}
'Debian': {
file_line { '/etc/default/libvirtd libvirtd opts':
path => '/etc/default/libvirtd',
line => 'libvirtd_opts=',
match => 'libvirtd_opts=',
tag => 'libvirt-file_line',
}
}
default: {
warning("Unsupported osfamily: ${::osfamily}, make sure you are configuring this yourself")
}
}
}

View File

@@ -0,0 +1,4 @@
---
upgrade:
- |
Now puppet-nova requires libvirt 5.6 or later.

View File

@@ -13,29 +13,7 @@ describe 'nova::compute::libvirt::qemu' do
context 'when not configuring qemu' do
let :params do
{
:configure_qemu => false,
:libvirt_version => '3.9',
}
end
it { is_expected.to contain_augeas('qemu-conf-limits').with({
:context => '/files/etc/libvirt/qemu.conf',
:changes => [
"rm max_files",
"rm max_processes",
"rm group",
"rm vnc_tls",
"rm vnc_tls_x509_verify",
"rm default_tls_x509_verify",
"rm memory_backing_dir",
],
}).that_notifies('Service[libvirt]') }
end
context 'when not configuring qemu with libvirt >= 4.5' do
let :params do
{
:configure_qemu => false,
:libvirt_version => '4.5',
:configure_qemu => false,
}
end
it { is_expected.to contain_augeas('qemu-conf-limits').with({
@@ -57,27 +35,6 @@ describe 'nova::compute::libvirt::qemu' do
let :params do
{
:configure_qemu => true,
:libvirt_version => '3.9',
}
end
it { is_expected.to contain_augeas('qemu-conf-limits').with({
:context => '/files/etc/libvirt/qemu.conf',
:changes => [
"set max_files 1024",
"set max_processes 4096",
"set vnc_tls 0",
"set vnc_tls_x509_verify 0",
"set default_tls_x509_verify 1",
],
:tag => 'qemu-conf-augeas',
}).that_notifies('Service[libvirt]') }
end
context 'when configuring qemu by default with libvirt >= 4.5' do
let :params do
{
:configure_qemu => true,
:libvirt_version => '4.5',
}
end
it { is_expected.to contain_augeas('qemu-conf-limits').with({
@@ -98,31 +55,8 @@ describe 'nova::compute::libvirt::qemu' do
let :params do
{
:configure_qemu => true,
:max_files => 32768,
:max_processes => 131072,
:libvirt_version => '3.9',
}
end
it { is_expected.to contain_augeas('qemu-conf-limits').with({
:context => '/files/etc/libvirt/qemu.conf',
:changes => [
"set max_files 32768",
"set max_processes 131072",
"set vnc_tls 0",
"set vnc_tls_x509_verify 0",
"set default_tls_x509_verify 1",
],
:tag => 'qemu-conf-augeas',
}).that_notifies('Service[libvirt]') }
end
context 'when configuring qemu with overridden parameters with libvirt >= 4.5' do
let :params do
{
:configure_qemu => true,
:max_files => 32768,
:max_processes => 131072,
:libvirt_version => '4.5',
:max_files => 32768,
:max_processes => 131072,
}
end
it { is_expected.to contain_augeas('qemu-conf-limits').with({
@@ -142,12 +76,11 @@ describe 'nova::compute::libvirt::qemu' do
context 'when configuring qemu with group parameter' do
let :params do
{
:configure_qemu => true,
:group => 'openvswitch',
:max_files => 32768,
:max_processes => 131072,
:configure_qemu => true,
:group => 'openvswitch',
:max_files => 32768,
:max_processes => 131072,
:memory_backing_dir => '/tmp',
:libvirt_version => '3.9',
}
end
it { is_expected.to contain_augeas('qemu-conf-limits').with({
@@ -160,6 +93,7 @@ describe 'nova::compute::libvirt::qemu' do
"set default_tls_x509_verify 1",
"set group openvswitch",
"set memory_backing_dir /tmp",
"set nbd_tls 0",
],
:tag => 'qemu-conf-augeas',
}).that_notifies('Service[libvirt]') }
@@ -169,8 +103,7 @@ describe 'nova::compute::libvirt::qemu' do
let :params do
{
:configure_qemu => true,
:vnc_tls => true,
:libvirt_version => '3.9',
:vnc_tls => true,
}
end
it { is_expected.to contain_augeas('qemu-conf-limits').with({
@@ -181,6 +114,7 @@ describe 'nova::compute::libvirt::qemu' do
"set vnc_tls 1",
"set vnc_tls_x509_verify 1",
"set default_tls_x509_verify 1",
"set nbd_tls 0",
],
:tag => 'qemu-conf-augeas',
}).that_notifies('Service[libvirt]') }
@@ -189,9 +123,8 @@ describe 'nova::compute::libvirt::qemu' do
context 'when configuring qemu with default_tls_verify enabled' do
let :params do
{
:configure_qemu => true,
:configure_qemu => true,
:default_tls_verify => true,
:libvirt_version => '3.9',
}
end
it { is_expected.to contain_augeas('qemu-conf-limits').with({
@@ -202,6 +135,7 @@ describe 'nova::compute::libvirt::qemu' do
"set vnc_tls 0",
"set vnc_tls_x509_verify 0",
"set default_tls_x509_verify 1",
"set nbd_tls 0",
],
:tag => 'qemu-conf-augeas',
}).that_notifies('Service[libvirt]') }
@@ -211,9 +145,8 @@ describe 'nova::compute::libvirt::qemu' do
let :params do
{
:configure_qemu => true,
:vnc_tls => true,
:vnc_tls => true,
:vnc_tls_verify => false,
:libvirt_version => '3.9',
}
end
it { is_expected.to contain_augeas('qemu-conf-limits').with({
@@ -224,6 +157,7 @@ describe 'nova::compute::libvirt::qemu' do
"set vnc_tls 1",
"set vnc_tls_x509_verify 0",
"set default_tls_x509_verify 1",
"set nbd_tls 0",
],
:tag => 'qemu-conf-augeas',
}).that_notifies('Service[libvirt]') }
@@ -232,9 +166,8 @@ describe 'nova::compute::libvirt::qemu' do
context 'when configuring qemu with default_tls_verify disabled' do
let :params do
{
:configure_qemu => true,
:configure_qemu => true,
:default_tls_verify => false,
:libvirt_version => '3.9',
}
end
it { is_expected.to contain_augeas('qemu-conf-limits').with({
@@ -245,27 +178,7 @@ describe 'nova::compute::libvirt::qemu' do
"set vnc_tls 0",
"set vnc_tls_x509_verify 0",
"set default_tls_x509_verify 0",
],
:tag => 'qemu-conf-augeas',
}).that_notifies('Service[libvirt]') }
end
context 'when configuring qemu with nbd_tls and libvirt < 4.5' do
let :params do
{
:configure_qemu => true,
:nbd_tls => true,
:libvirt_version => '3.9',
}
end
it { is_expected.to contain_augeas('qemu-conf-limits').with({
:context => '/files/etc/libvirt/qemu.conf',
:changes => [
"set max_files 1024",
"set max_processes 4096",
"set vnc_tls 0",
"set vnc_tls_x509_verify 0",
"set default_tls_x509_verify 1",
"set nbd_tls 0",
],
:tag => 'qemu-conf-augeas',
}).that_notifies('Service[libvirt]') }
@@ -275,8 +188,7 @@ describe 'nova::compute::libvirt::qemu' do
let :params do
{
:configure_qemu => true,
:nbd_tls => true,
:libvirt_version => '4.5',
:nbd_tls => true,
}
end
it { is_expected.to contain_augeas('qemu-conf-limits').with({

View File

@@ -418,68 +418,47 @@ describe 'nova::migration::libvirt' do
end
shared_examples_for 'nova migration with libvirt in Debian' do
context 'with libvirt < 5.6' do
context 'with tls transport' do
let :params do
{ :transport => 'tls',
:libvirt_version => '4.0' }
{ :transport => 'tls' }
end
it { is_expected.to contain_file_line('/etc/default/libvirtd libvirtd opts').with(
:path => '/etc/default/libvirtd',
:line => 'libvirtd_opts="-l"',
:line => 'libvirtd_opts=',
:match => 'libvirtd_opts=',
:tag => 'libvirt-file_line',
) }
it { is_expected.to_not contain_service('libvirtd-tls') }
it { is_expected.to_not contain_service('libvirtd-tcp') }
it { is_expected.to contain_service('libvirtd-tls').with(
:name => 'libvirtd-tls.socket',
:ensure => 'running',
:enable => true,
)}
end
context 'with libvirt >= 5.6' do
context 'with tls transport' do
let :params do
{ :transport => 'tls',
:libvirt_version => '6.0' }
end
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',
:enable => true,
)}
context 'with tcp transport' do
let :params do
{ :transport => 'tcp' }
end
context 'with tcp transport' do
let :params do
{ :transport => 'tcp',
:libvirt_version => '6.0' }
end
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',
:enable => true,
)}
end
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',
:enable => true,
)}
end
end
shared_examples_for 'nova migration with libvirt in RedHat' do
context 'with libvirt < 5.6' do
context 'with tls transport' do
let :params do
{ :transport => 'tls',
:libvirt_version => '4.5' }
{ :transport => 'tls' }
end
it { is_expected.to contain_file('/etc/sysconfig/libvirtd').with(
@@ -489,63 +468,38 @@ describe 'nova::migration::libvirt' do
)}
it { is_expected.to contain_file_line('/etc/sysconfig/libvirtd libvirtd args').with(
:path => '/etc/sysconfig/libvirtd',
:line => 'LIBVIRTD_ARGS="--listen"',
:line => 'LIBVIRTD_ARGS=',
:match => '^LIBVIRTD_ARGS=',
:tag => 'libvirt-file_line',
)}
it { is_expected.to_not contain_service('libvirtd-tls') }
it { is_expected.to_not contain_service('libvirtd-tcp') }
it { is_expected.to contain_service('libvirtd-tls').with(
:name => 'libvirtd-tls.socket',
:ensure => 'running',
:enable => true,
)}
end
context 'with libvirt >= 5.6' do
context 'with tls transport' do
let :params do
{ :transport => 'tls',
:libvirt_version => '5.6' }
end
it { is_expected.to contain_file('/etc/sysconfig/libvirtd').with(
:ensure => 'present',
:path => '/etc/sysconfig/libvirtd',
:tag => 'libvirt-file',
)}
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,
)}
context 'with tcp transport' do
let :params do
{ :transport => 'tcp' }
end
context 'with tcp transport' do
let :params do
{ :transport => 'tcp',
:libvirt_version => '5.6' }
end
it { is_expected.to contain_file('/etc/sysconfig/libvirtd').with(
:ensure => 'present',
:path => '/etc/sysconfig/libvirtd',
:tag => 'libvirt-file',
)}
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
it { is_expected.to contain_file('/etc/sysconfig/libvirtd').with(
:ensure => 'present',
:path => '/etc/sysconfig/libvirtd',
:tag => 'libvirt-file',
)}
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