Skip to content
Permalink
Browse files

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
  • Loading branch information...
smalleni authored and olliewalsh committed Jun 22, 2017
1 parent f716f0e commit c1a4ab211dd2322572349719379cd13c6f2abb9a
@@ -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
@@ -275,6 +268,14 @@
# (optional) Default pool for floating IPs
# 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,
@@ -292,7 +293,6 @@
$sync_db_api = true,
$db_online_data_migrations = false,
$neutron_metadata_proxy_shared_secret = undef,
$pci_alias = $::os_service_default,
$ratelimits = undef,
$ratelimits_factory =
'nova.api.openstack.compute.limits:RateLimitingMiddleware.factory',
@@ -334,6 +334,7 @@
$osapi_glance_link_prefix = undef,
$osapi_hide_server_address_states = undef,
$default_floating_pool = undef,
$pci_alias = undef,
) inherits nova::params {

include ::nova::deps
@@ -536,14 +537,10 @@
'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
@@ -149,6 +142,16 @@
# will disable itself.
# 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,
@@ -169,7 +172,6 @@
$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,
@@ -181,21 +183,21 @@
$barbican_api_version = $::os_service_default,
$max_concurrent_live_migrations = $::os_service_default,
$consecutive_build_service_disable_threshold = $::os_service_default,
# DEPRECATED PARAMETERS
$pci_passthrough = undef,
) {

include ::nova::deps
include ::nova::params

$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/ {
@@ -210,7 +212,6 @@
nova_config {
'DEFAULT/reserved_host_memory_mb': value => $reserved_host_memory;
'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;
@@ -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;
}
}
@@ -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
@@ -79,13 +79,17 @@ class { '::nova::keystone::authtoken':
is_expected.to contain_nova_config('vendordata_dynamic_auth/project_name').with('value' => '<SERVICE DEFAULT>')
is_expected.to contain_nova_config('vendordata_dynamic_auth/user_domain_name').with('value' => '<SERVICE DEFAULT>')
is_expected.to contain_nova_config('vendordata_dynamic_auth/username').with('value' => '<SERVICE DEFAULT>')
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
@@ -201,6 +205,7 @@ class { '::nova::keystone::authtoken':
})
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"}']
)
@@ -214,18 +219,22 @@ class { '::nova::keystone::authtoken':
})
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"}']
)
end
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
@@ -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
Oops, something went wrong.

0 comments on commit c1a4ab2

Please sign in to comment.
You can’t perform that action at this time.