diff --git a/manifests/migration/libvirt.pp b/manifests/migration/libvirt.pp index fa19ad0db..8efe5718d 100644 --- a/manifests/migration/libvirt.pp +++ b/manifests/migration/libvirt.pp @@ -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'], diff --git a/releasenotes/notes/add-libvirtd-host_uuid-ff1ab95e4586d176.yaml b/releasenotes/notes/add-libvirtd-host_uuid-ff1ab95e4586d176.yaml new file mode 100644 index 000000000..a73cbaf68 --- /dev/null +++ b/releasenotes/notes/add-libvirtd-host_uuid-ff1ab95e4586d176.yaml @@ -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. diff --git a/spec/classes/nova_migration_libvirt_spec.rb b/spec/classes/nova_migration_libvirt_spec.rb index dde6ae151..930a970f4 100644 --- a/spec/classes/nova_migration_libvirt_spec.rb +++ b/spec/classes/nova_migration_libvirt_spec.rb @@ -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 {