migration: split libvirt & nova configs
When running micro-services on compute nodes, nova & libvirt are separated & isolated (ie: containers). nova::migration::libvirt used to configure both nova & libvirt to support migration. This patch makes possible to select what we want (libvirt, nova or both). It will configure all by default for backward compatibility. Depends-On: I33e565638f39ace819645215912303d6e431870c Change-Id: I1a1cb827512b12289558b296a7e64ce2dc71f00a
This commit is contained in:
parent
c32ef24094
commit
a7bdcd95c4
@ -166,8 +166,6 @@ class nova::compute::libvirt (
|
||||
if $vncserver_listen != '0.0.0.0' and $vncserver_listen != '::0' {
|
||||
fail('For migration support to work, you MUST set vncserver_listen to \'0.0.0.0\' or \'::0\'')
|
||||
} else {
|
||||
# TODO(emilien): explode ::nova::migration::libvirt to select what bits we want to configure
|
||||
# and allow micro services between libvirt & nova-compute.
|
||||
include ::nova::migration::libvirt
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,14 @@
|
||||
# (optional) Set uuid not equal to output from dmidecode (boolean)
|
||||
# Defaults to false
|
||||
#
|
||||
# [*configure_libvirt*]
|
||||
# (optional) Whether or not configure libvirt bits.
|
||||
# Defaults to true.
|
||||
#
|
||||
# [*configure_nova*]
|
||||
# (optional) Whether or not configure libvirt bits.
|
||||
# Defaults to true.
|
||||
#
|
||||
class nova::migration::libvirt(
|
||||
$use_tls = false,
|
||||
$auth = 'none',
|
||||
@ -43,156 +51,164 @@ class nova::migration::libvirt(
|
||||
$block_migration_flag = undef,
|
||||
$live_migration_tunnelled = $::os_service_default,
|
||||
$override_uuid = false,
|
||||
$configure_libvirt = true,
|
||||
$configure_nova = true,
|
||||
){
|
||||
|
||||
include ::nova::deps
|
||||
|
||||
validate_re($auth, [ '^sasl$', '^none$' ], 'Valid options for auth are none and sasl.')
|
||||
|
||||
if $use_tls {
|
||||
$listen_tls = '1'
|
||||
$listen_tcp = '0'
|
||||
nova_config {
|
||||
'libvirt/live_migration_uri': value => 'qemu+tls://%s/system';
|
||||
}
|
||||
} else {
|
||||
$listen_tls = '0'
|
||||
$listen_tcp = '1'
|
||||
}
|
||||
|
||||
if $live_migration_flag {
|
||||
if $configure_nova {
|
||||
if $use_tls {
|
||||
nova_config {
|
||||
'libvirt/live_migration_uri': value => 'qemu+tls://%s/system';
|
||||
}
|
||||
}
|
||||
if $live_migration_flag {
|
||||
nova_config {
|
||||
'libvirt/live_migration_flag': value => $live_migration_flag
|
||||
}
|
||||
}
|
||||
|
||||
if $block_migration_flag {
|
||||
nova_config {
|
||||
'libvirt/block_migration_flag': value => $block_migration_flag
|
||||
}
|
||||
}
|
||||
|
||||
nova_config {
|
||||
'libvirt/live_migration_flag': value => $live_migration_flag
|
||||
'libvirt/live_migration_tunnelled': value => $live_migration_tunnelled
|
||||
}
|
||||
}
|
||||
|
||||
if $block_migration_flag {
|
||||
nova_config {
|
||||
'libvirt/block_migration_flag': value => $block_migration_flag
|
||||
}
|
||||
}
|
||||
if $configure_libvirt {
|
||||
Anchor['nova::config::begin']
|
||||
-> File_line<| tag == 'libvirt-file_line'|>
|
||||
-> Anchor['nova::config::end']
|
||||
|
||||
nova_config {
|
||||
'libvirt/live_migration_tunnelled': value => $live_migration_tunnelled
|
||||
}
|
||||
File_line<| tag == 'libvirt-file_line' |>
|
||||
~> Service['libvirt']
|
||||
|
||||
validate_re($auth, [ '^sasl$', '^none$' ], 'Valid options for auth are none and sasl.')
|
||||
if $override_uuid {
|
||||
if ! $::libvirt_uuid {
|
||||
$host_uuid = generate('/bin/cat', '/proc/sys/kernel/random/uuid')
|
||||
file { '/etc/libvirt/libvirt_uuid':
|
||||
content => $host_uuid,
|
||||
require => Package['libvirt'],
|
||||
}
|
||||
} else {
|
||||
$host_uuid = $::libvirt_uuid
|
||||
}
|
||||
|
||||
Anchor['nova::config::begin']
|
||||
-> File_line<| tag == 'libvirt-file_line'|>
|
||||
-> Anchor['nova::config::end']
|
||||
|
||||
File_line<| tag == 'libvirt-file_line' |>
|
||||
~> Service['libvirt']
|
||||
|
||||
if $override_uuid {
|
||||
if ! $::libvirt_uuid {
|
||||
$host_uuid = generate('/bin/cat', '/proc/sys/kernel/random/uuid')
|
||||
file { '/etc/libvirt/libvirt_uuid':
|
||||
content => $host_uuid,
|
||||
augeas { 'libvirt-conf-uuid':
|
||||
context => '/files/etc/libvirt/libvirtd.conf',
|
||||
changes => [
|
||||
"set host_uuid ${host_uuid}",
|
||||
],
|
||||
notify => Service['libvirt'],
|
||||
require => Package['libvirt'],
|
||||
}
|
||||
} else {
|
||||
$host_uuid = $::libvirt_uuid
|
||||
}
|
||||
|
||||
augeas { 'libvirt-conf-uuid':
|
||||
context => '/files/etc/libvirt/libvirtd.conf',
|
||||
changes => [
|
||||
"set host_uuid ${host_uuid}",
|
||||
],
|
||||
notify => Service['libvirt'],
|
||||
require => Package['libvirt'],
|
||||
}
|
||||
}
|
||||
|
||||
case $::osfamily {
|
||||
'RedHat': {
|
||||
file_line { '/etc/libvirt/libvirtd.conf listen_tls':
|
||||
path => '/etc/libvirt/libvirtd.conf',
|
||||
line => "listen_tls = ${listen_tls}",
|
||||
match => 'listen_tls =',
|
||||
tag => 'libvirt-file_line',
|
||||
}
|
||||
|
||||
file_line { '/etc/libvirt/libvirtd.conf listen_tcp':
|
||||
path => '/etc/libvirt/libvirtd.conf',
|
||||
line => "listen_tcp = ${listen_tcp}",
|
||||
match => 'listen_tcp =',
|
||||
tag => 'libvirt-file_line',
|
||||
}
|
||||
|
||||
if $use_tls {
|
||||
file_line { '/etc/libvirt/libvirtd.conf auth_tls':
|
||||
case $::osfamily {
|
||||
'RedHat': {
|
||||
file_line { '/etc/libvirt/libvirtd.conf listen_tls':
|
||||
path => '/etc/libvirt/libvirtd.conf',
|
||||
line => "auth_tls = \"${auth}\"",
|
||||
match => 'auth_tls =',
|
||||
line => "listen_tls = ${listen_tls}",
|
||||
match => 'listen_tls =',
|
||||
tag => 'libvirt-file_line',
|
||||
}
|
||||
} else {
|
||||
file_line { '/etc/libvirt/libvirtd.conf auth_tcp':
|
||||
|
||||
file_line { '/etc/libvirt/libvirtd.conf listen_tcp':
|
||||
path => '/etc/libvirt/libvirtd.conf',
|
||||
line => "auth_tcp = \"${auth}\"",
|
||||
match => 'auth_tcp =',
|
||||
line => "listen_tcp = ${listen_tcp}",
|
||||
match => 'listen_tcp =',
|
||||
tag => 'libvirt-file_line',
|
||||
}
|
||||
|
||||
if $use_tls {
|
||||
file_line { '/etc/libvirt/libvirtd.conf auth_tls':
|
||||
path => '/etc/libvirt/libvirtd.conf',
|
||||
line => "auth_tls = \"${auth}\"",
|
||||
match => 'auth_tls =',
|
||||
tag => 'libvirt-file_line',
|
||||
}
|
||||
} else {
|
||||
file_line { '/etc/libvirt/libvirtd.conf auth_tcp':
|
||||
path => '/etc/libvirt/libvirtd.conf',
|
||||
line => "auth_tcp = \"${auth}\"",
|
||||
match => 'auth_tcp =',
|
||||
tag => 'libvirt-file_line',
|
||||
}
|
||||
}
|
||||
|
||||
file_line { '/etc/sysconfig/libvirtd libvirtd args':
|
||||
path => '/etc/sysconfig/libvirtd',
|
||||
line => 'LIBVIRTD_ARGS="--listen"',
|
||||
match => 'LIBVIRTD_ARGS=',
|
||||
tag => 'libvirt-file_line',
|
||||
}
|
||||
}
|
||||
|
||||
file_line { '/etc/sysconfig/libvirtd libvirtd args':
|
||||
path => '/etc/sysconfig/libvirtd',
|
||||
line => 'LIBVIRTD_ARGS="--listen"',
|
||||
match => 'LIBVIRTD_ARGS=',
|
||||
tag => 'libvirt-file_line',
|
||||
}
|
||||
}
|
||||
|
||||
'Debian': {
|
||||
file_line { '/etc/libvirt/libvirtd.conf listen_tls':
|
||||
path => '/etc/libvirt/libvirtd.conf',
|
||||
line => "listen_tls = ${listen_tls}",
|
||||
match => 'listen_tls =',
|
||||
tag => 'libvirt-file_line',
|
||||
}
|
||||
|
||||
file_line { '/etc/libvirt/libvirtd.conf listen_tcp':
|
||||
path => '/etc/libvirt/libvirtd.conf',
|
||||
line => "listen_tcp = ${listen_tcp}",
|
||||
match => 'listen_tcp =',
|
||||
tag => 'libvirt-file_line',
|
||||
}
|
||||
|
||||
if $use_tls {
|
||||
file_line { '/etc/libvirt/libvirtd.conf auth_tls':
|
||||
'Debian': {
|
||||
file_line { '/etc/libvirt/libvirtd.conf listen_tls':
|
||||
path => '/etc/libvirt/libvirtd.conf',
|
||||
line => "auth_tls = \"${auth}\"",
|
||||
match => 'auth_tls =',
|
||||
line => "listen_tls = ${listen_tls}",
|
||||
match => 'listen_tls =',
|
||||
tag => 'libvirt-file_line',
|
||||
}
|
||||
} else {
|
||||
file_line { '/etc/libvirt/libvirtd.conf auth_tcp':
|
||||
|
||||
file_line { '/etc/libvirt/libvirtd.conf listen_tcp':
|
||||
path => '/etc/libvirt/libvirtd.conf',
|
||||
line => "auth_tcp = \"${auth}\"",
|
||||
match => 'auth_tcp =',
|
||||
line => "listen_tcp = ${listen_tcp}",
|
||||
match => 'listen_tcp =',
|
||||
tag => 'libvirt-file_line',
|
||||
}
|
||||
|
||||
if $use_tls {
|
||||
file_line { '/etc/libvirt/libvirtd.conf auth_tls':
|
||||
path => '/etc/libvirt/libvirtd.conf',
|
||||
line => "auth_tls = \"${auth}\"",
|
||||
match => 'auth_tls =',
|
||||
tag => 'libvirt-file_line',
|
||||
}
|
||||
} else {
|
||||
file_line { '/etc/libvirt/libvirtd.conf auth_tcp':
|
||||
path => '/etc/libvirt/libvirtd.conf',
|
||||
line => "auth_tcp = \"${auth}\"",
|
||||
match => 'auth_tcp =',
|
||||
tag => 'libvirt-file_line',
|
||||
}
|
||||
}
|
||||
|
||||
if $::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemmajrelease, '16') >= 0 {
|
||||
# If systemd is being used then libvirtd is already being launched correctly and
|
||||
# adding -d causes a second consecutive start to fail which causes puppet to fail.
|
||||
$libvirtd_opts = 'libvirtd_opts="-l"'
|
||||
} else {
|
||||
$libvirtd_opts = 'libvirtd_opts="-d -l"'
|
||||
}
|
||||
|
||||
file_line { "/etc/default/${::nova::compute::libvirt::libvirt_service_name} libvirtd opts":
|
||||
path => "/etc/default/${::nova::compute::libvirt::libvirt_service_name}",
|
||||
line => $libvirtd_opts,
|
||||
match => 'libvirtd_opts=',
|
||||
tag => 'libvirt-file_line',
|
||||
}
|
||||
}
|
||||
|
||||
if $::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemmajrelease, '16') >= 0 {
|
||||
# If systemd is being used then libvirtd is already being launched correctly and
|
||||
# adding -d causes a second consecutive start to fail which causes puppet to fail.
|
||||
$libvirtd_opts = 'libvirtd_opts="-l"'
|
||||
} else {
|
||||
$libvirtd_opts = 'libvirtd_opts="-d -l"'
|
||||
default: {
|
||||
warning("Unsupported osfamily: ${::osfamily}, make sure you are configuring this yourself")
|
||||
}
|
||||
|
||||
file_line { "/etc/default/${::nova::compute::libvirt::libvirt_service_name} libvirtd opts":
|
||||
path => "/etc/default/${::nova::compute::libvirt::libvirt_service_name}",
|
||||
line => $libvirtd_opts,
|
||||
match => 'libvirtd_opts=',
|
||||
tag => 'libvirt-file_line',
|
||||
}
|
||||
}
|
||||
|
||||
default: {
|
||||
warning("Unsupported osfamily: ${::osfamily}, make sure you are configuring this yourself")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -120,6 +120,25 @@ describe 'nova::migration::libvirt' do
|
||||
it { expect { is_expected.to contain_class('nova::compute::libvirt') }.to \
|
||||
raise_error(Puppet::Error, /Valid options for auth are none and sasl./) }
|
||||
end
|
||||
|
||||
context 'when not configuring libvirt' do
|
||||
let :params do
|
||||
{
|
||||
:configure_libvirt => false
|
||||
}
|
||||
end
|
||||
it { is_expected.not_to contain_file_line('/etc/libvirt/libvirtd.conf listen_tls') }
|
||||
end
|
||||
|
||||
context 'when not configuring nova and tls enabled' do
|
||||
let :params do
|
||||
{
|
||||
:configure_nova => false,
|
||||
:use_tls => true,
|
||||
}
|
||||
end
|
||||
it { is_expected.not_to contain_nova_config('libvirt/live_migration_uri').with_value('qemu+tls://%s/system') }
|
||||
end
|
||||
end
|
||||
|
||||
# TODO (degorenko): switch to on_supported_os function when we got Xenial
|
||||
|
Loading…
Reference in New Issue
Block a user