Add option to bind libvirtd to a specific IP address

Change-Id: Icd0260cd3a5de130b81a9a7b3fe5b8395594541c
(cherry picked from commit 3b23eff10e)
This commit is contained in:
Oliver Walsh 2017-03-20 12:29:47 +00:00 committed by Alex Schultz
parent a6c45ec67e
commit eeee2eedac
3 changed files with 36 additions and 0 deletions

View File

@ -13,6 +13,10 @@
# Valid options are none and sasl.
# Defaults to 'none'
#
# [*listen_address*]
# (optional) Bind libvirtd tcp/tls socket to the given address.
# Defaults to undef (bind to all addresses)
#
# [*live_migration_tunnelled*]
# (optional) Whether to use tunnelled migration, where migration data is
# transported over the libvirtd connection.
@ -62,6 +66,7 @@
class nova::migration::libvirt(
$use_tls = false,
$auth = 'none',
$listen_address = undef,
$live_migration_tunnelled = $::os_service_default,
$live_migration_completion_timeout = $::os_service_default,
$live_migration_progress_timeout = $::os_service_default,
@ -168,6 +173,15 @@ class nova::migration::libvirt(
}
}
if $listen_address {
file_line { '/etc/libvirt/libvirtd.conf listen_address':
path => '/etc/libvirt/libvirtd.conf',
line => "listen_addr = \"${listen_address}\"",
match => 'listen_addr =',
tag => 'libvirt-file_line',
}
}
file_line { '/etc/sysconfig/libvirtd libvirtd args':
path => '/etc/sysconfig/libvirtd',
line => 'LIBVIRTD_ARGS="--listen"',
@ -207,6 +221,15 @@ class nova::migration::libvirt(
}
}
if $listen_address {
file_line { '/etc/libvirt/libvirtd.conf listen_address':
path => '/etc/libvirt/libvirtd.conf',
line => "listen_addr = \"${listen_address}\"",
match => 'listen_addr =',
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.

View File

@ -0,0 +1,4 @@
---
features:
- Add a new parameter, "nova::migration::libvirt::listen_address", to control
the address/interface that libvirtd binds to.

View File

@ -141,6 +141,15 @@ describe 'nova::migration::libvirt' do
end
it { is_expected.not_to contain_nova_config('libvirt/live_migration_uri').with_value('qemu+tls://%s/system') }
end
context 'with listen_address set' do
let :params do
{
:listen_address => "127.0.0.1"
}
end
it { is_expected.to contain_file_line('/etc/libvirt/libvirtd.conf listen_address').with(:line => "listen_addr = \"127.0.0.1\"") }
end
end
# TODO (degorenko): switch to on_supported_os function when we got Xenial