diff --git a/manifests/compute/libvirt.pp b/manifests/compute/libvirt.pp index f2bc9771f..c9b31d879 100644 --- a/manifests/compute/libvirt.pp +++ b/manifests/compute/libvirt.pp @@ -345,6 +345,11 @@ class nova::compute::libvirt ( } } + $hw_machine_type_real = $hw_machine_type ? { + Hash => join(join_keys_to_values($hw_machine_type, '='), ','), + default => join(any2array($hw_machine_type), ','), + } + nova_config { 'DEFAULT/compute_driver': value => $compute_driver; 'DEFAULT/preallocate_images': value => $preallocate_images; @@ -361,7 +366,7 @@ class nova::compute::libvirt ( 'libvirt/inject_key': value => $inject_key; 'libvirt/inject_partition': value => $inject_partition; 'libvirt/hw_disk_discard': value => $hw_disk_discard; - 'libvirt/hw_machine_type': value => $hw_machine_type; + 'libvirt/hw_machine_type': value => $hw_machine_type_real; 'libvirt/sysinfo_serial': value => $sysinfo_serial; 'libvirt/enabled_perf_events': value => join(any2array($enabled_perf_events), ','); 'libvirt/device_detach_attempts': value => $device_detach_attempts; diff --git a/spec/classes/nova_compute_libvirt_spec.rb b/spec/classes/nova_compute_libvirt_spec.rb index 59acff028..b23246c60 100644 --- a/spec/classes/nova_compute_libvirt_spec.rb +++ b/spec/classes/nova_compute_libvirt_spec.rb @@ -219,6 +219,23 @@ describe 'nova::compute::libvirt' do it { is_expected.to contain_nova_config('libvirt/cpu_mode').with_value('none')} end + describe 'with hw_machine_type set by array' do + let :params do + { :hw_machine_type => ['x86_64=machinetype1', 'armv7l=machinetype2'] } + end + it { is_expected.to contain_nova_config('libvirt/hw_machine_type').with_value('x86_64=machinetype1,armv7l=machinetype2')} + end + + describe 'with hw_machine_type set by hash' do + let :params do + { :hw_machine_type => { + 'x86_64' => 'machinetype1', + 'armv7l' => 'machinetype2' + } } + end + it { is_expected.to contain_nova_config('libvirt/hw_machine_type').with_value('x86_64=machinetype1,armv7l=machinetype2')} + end + describe 'with migration_support enabled' do context 'with vncserver_listen set to 0.0.0.0' do