Add parameter to specify host_uuid

Currently, the `override_uuid` parameter, if set, will generate a random
uuid to be set in libvirtd.conf. It might be desirable to set a specific
uuid instead of a random one, create a parameter to do so.

Change-Id: I981a80d9767b7eae0854a64df720c23f855ab1be
This commit is contained in:
Jake Yip 2020-11-11 16:52:51 +11:00 committed by Jake Yip
parent 71276558e7
commit 6f8369ccfa
3 changed files with 37 additions and 4 deletions

View File

@ -79,6 +79,11 @@
# (optional) Set uuid not equal to output from dmidecode (boolean)
# Defaults to false
#
# [*host_uuid*]
# (optional) Set host_uuid to this value, instead of generating a random
# uuid, if override_uuid is set to true.
# Defaults to undef
#
# [*configure_libvirt*]
# (optional) Whether or not configure libvirt bits.
# Defaults to true.
@ -130,6 +135,7 @@ class nova::migration::libvirt(
$live_migration_permit_post_copy = $::os_service_default,
$live_migration_permit_auto_converge = $::os_service_default,
$override_uuid = false,
$host_uuid = undef,
$configure_libvirt = true,
$configure_nova = true,
$client_user = undef,
@ -217,19 +223,21 @@ class nova::migration::libvirt(
if $override_uuid {
if ! $::libvirt_uuid {
$host_uuid = generate('/bin/cat', '/proc/sys/kernel/random/uuid')
$host_uuid_real = pick(
$host_uuid,
generate('/bin/cat', '/proc/sys/kernel/random/uuid'))
file { '/etc/libvirt/libvirt_uuid':
content => $host_uuid,
content => $host_uuid_real,
require => Package['libvirt'],
}
} else {
$host_uuid = $::libvirt_uuid
$host_uuid_real = $::libvirt_uuid
}
augeas { 'libvirt-conf-uuid':
context => '/files/etc/libvirt/libvirtd.conf',
changes => [
"set host_uuid ${host_uuid}",
"set host_uuid ${host_uuid_real}",
],
notify => Service['libvirt'],
require => Package['libvirt'],

View File

@ -0,0 +1,7 @@
---
features:
- |
Add a new paramter nova::migration::libvirt::host_uuid. Currently, the
host_uuid is autogenerated (if override_uuid = true). This means an
operator is unable to set a uuid if desired. Add a new parameter to specify
host_uuid.

View File

@ -64,6 +64,24 @@ describe 'nova::migration::libvirt' do
}).that_requires('Package[libvirt]').that_notifies('Service[libvirt]') }
end
context 'with override_uuid enabled and host_uuid set' do
let :params do
{
:override_uuid => true,
:host_uuid => 'a8debd9d-e359-4bb2-8c77-edee431f94f2',
}
end
it { is_expected.to contain_file('/etc/libvirt/libvirt_uuid').with({
:content => 'a8debd9d-e359-4bb2-8c77-edee431f94f2',
}).that_requires('Package[libvirt]') }
it { is_expected.to contain_augeas('libvirt-conf-uuid').with({
:context => '/files/etc/libvirt/libvirtd.conf',
:changes => [ "set host_uuid a8debd9d-e359-4bb2-8c77-edee431f94f2" ],
}).that_requires('Package[libvirt]').that_notifies('Service[libvirt]') }
end
context 'with tls enabled' do
let :params do
{