Rename vgpu options to mdev
... following the renaming in nova[1]. [1] ff4d0d002a35022df1cb71029ad82ad8f3b327df Change-Id: I166691118deaabc89d4bf351d2022ce7b72b26b0
This commit is contained in:
parent
d894523a63
commit
84a12d8b37
@ -378,6 +378,8 @@ class nova::compute (
|
||||
}
|
||||
include nova::compute::pci
|
||||
|
||||
# TODO(tkajinam): Replace this by nova::compute::mdev when we remove
|
||||
# nova::compute::vgpu
|
||||
include nova::compute::vgpu
|
||||
|
||||
if ($vnc_enabled and $spice_enabled) {
|
||||
|
55
manifests/compute/mdev.pp
Normal file
55
manifests/compute/mdev.pp
Normal file
@ -0,0 +1,55 @@
|
||||
# Class nova::compute::mdev
|
||||
#
|
||||
# Configures nova compute mdev options
|
||||
#
|
||||
# === Parameters:
|
||||
#
|
||||
# [*mdev_types_device_addresses_mapping*]
|
||||
# (optional) Map of mdev type(s) the instances can get as key and list of
|
||||
# corresponding device addresses as value.
|
||||
# Defaults to {}
|
||||
#
|
||||
class nova::compute::mdev(
|
||||
$mdev_types_device_addresses_mapping = {},
|
||||
) {
|
||||
include nova::deps
|
||||
|
||||
# TODO(tkajinam): Remove this when we remove nova::compute::vgpu
|
||||
$mdev_types_device_addresses_mapping_real = pick(
|
||||
$::nova::compute::vgpu::vgpu_types_device_addresses_mapping,
|
||||
$mdev_types_device_addresses_mapping)
|
||||
|
||||
if !empty($mdev_types_device_addresses_mapping_real) {
|
||||
validate_legacy(Hash, 'validate_hash', $mdev_types_device_addresses_mapping_real)
|
||||
$mdev_types_real = keys($mdev_types_device_addresses_mapping_real)
|
||||
nova_config {
|
||||
'devices/enabled_mdev_types': value => join(any2array($mdev_types_real), ',');
|
||||
}
|
||||
|
||||
# TODO(tkajinam): Remove this when we remove nova::compute::vgpu
|
||||
nova_config {
|
||||
'devices/enabled_vgpu_types': ensure => absent;
|
||||
}
|
||||
|
||||
$mdev_types_device_addresses_mapping_real.each |$mdev_type, $device_addresses| {
|
||||
if !empty($device_addresses) {
|
||||
nova_config {
|
||||
"mdev_${mdev_type}/device_addresses": value => join(any2array($device_addresses), ',');
|
||||
}
|
||||
|
||||
# TODO(tkajinam): Remove this when we remove nova::compute::vgpu
|
||||
nova_config {
|
||||
"vgpu_${mdev_type}/device_addresses": ensure => absent;
|
||||
}
|
||||
} else {
|
||||
nova_config {
|
||||
"mdev_${mdev_type}/device_addresses": ensure => absent;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
nova_config {
|
||||
'devices/enabled_mdev_types': ensure => absent;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
# Class nova::compute::vgpu
|
||||
#
|
||||
# DEPRECATED !!
|
||||
# Configures nova compute vgpu options
|
||||
#
|
||||
# === Parameters:
|
||||
@ -7,34 +8,17 @@
|
||||
# [*vgpu_types_device_addresses_mapping*]
|
||||
# (optional) Map of vgpu type(s) the instances can get as key and list of
|
||||
# corresponding device addresses as value.
|
||||
# Defaults to {}
|
||||
# Defaults to undef
|
||||
#
|
||||
class nova::compute::vgpu(
|
||||
$vgpu_types_device_addresses_mapping = {},
|
||||
$vgpu_types_device_addresses_mapping = undef,
|
||||
) {
|
||||
include nova::deps
|
||||
|
||||
if !empty($vgpu_types_device_addresses_mapping) {
|
||||
validate_legacy(Hash, 'validate_hash', $vgpu_types_device_addresses_mapping)
|
||||
$vgpu_types_real = keys($vgpu_types_device_addresses_mapping)
|
||||
nova_config {
|
||||
'devices/enabled_vgpu_types': value => join(any2array($vgpu_types_real), ',');
|
||||
}
|
||||
|
||||
$vgpu_types_device_addresses_mapping.each |$vgpu_type, $device_addresses| {
|
||||
if !empty($device_addresses) {
|
||||
nova_config {
|
||||
"vgpu_${vgpu_type}/device_addresses": value => join(any2array($device_addresses), ',');
|
||||
}
|
||||
} else {
|
||||
nova_config {
|
||||
"vgpu_${vgpu_type}/device_addresses": ensure => absent;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
nova_config {
|
||||
'devices/enabled_vgpu_types': ensure => absent;
|
||||
}
|
||||
if $vgpu_types_device_addresses_mapping != undef or ! defined(Class[nova::compute]) {
|
||||
# NOTE(tkajinam): If the nova::compute class is not yet included then it is
|
||||
# likely this class is included explicitly.
|
||||
warning('The nova::compute::vgpu class is deprecated. Use the nova::compute::mdev class instead')
|
||||
}
|
||||
include nova::compute::mdev
|
||||
}
|
||||
|
5
releasenotes/notes/generic-mdevs-627ccb29320cd442.yaml
Normal file
5
releasenotes/notes/generic-mdevs-627ccb29320cd442.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
deprecations:
|
||||
- |
|
||||
The ``nova::compute::vgpu`` class has been deprecated in favor of the new
|
||||
``nova::compute::mdev`` class.
|
47
spec/classes/nova_compute_mdev_spec.rb
Normal file
47
spec/classes/nova_compute_mdev_spec.rb
Normal file
@ -0,0 +1,47 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'nova::compute::mdev' do
|
||||
|
||||
shared_examples_for 'nova-compute-mdev' do
|
||||
context 'with default parameters' do
|
||||
it 'clears mdev devices' do
|
||||
is_expected.to contain_nova_config('devices/enabled_mdev_types').with_ensure('absent')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with mdev types and device addresses mapping' do
|
||||
let :params do
|
||||
{
|
||||
:mdev_types_device_addresses_mapping => { "nvidia-35" => [] },
|
||||
}
|
||||
end
|
||||
it { is_expected.to contain_nova_config('devices/enabled_mdev_types').with_value('nvidia-35') }
|
||||
it { is_expected.to contain_nova_config('mdev_nvidia-35/device_addresses').with_ensure('absent') }
|
||||
end
|
||||
|
||||
context 'with multiple mdev types and corresponding device addresses mapping' do
|
||||
let :params do
|
||||
{
|
||||
:mdev_types_device_addresses_mapping => { "nvidia-35" => ['0000:84:00.0', '0000:85:00.0'],
|
||||
"nvidia-36" => ['0000:86:00.0'] }
|
||||
}
|
||||
end
|
||||
|
||||
it { is_expected.to contain_nova_config('devices/enabled_mdev_types').with_value('nvidia-35,nvidia-36') }
|
||||
it { is_expected.to contain_nova_config('mdev_nvidia-35/device_addresses').with_value('0000:84:00.0,0000:85:00.0') }
|
||||
it { is_expected.to contain_nova_config('mdev_nvidia-36/device_addresses').with_value('0000:86:00.0') }
|
||||
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-mdev'
|
||||
end
|
||||
end
|
||||
end
|
@ -5,18 +5,18 @@ describe 'nova::compute::vgpu' do
|
||||
shared_examples_for 'nova-compute-vgpu' do
|
||||
context 'with default parameters' do
|
||||
it 'clears vgpu devices' do
|
||||
is_expected.to contain_nova_config('devices/enabled_vgpu_types').with_ensure('absent')
|
||||
is_expected.to contain_nova_config('devices/enabled_mdev_types').with_ensure('absent')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with vgpu types and device addresses mapping' do
|
||||
let :params do
|
||||
{
|
||||
:vgpu_types_device_addresses_mapping => { "nvidia-35" => [] },
|
||||
:vgpu_types_device_addresses_mapping => { "nvidia-35" => [] },
|
||||
}
|
||||
end
|
||||
it { is_expected.to contain_nova_config('devices/enabled_vgpu_types').with_value('nvidia-35') }
|
||||
it { is_expected.to contain_nova_config('vgpu_nvidia-35/device_addresses').with_ensure('absent') }
|
||||
it { is_expected.to contain_nova_config('devices/enabled_mdev_types').with_value('nvidia-35') }
|
||||
it { is_expected.to contain_nova_config('mdev_nvidia-35/device_addresses').with_ensure('absent') }
|
||||
end
|
||||
|
||||
context 'with multiple vgpu types and corresponding device addresses mapping' do
|
||||
@ -27,9 +27,9 @@ describe 'nova::compute::vgpu' do
|
||||
}
|
||||
end
|
||||
|
||||
it { is_expected.to contain_nova_config('devices/enabled_vgpu_types').with_value('nvidia-35,nvidia-36') }
|
||||
it { is_expected.to contain_nova_config('vgpu_nvidia-35/device_addresses').with_value('0000:84:00.0,0000:85:00.0') }
|
||||
it { is_expected.to contain_nova_config('vgpu_nvidia-36/device_addresses').with_value('0000:86:00.0') }
|
||||
it { is_expected.to contain_nova_config('devices/enabled_mdev_types').with_value('nvidia-35,nvidia-36') }
|
||||
it { is_expected.to contain_nova_config('mdev_nvidia-35/device_addresses').with_value('0000:84:00.0,0000:85:00.0') }
|
||||
it { is_expected.to contain_nova_config('mdev_nvidia-36/device_addresses').with_value('0000:86:00.0') }
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user