From 4f93e49cee4339df7e291792b999dcb4df320bff Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Fri, 26 Aug 2016 10:21:53 -0400 Subject: [PATCH] Allow to set pci_passthrough to an empty value If pci_passthrough is set to an empty value, puppet won't configure the parameter and use os_service_default, so the parameter won't be set. This patch is required because of the usage of a custom function to compute the final parameter. Change-Id: I5ed53cfffe80dbbbb9dcee7c2ea6037afbed2382 --- manifests/compute.pp | 33 ++++++++++++++++--------------- spec/classes/nova_compute_spec.rb | 8 ++++++-- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/manifests/compute.pp b/manifests/compute.pp index a07af49a5..24373092e 100644 --- a/manifests/compute.pp +++ b/manifests/compute.pp @@ -84,9 +84,9 @@ # Defaults to '512' # # [*pci_passthrough*] -# (optional) Pci passthrough hash in format of: -# Defaults to undef -# Example +# (optional) Pci passthrough list of hash. +# Defaults to $::os_service_default +# Example of format: # "[ { 'vendor_id':'1234','product_id':'5678' }, # { 'vendor_id':'4321','product_id':'8765','physical_network':'default' } ] " # @@ -165,7 +165,7 @@ class nova::compute ( $force_raw_images = true, $reserved_host_memory = '512', $heal_instance_info_cache_interval = '60', - $pci_passthrough = undef, + $pci_passthrough = $::os_service_default, $config_drive_format = $::os_service_default, $allow_resize_to_same_host = false, $vcpu_pin_set = $::os_service_default, @@ -204,6 +204,17 @@ class nova::compute ( warning('compute_manager is marked as deprecated in Nova but still needed when Ironic is used. It will be removed once Nova removes it.') } + $vcpu_pin_set_real = pick(join(any2array($vcpu_pin_set), ','), $::os_service_default) + + # in the case of pci_passthrough, we can't use the same mechanism as vcpu_pin_set because + # the value is computed in a function and it makes things more complex. Let's just check if + # a value is set or if it's empty. + if !is_service_default($pci_passthrough) and !empty($pci_passthrough) { + $pci_passthrough_real = check_array_of_hash($pci_passthrough) + } else { + $pci_passthrough_real = $::os_service_default + } + # cryptsetup is required when Barbican is encrypting volumes if $keymgr_api_class =~ /barbican/ { ensure_packages('cryptsetup', { @@ -219,18 +230,14 @@ class nova::compute ( 'DEFAULT/compute_manager': value => $compute_manager; 'DEFAULT/heal_instance_info_cache_interval': value => $heal_instance_info_cache_interval; 'DEFAULT/allow_resize_to_same_host': value => $allow_resize_to_same_host; + 'DEFAULT/pci_passthrough_whitelist': value => $pci_passthrough_real; + 'DEFAULT/vcpu_pin_set': value => $vcpu_pin_set_real; 'key_manager/api_class': value => $keymgr_api_class; 'barbican/auth_endpoint': value => $barbican_auth_endpoint; 'barbican/barbican_endpoint': value => $barbican_endpoint; 'barbican/barbican_api_version': value => $barbican_api_version; } - $vcpu_pin_set_real = pick(join(any2array($vcpu_pin_set), ','), $::os_service_default) - - nova_config { - 'DEFAULT/vcpu_pin_set': value => $vcpu_pin_set_real; - } - if ($vnc_enabled) { include ::nova::vncproxy::common @@ -293,12 +300,6 @@ class nova::compute ( 'DEFAULT/force_raw_images': value => $force_raw_images; } - if ($pci_passthrough) { - nova_config { - 'DEFAULT/pci_passthrough_whitelist': value => check_array_of_hash($pci_passthrough); - } - } - if is_service_default($config_drive_format) or $config_drive_format == 'iso9660' { ensure_packages($::nova::params::genisoimage_package_name, { tag => ['openstack', 'nova-support-package'], diff --git a/spec/classes/nova_compute_spec.rb b/spec/classes/nova_compute_spec.rb index d8010b562..e7300d715 100644 --- a/spec/classes/nova_compute_spec.rb +++ b/spec/classes/nova_compute_spec.rb @@ -143,14 +143,18 @@ describe 'nova::compute' do end - context 'when vcpu_pin_set is empty' do + context 'when vcpu_pin_set and pci_passthrough are empty' do let :params do - { :vcpu_pin_set => "" } + { :vcpu_pin_set => "", + :pci_passthrough => "" } end it 'clears vcpu_pin_set configuration' do is_expected.to contain_nova_config('DEFAULT/vcpu_pin_set').with(:value => '') end + it 'clears pci_passthrough configuration' do + is_expected.to contain_nova_config('DEFAULT/pci_passthrough_whitelist').with(:value => '') + end end context 'with neutron_enabled set to false' do