Merge "Support libvirt/cpu_models instead of libvirt/cpu_model"

This commit is contained in:
Zuul 2020-09-24 04:21:30 +00:00 committed by Gerrit Code Review
commit 3ff3316fdc
4 changed files with 50 additions and 25 deletions

View File

@ -27,11 +27,11 @@
# Defaults to 'host-model' if virt_type is set to kvm,
# otherwise defaults to 'none'.
#
# [*cpu_model*]
# (optional) The named libvirt CPU model (see names listed in
# [*cpu_models*]
# (optional) The named libvirt CPU models (see names listed in
# /usr/share/libvirt/cpu_map.xml). Only has effect if
# cpu_mode="custom" and virt_type="kvm|qemu".
# Defaults to undef
# Defaults to []
#
# [*cpu_model_extra_flags*]
# (optional) This allows specifying granular CPU feature flags when
@ -270,7 +270,7 @@ class nova::compute::libvirt (
$vncserver_listen = '127.0.0.1',
$migration_support = false,
$cpu_mode = false,
$cpu_model = undef,
$cpu_models = [],
$cpu_model_extra_flags = undef,
$snapshot_image_format = $::os_service_default,
$disk_cachemodes = [],
@ -334,14 +334,6 @@ in a future release. Use the cpu_mode parameter instead')
$cpu_mode_real = $cpu_mode
}
if $libvirt_cpu_model != undef {
warning('The libvirt_cpu_model parameter was deprecated and will be removed \
in a future release. Use the cpu_model parameter instead')
$cpu_model_real = $libvirt_cpu_model
} else {
$cpu_model_real = $cpu_model
}
if $libvirt_cpu_model_extra_flags != undef {
warning('The libvirt_cpu_model_extra_flags parameter was deprecated and will be removed \
in a future release. Use the cpu_model_extra_flags parameter instead')
@ -522,20 +514,33 @@ in a future release. Use the enabled_perf_events parameter instead')
'libvirt/pmem_namespaces': value => $pmem_namespaces;
}
if $libvirt_cpu_model != undef {
warning('The libvirt_cpu_model parameter was deprecated an will be removed \
in a future release. Use the cpu_models parameter instead')
validate_legacy(String, 'validate_string', $libvirt_cpu_model)
$cpu_models_real = [$libvirt_cpu_model]
} else {
validate_legacy(Array, 'validate_array', $cpu_models)
$cpu_models_real = $cpu_models
}
# cpu_model param is only valid if cpu_mode=custom
# otherwise it should be commented out
if $cpu_mode_default == 'custom' {
validate_legacy(String, 'validate_string', $cpu_model_real)
nova_config {
'libvirt/cpu_model': value => $cpu_model_real;
if empty($cpu_models_real){
$cpu_models_value = $::os_service_default
} else {
$cpu_models_value = join($cpu_models_real, ',')
}
} else {
nova_config {
'libvirt/cpu_model': ensure => absent;
}
if $cpu_model_real {
warning('$cpu_model requires that $cpu_mode => "custom" and will be ignored')
if !empty($cpu_models_real) {
warning('$cpu_models requires that $cpu_mode => "custom" and will be ignored')
}
$cpu_models_value = $::os_service_default
}
nova_config {
'libvirt/cpu_model' : ensure => absent;
'libvirt/cpu_models': value => $cpu_models_value;
}
if $cpu_mode_default != 'none' and $cpu_model_extra_flags_real {

View File

@ -0,0 +1,6 @@
---
deprecations:
- |
The ``nova::compute::libvirt::libvirt_cpu_model`` parameter has been
deprecated and will be removed in a future release. Use the ``cpu_models``
parameter instead.

View File

@ -7,7 +7,6 @@ deprecations:
- ``libvirt_virt_type``
- ``libvirt_cpu_mode``
- ``libvirt_cpu_model``
- ``libvirt_cpu_model_extra_flags``
- ``libvirt_snapshot_image_format``
- ``libvirt_disk_cachemodes``

View File

@ -49,6 +49,7 @@ describe 'nova::compute::libvirt' do
it { is_expected.to contain_nova_config('DEFAULT/preallocate_images').with_value('<SERVICE DEFAULT>')}
it { is_expected.to contain_nova_config('libvirt/virt_type').with_value('kvm')}
it { is_expected.to contain_nova_config('libvirt/cpu_mode').with_value('host-model')}
it { is_expected.to contain_nova_config('libvirt/cpu_models').with_value('<SERVICE DEFAULT>')}
it { is_expected.to contain_nova_config('libvirt/cpu_model').with_ensure('absent')}
it { is_expected.to contain_nova_config('libvirt/cpu_model_extra_flags').with_ensure('absent')}
it { is_expected.to contain_nova_config('libvirt/snapshot_image_format').with_value('<SERVICE DEFAULT>')}
@ -78,7 +79,7 @@ describe 'nova::compute::libvirt' do
:virt_type => 'qemu',
:vncserver_listen => '0.0.0.0',
:cpu_mode => 'host-passthrough',
:cpu_model => 'kvm64',
:cpu_models => ['kvm64', 'qemu64'],
:cpu_model_extra_flags => 'pcid',
:snapshot_image_format => 'raw',
:disk_cachemodes => ['file=directsync','block=none'],
@ -114,6 +115,7 @@ describe 'nova::compute::libvirt' do
it { is_expected.to contain_nova_config('DEFAULT/preallocate_images').with_value('space')}
it { is_expected.to contain_nova_config('libvirt/virt_type').with_value('qemu')}
it { is_expected.to contain_nova_config('libvirt/cpu_mode').with_value('host-passthrough')}
it { is_expected.to contain_nova_config('libvirt/cpu_models').with_value('<SERVICE DEFAULT>')}
it { is_expected.to contain_nova_config('libvirt/cpu_model').with_ensure('absent')}
it { is_expected.to contain_nova_config('libvirt/cpu_model_extra_flags').with_value('pcid')}
it { is_expected.to contain_nova_config('libvirt/snapshot_image_format').with_value('raw')}
@ -159,12 +161,26 @@ describe 'nova::compute::libvirt' do
describe 'with custom cpu_mode' do
let :params do
{ :cpu_mode => 'custom',
:cpu_model => 'kvm64',
:cpu_models => ['kvm64', 'qemu64'],
:cpu_model_extra_flags => 'pcid' }
end
it { is_expected.to contain_nova_config('libvirt/cpu_mode').with_value('custom')}
it { is_expected.to contain_nova_config('libvirt/cpu_model').with_value('kvm64')}
it { is_expected.to contain_nova_config('libvirt/cpu_models').with_value('kvm64,qemu64')}
it { is_expected.to contain_nova_config('libvirt/cpu_model').with_ensure('absent')}
it { is_expected.to contain_nova_config('libvirt/cpu_model_extra_flags').with_value('pcid')}
end
describe 'with custom cpu_mode with deprecated libvirt_cpu_model' do
let :params do
{ :cpu_mode => 'custom',
:libvirt_cpu_model => 'kvm64',
:cpu_model_extra_flags => 'pcid' }
end
it { is_expected.to contain_nova_config('libvirt/cpu_mode').with_value('custom')}
it { is_expected.to contain_nova_config('libvirt/cpu_models').with_value('kvm64')}
it { is_expected.to contain_nova_config('libvirt/cpu_model').with_ensure('absent')}
it { is_expected.to contain_nova_config('libvirt/cpu_model_extra_flags').with_value('pcid')}
end
@ -414,5 +430,4 @@ describe 'nova::compute::libvirt' do
end
end
end
end