puppet-nova/manifests/compute/vgpu.pp
Takashi Kajinami 851dc512e1 Cleanup device addresses of vgpu type when empty
This change makes sure that device_addresses parameter is unset when
empty list of device addresses is associated with a vgpu type, so that
unmanaged parameter is not left.

Change-Id: Id6a354401b3233d3a17081d97a1a0e25f24d3219
2020-09-17 23:38:17 +09:00

58 lines
1.7 KiB
Puppet

# Class nova::compute::vgpu
#
# Configures nova compute vgpu options
#
# === Parameters:
#
# [*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 {}
#
# DEPRECATED PARAMETERS
#
# [*enabled_vgpu_types*]
# (optional) Specify which specific GPU type(s) the instances can get
# Defaults to undef
#
class nova::compute::vgpu(
$vgpu_types_device_addresses_mapping = {},
# DEPRECATED PARAMETERS
$enabled_vgpu_types = undef,
) {
include nova::deps
if $enabled_vgpu_types {
warning('enabled_vgpu_types is deprecated, instead use vgpu_types_device_addresses_mapping parameter.')
}
if $enabled_vgpu_types != undef and !empty($enabled_vgpu_types) {
nova_config {
'devices/enabled_vgpu_types': value => join(any2array($enabled_vgpu_types), ',');
}
} elsif !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;
}
}
}