Add pci/alias to compute manifest
Starting with Ocata pci_alias needs to be configured on compute nodes as
well.
This requires refactoring of the manifests as the parameter is common to
nova::compute and nova::api.
Common pci configuration is now done by the nova::pci class while compute
specific configuration is done now by the nova::compute::pci class.
Closes-Bug: #1702730
Change-Id: Iac4f22cbe043629ae9f0477ae62cf77ad0d761f8
(cherry picked from commit c1a4ab211d
)
This commit is contained in:
parent
005e5c8cc4
commit
82966150a1
@ -74,13 +74,6 @@
|
||||
# (optional) Shared secret to validate proxies Neutron metadata requests
|
||||
# Defaults to undef
|
||||
#
|
||||
# [*pci_alias*]
|
||||
# (optional) A list of pci alias hashes
|
||||
# Defaults to $::os_service_default
|
||||
# Example:
|
||||
# [{"vendor_id" => "1234", "product_id" => "5678", "name" => "default"},
|
||||
# {"vendor_id" => "1234", "product_id" => "6789", "name" => "other"}]
|
||||
#
|
||||
# [*ratelimits*]
|
||||
# (optional) A string that is a semicolon-separated list of 5-tuples.
|
||||
# See http://docs.openstack.org/trunk/config-reference/content/configuring-compute-API.html
|
||||
@ -237,6 +230,14 @@
|
||||
# information should not be returned from the API.
|
||||
# Defaults to undef
|
||||
#
|
||||
# [*pci_alias*]
|
||||
# DEPRECATED. Use nova::pci::aliases instead.
|
||||
# (optional) A list of pci alias hashes
|
||||
# Defaults to undef
|
||||
# Example:
|
||||
# [{"vendor_id" => "1234", "product_id" => "5678", "name" => "default"},
|
||||
# {"vendor_id" => "1234", "product_id" => "6789", "name" => "other"}]
|
||||
#
|
||||
class nova::api(
|
||||
$enabled = true,
|
||||
$manage_service = true,
|
||||
@ -255,7 +256,6 @@ class nova::api(
|
||||
$db_online_data_migrations = false,
|
||||
$neutron_metadata_proxy_shared_secret = undef,
|
||||
$default_floating_pool = 'nova',
|
||||
$pci_alias = $::os_service_default,
|
||||
$ratelimits = undef,
|
||||
$ratelimits_factory =
|
||||
'nova.api.openstack.compute.limits:RateLimitingMiddleware.factory',
|
||||
@ -287,6 +287,7 @@ class nova::api(
|
||||
$osapi_compute_link_prefix = undef,
|
||||
$osapi_glance_link_prefix = undef,
|
||||
$osapi_hide_server_address_states = undef,
|
||||
$pci_alias = undef,
|
||||
) inherits nova::params {
|
||||
|
||||
include ::nova::deps
|
||||
@ -477,14 +478,10 @@ as a standalone service, or httpd for being run by a httpd server")
|
||||
'filter:authtoken/auth_admin_prefix': ensure => absent;
|
||||
}
|
||||
|
||||
if !is_service_default($pci_alias) and !empty($pci_alias) {
|
||||
$pci_alias_real = to_array_of_json_strings($pci_alias)
|
||||
} else {
|
||||
$pci_alias_real = $::os_service_default
|
||||
}
|
||||
nova_config {
|
||||
'pci/alias': value => $pci_alias_real;
|
||||
if $pci_alias {
|
||||
warning('The pci_alias parameter is deprecated. Please use nova::pci::aliases instead.')
|
||||
}
|
||||
include ::nova::pci
|
||||
|
||||
if $validate {
|
||||
#Shrinking the variables names in favor of not
|
||||
|
@ -83,13 +83,6 @@
|
||||
# The amount of memory in MB reserved for the host.
|
||||
# Defaults to '512'
|
||||
#
|
||||
# [*pci_passthrough*]
|
||||
# (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" } ]
|
||||
#
|
||||
# [*config_drive_format*]
|
||||
# (optional) Config drive format. One of iso9660 (default) or vfat
|
||||
# Defaults to undef
|
||||
@ -163,6 +156,16 @@
|
||||
# The driver that will manage the running instances.
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# DEPRECATED
|
||||
#
|
||||
# [*pci_passthrough*]
|
||||
# DEPRECATED. Use nova::compute::pci::passthrough instead.
|
||||
# (optional) Pci passthrough list of hash.
|
||||
# Defaults to undef
|
||||
# Example of format:
|
||||
# [ { "vendor_id" => "1234","product_id" => "5678" },
|
||||
# { "vendor_id" => "4321","product_id" => "8765", "physical_network" => "default" } ]
|
||||
#
|
||||
class nova::compute (
|
||||
$enabled = true,
|
||||
$manage_service = true,
|
||||
@ -183,7 +186,6 @@ class nova::compute (
|
||||
$force_raw_images = true,
|
||||
$reserved_host_memory = '512',
|
||||
$heal_instance_info_cache_interval = '60',
|
||||
$pci_passthrough = $::os_service_default,
|
||||
$config_drive_format = $::os_service_default,
|
||||
$allow_resize_to_same_host = false,
|
||||
$resize_confirm_window = $::os_service_default,
|
||||
@ -199,6 +201,7 @@ class nova::compute (
|
||||
$default_schedule_zone = undef,
|
||||
$internal_service_availability_zone = undef,
|
||||
$compute_manager = $::os_service_default,
|
||||
$pci_passthrough = undef,
|
||||
) {
|
||||
|
||||
include ::nova::deps
|
||||
@ -226,14 +229,12 @@ 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 = to_array_of_json_strings($pci_passthrough)
|
||||
} else {
|
||||
$pci_passthrough_real = $::os_service_default
|
||||
include ::nova::pci
|
||||
|
||||
if $pci_passthrough {
|
||||
warning('The pci_passthrough parameter is deprecated. Please use nova::compute::pci::passthrough instead.')
|
||||
}
|
||||
include ::nova::compute::pci
|
||||
|
||||
# cryptsetup is required when Barbican is encrypting volumes
|
||||
if $keymgr_api_class =~ /barbican/ {
|
||||
@ -249,7 +250,6 @@ is used. It will be removed once Nova removes it.")
|
||||
'DEFAULT/reserved_host_memory_mb': value => $reserved_host_memory;
|
||||
'DEFAULT/compute_manager': value => $compute_manager;
|
||||
'DEFAULT/heal_instance_info_cache_interval': value => $heal_instance_info_cache_interval;
|
||||
'pci/passthrough_whitelist': value => $pci_passthrough_real;
|
||||
'DEFAULT/resize_confirm_window': value => $resize_confirm_window;
|
||||
'DEFAULT/vcpu_pin_set': value => $vcpu_pin_set_real;
|
||||
'DEFAULT/resume_guests_state_on_host_boot': value => $resume_guests_state_on_host_boot;
|
||||
|
31
manifests/compute/pci.pp
Normal file
31
manifests/compute/pci.pp
Normal file
@ -0,0 +1,31 @@
|
||||
# Class nova::compute::pci
|
||||
#
|
||||
# Configures nova compute pci options
|
||||
#
|
||||
# === Parameters:
|
||||
#
|
||||
# [*passthrough*]
|
||||
# (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" } ]
|
||||
|
||||
class nova::compute::pci(
|
||||
$passthrough = $::os_service_default
|
||||
) {
|
||||
include ::nova::deps
|
||||
|
||||
$picked_passthrough = pick_default($::nova::compute::pci_passthrough,$passthrough)
|
||||
|
||||
if $picked_passthrough and
|
||||
!is_service_default($picked_passthrough) and
|
||||
!empty($picked_passthrough) {
|
||||
$passthrough_real = to_array_of_json_strings($picked_passthrough)
|
||||
} else {
|
||||
$passthrough_real = $::os_service_default
|
||||
}
|
||||
nova_config {
|
||||
'pci/passthrough_whitelist': value => $passthrough_real;
|
||||
}
|
||||
}
|
31
manifests/pci.pp
Normal file
31
manifests/pci.pp
Normal file
@ -0,0 +1,31 @@
|
||||
# Class nova::pci
|
||||
#
|
||||
# Configures nova pci options
|
||||
#
|
||||
# === Parameters:
|
||||
#
|
||||
# [*aliases*]
|
||||
# (optional) A list of pci alias hashes
|
||||
# Defaults to $::os_service_default
|
||||
# Example:
|
||||
# [{"vendor_id" => "1234", "product_id" => "5678", "name" => "default"},
|
||||
# {"vendor_id" => "1234", "product_id" => "6789", "name" => "other"}]
|
||||
|
||||
class nova::pci(
|
||||
$aliases = $::os_service_default
|
||||
) {
|
||||
include ::nova::deps
|
||||
|
||||
$picked_aliases = pick_default($::nova::api::pci_alias, $aliases)
|
||||
|
||||
if $picked_aliases and
|
||||
!is_service_default($picked_aliases) and
|
||||
!empty($picked_aliases) {
|
||||
$aliases_real = to_array_of_json_strings($picked_aliases)
|
||||
} else {
|
||||
$aliases_real = $::os_service_default
|
||||
}
|
||||
nova_config {
|
||||
'pci/alias': value => $aliases_real;
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
[pci]/alias option is now required in the nova configuration file on compute nodes too.
|
||||
This requires refactoring of the manifests as the parameter is common to nova::compute
|
||||
and nova::api.
|
||||
Common pci configuration is now done by the nova::pci class while compute specific
|
||||
configuration is done now by the nova::compute::pci class.
|
||||
deprecations:
|
||||
- |
|
||||
nova::api::pci_alias is deprecated by nova::pci::aliases
|
||||
nova::compute::pci_passthrough is deprecated by nova::compute::pci::passthrough
|
||||
|
@ -71,13 +71,17 @@ describe 'nova::api' do
|
||||
is_expected.to contain_nova_config('api/enable_instance_password').with('value' => '<SERVICE DEFAULT>')
|
||||
is_expected.to contain_nova_config('DEFAULT/password_length').with('value' => '<SERVICE DEFAULT>')
|
||||
is_expected.to contain_nova_config('DEFAULT/allow_resize_to_same_host').with('value' => false)
|
||||
is_expected.to contain_nova_config('pci/alias').with(:value => '<SERVICE DEFAULT>')
|
||||
end
|
||||
|
||||
it 'unconfigures neutron_metadata proxy' do
|
||||
is_expected.to contain_nova_config('neutron/service_metadata_proxy').with(:value => false)
|
||||
is_expected.to contain_nova_config('neutron/metadata_proxy_shared_secret').with(:ensure => 'absent')
|
||||
end
|
||||
|
||||
it 'includes nova::pci' do
|
||||
is_expected.to contain_class('nova::pci')
|
||||
is_expected.to contain_nova_config('pci/alias').with(:value => '<SERVICE DEFAULT>')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with overridden parameters' do
|
||||
@ -177,6 +181,7 @@ describe 'nova::api' do
|
||||
})
|
||||
end
|
||||
it 'configures nova pci_alias entries' do
|
||||
is_expected.to contain_class('nova::pci')
|
||||
is_expected.to contain_nova_config('pci/alias').with(
|
||||
'value' => ['{"vendor_id":"8086","product_id":"0126","name":"graphic_card"}','{"vendor_id":"9096","product_id":"1520","name":"network_card"}']
|
||||
)
|
||||
@ -190,6 +195,7 @@ describe 'nova::api' do
|
||||
})
|
||||
end
|
||||
it 'configures nova pci_alias entries' do
|
||||
is_expected.to contain_class('nova::pci')
|
||||
is_expected.to contain_nova_config('pci/alias').with(
|
||||
'value' => ['{"vendor_id":"8086","product_id":"0126","name":"graphic_card"}','{"vendor_id":"9096","product_id":"1520","name":"network_card"}']
|
||||
)
|
||||
@ -197,11 +203,14 @@ describe 'nova::api' do
|
||||
end
|
||||
|
||||
context 'when pci_alias is empty' do
|
||||
let :params do
|
||||
{ :pci_alias => "" }
|
||||
before do
|
||||
params.merge!({
|
||||
:pci_alias => ""
|
||||
})
|
||||
end
|
||||
|
||||
it 'clears pci_alias configuration' do
|
||||
is_expected.to contain_class('nova::pci')
|
||||
is_expected.to contain_nova_config('pci/alias').with(:value => '<SERVICE DEFAULT>')
|
||||
end
|
||||
end
|
||||
|
85
spec/classes/nova_compute_pci_spec.rb
Normal file
85
spec/classes/nova_compute_pci_spec.rb
Normal file
@ -0,0 +1,85 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'nova::compute::pci' do
|
||||
|
||||
shared_examples_for 'nova-compute-pci' do
|
||||
context 'with default parameters' do
|
||||
it 'clears pci_passthrough_whitelist configuration' do
|
||||
is_expected.to contain_nova_config('pci/passthrough_whitelist').with(:value => '<SERVICE DEFAULT>')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with passthrough array' do
|
||||
let :params do
|
||||
{
|
||||
:passthrough => [
|
||||
{
|
||||
"vendor_id" => "8086",
|
||||
"product_id" => "0126"
|
||||
},
|
||||
{
|
||||
"vendor_id" => "9096",
|
||||
"product_id" => "1520",
|
||||
"physical_network" => "physnet1"
|
||||
}
|
||||
],
|
||||
}
|
||||
end
|
||||
it 'configures nova pci_passthrough_whitelist entries' do
|
||||
is_expected.to contain_nova_config('pci/passthrough_whitelist').with(
|
||||
'value' => ['{"vendor_id":"8086","product_id":"0126"}','{"vendor_id":"9096","product_id":"1520","physical_network":"physnet1"}']
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with passthrough JSON encoded string (deprecated)' do
|
||||
let :params do
|
||||
{
|
||||
:passthrough => "[{\"vendor_id\":\"8086\",\"product_id\":\"0126\"},{\"vendor_id\":\"9096\",\"product_id\":\"1520\",\"physical_network\":\"physnet1\"}]",
|
||||
}
|
||||
end
|
||||
|
||||
it 'configures nova pci_passthrough_whitelist entries' do
|
||||
is_expected.to contain_nova_config('pci/passthrough_whitelist').with(
|
||||
'value' => ['{"vendor_id":"8086","product_id":"0126"}','{"vendor_id":"9096","product_id":"1520","physical_network":"physnet1"}']
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when passthrough is empty' do
|
||||
let :params do
|
||||
{
|
||||
:passthrough => []
|
||||
}
|
||||
end
|
||||
|
||||
it 'clears pci_passthrough_whitelist configuration' do
|
||||
is_expected.to contain_nova_config('pci/passthrough_whitelist').with(:value => '<SERVICE DEFAULT>')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when passthrough is empty string' do
|
||||
let :params do
|
||||
{
|
||||
:passthrough => ""
|
||||
}
|
||||
end
|
||||
|
||||
it 'clears pci_passthrough_whitelist configuration' do
|
||||
is_expected.to contain_nova_config('pci/passthrough_whitelist').with(:value => '<SERVICE DEFAULT>')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
on_supported_os({
|
||||
:supported_os => OSDefaults.get_supported_os
|
||||
}).each do |os,facts|
|
||||
context "on #{os}" do
|
||||
let (:facts) do
|
||||
facts.merge!(OSDefaults.get_facts())
|
||||
end
|
||||
|
||||
it_configures 'nova-compute-pci'
|
||||
end
|
||||
end
|
||||
end
|
@ -34,7 +34,6 @@ describe 'nova::compute' do
|
||||
it { is_expected.to contain_nova_config('barbican/barbican_api_version').with_value('<SERVICE DEFAULT>') }
|
||||
it { is_expected.to contain_nova_config('barbican/auth_endpoint').with_value('<SERVICE DEFAULT>') }
|
||||
it { is_expected.to contain_nova_config('DEFAULT/max_concurrent_live_migrations').with_value('<SERVICE DEFAULT>') }
|
||||
it { is_expected.to contain_nova_config('pci/passthrough_whitelist').with(:value => '<SERVICE DEFAULT>') }
|
||||
|
||||
it { is_expected.to_not contain_package('cryptsetup').with( :ensure => 'present' )}
|
||||
|
||||
@ -60,6 +59,11 @@ describe 'nova::compute' do
|
||||
is_expected.to contain_package('genisoimage').that_requires('Anchor[nova::install::begin]')
|
||||
is_expected.to contain_package('genisoimage').that_comes_before('Anchor[nova::install::end]')
|
||||
end
|
||||
|
||||
it 'configures nova pci_passthrough_whitelist' do
|
||||
is_expected.to contain_class('nova::compute::pci')
|
||||
is_expected.to contain_nova_config('pci/passthrough_whitelist').with(:value => '<SERVICE DEFAULT>')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with overridden parameters' do
|
||||
@ -149,7 +153,7 @@ describe 'nova::compute' do
|
||||
end
|
||||
end
|
||||
|
||||
context 'with pci_passthrough array' do
|
||||
context 'with pci params array' do
|
||||
let :params do
|
||||
{
|
||||
:pci_passthrough => [
|
||||
@ -162,41 +166,44 @@ describe 'nova::compute' do
|
||||
"product_id" => "1520",
|
||||
"physical_network" => "physnet1"
|
||||
}
|
||||
]
|
||||
],
|
||||
}
|
||||
end
|
||||
|
||||
it 'configures nova pci_passthrough_whitelist entries' do
|
||||
is_expected.to contain_class('nova::compute::pci')
|
||||
is_expected.to contain_nova_config('pci/passthrough_whitelist').with(
|
||||
'value' => ['{"vendor_id":"8086","product_id":"0126"}','{"vendor_id":"9096","product_id":"1520","physical_network":"physnet1"}']
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with pci_passthrough JSON encoded string (deprecated)' do
|
||||
context 'with pci params JSON encoded string (deprecated)' do
|
||||
let :params do
|
||||
{
|
||||
:pci_passthrough => "[{\"vendor_id\":\"8086\",\"product_id\":\"0126\"},{\"vendor_id\":\"9096\",\"product_id\":\"1520\",\"physical_network\":\"physnet1\"}]"
|
||||
:pci_passthrough => "[{\"vendor_id\":\"8086\",\"product_id\":\"0126\"},{\"vendor_id\":\"9096\",\"product_id\":\"1520\",\"physical_network\":\"physnet1\"}]",
|
||||
}
|
||||
end
|
||||
|
||||
it 'configures nova pci_passthrough_whitelist entries' do
|
||||
is_expected.to contain_class('nova::compute::pci')
|
||||
is_expected.to contain_nova_config('pci/passthrough_whitelist').with(
|
||||
'value' => ['{"vendor_id":"8086","product_id":"0126"}','{"vendor_id":"9096","product_id":"1520","physical_network":"physnet1"}']
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when vcpu_pin_set and pci_passthrough are empty' do
|
||||
context 'when vcpu_pin_set and pci params are empty' do
|
||||
let :params do
|
||||
{ :vcpu_pin_set => "",
|
||||
:pci_passthrough => "" }
|
||||
:pci_passthrough => ""}
|
||||
end
|
||||
|
||||
it 'clears vcpu_pin_set configuration' do
|
||||
is_expected.to contain_nova_config('DEFAULT/vcpu_pin_set').with(:value => '<SERVICE DEFAULT>')
|
||||
end
|
||||
it 'clears pci_passthrough configuration' do
|
||||
is_expected.to contain_class('nova::compute::pci')
|
||||
is_expected.to contain_nova_config('pci/passthrough_whitelist').with(:value => '<SERVICE DEFAULT>')
|
||||
end
|
||||
end
|
||||
|
84
spec/classes/nova_pci_spec.rb
Normal file
84
spec/classes/nova_pci_spec.rb
Normal file
@ -0,0 +1,84 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'nova::pci' do
|
||||
|
||||
shared_examples_for 'nova-pci' do
|
||||
context 'with default parameters' do
|
||||
it 'clears pci_alias configuration' do
|
||||
is_expected.to contain_nova_config('pci/alias').with(:value => '<SERVICE DEFAULT>')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with aliases array' do
|
||||
let :params do
|
||||
{
|
||||
:aliases => [{
|
||||
"vendor_id" => "8086",
|
||||
"product_id" => "0126",
|
||||
"name" => "graphic_card"
|
||||
},
|
||||
{
|
||||
"vendor_id" => "9096",
|
||||
"product_id" => "1520",
|
||||
"name" => "network_card"
|
||||
}
|
||||
]
|
||||
}
|
||||
end
|
||||
it 'configures nova pci_alias entries' do
|
||||
is_expected.to contain_nova_config('pci/alias').with(
|
||||
'value' => ['{"vendor_id":"8086","product_id":"0126","name":"graphic_card"}','{"vendor_id":"9096","product_id":"1520","name":"network_card"}']
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with aliases JSON encoded string (deprecated)' do
|
||||
let :params do
|
||||
{
|
||||
:aliases => "[{\"vendor_id\":\"8086\",\"product_id\":\"0126\",\"name\":\"graphic_card\"},{\"vendor_id\":\"9096\",\"product_id\":\"1520\",\"name\":\"network_card\"}]",
|
||||
}
|
||||
end
|
||||
it 'configures nova pci_alias entries' do
|
||||
is_expected.to contain_nova_config('pci/alias').with(
|
||||
'value' => ['{"vendor_id":"8086","product_id":"0126","name":"graphic_card"}','{"vendor_id":"9096","product_id":"1520","name":"network_card"}']
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when aliases is empty' do
|
||||
let :params do
|
||||
{
|
||||
:aliases => []
|
||||
}
|
||||
end
|
||||
|
||||
it 'clears pci_alias configuration' do
|
||||
is_expected.to contain_nova_config('pci/alias').with(:value => '<SERVICE DEFAULT>')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when aliases is empty string' do
|
||||
let :params do
|
||||
{
|
||||
:aliases => ""
|
||||
}
|
||||
end
|
||||
|
||||
it 'clears pci_alias configuration' do
|
||||
is_expected.to contain_nova_config('pci/alias').with(:value => '<SERVICE DEFAULT>')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
on_supported_os({
|
||||
:supported_os => OSDefaults.get_supported_os
|
||||
}).each do |os,facts|
|
||||
context "on #{os}" do
|
||||
let (:facts) do
|
||||
facts.merge!(OSDefaults.get_facts())
|
||||
end
|
||||
|
||||
it_configures 'nova-pci'
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user