Consolidate boolean config opts in nova::compute
Make them more consistent by reducing the logic and grouping them together. Change-Id: I7c1dc27edaedb1d8835434f93ea5f6a2bf1b45eb
This commit is contained in:
parent
fb73d45b03
commit
cc00e708de
@ -52,11 +52,11 @@
|
||||
#
|
||||
# [*force_config_drive*]
|
||||
# (optional) Whether to force the config drive to be attached to all VMs
|
||||
# Defaults to false
|
||||
# Defaults to $facts['os_service_default']
|
||||
#
|
||||
# [*instance_usage_audit*]
|
||||
# (optional) Generate periodic compute.instance.exists notifications.
|
||||
# Defaults to false
|
||||
# Defaults to $facts['os_service_default']
|
||||
#
|
||||
# [*instance_usage_audit_period*]
|
||||
# (optional) Time period to generate instance usages for.
|
||||
@ -273,8 +273,8 @@ class nova::compute (
|
||||
$vncproxy_protocol = 'http',
|
||||
$vncproxy_port = '6080',
|
||||
$vncproxy_path = '/vnc_auto.html',
|
||||
Boolean $force_config_drive = false,
|
||||
Boolean $instance_usage_audit = false,
|
||||
$force_config_drive = $facts['os_service_default'],
|
||||
$instance_usage_audit = $facts['os_service_default'],
|
||||
$instance_usage_audit_period = $facts['os_service_default'],
|
||||
$flat_injected = $facts['os_service_default'],
|
||||
$mkisofs_cmd = $facts['os_service_default'],
|
||||
@ -439,28 +439,11 @@ class nova::compute (
|
||||
ensure_package => $ensure_package,
|
||||
}
|
||||
|
||||
if $force_config_drive {
|
||||
nova_config { 'DEFAULT/force_config_drive': value => true }
|
||||
} else {
|
||||
nova_config { 'DEFAULT/force_config_drive': ensure => absent }
|
||||
}
|
||||
|
||||
if $instance_usage_audit {
|
||||
nova_config {
|
||||
'DEFAULT/instance_usage_audit': value => $instance_usage_audit;
|
||||
'DEFAULT/instance_usage_audit_period': value => $instance_usage_audit_period;
|
||||
}
|
||||
} else {
|
||||
nova_config {
|
||||
'DEFAULT/instance_usage_audit': ensure => absent;
|
||||
'DEFAULT/instance_usage_audit_period': ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
nova_config { 'DEFAULT/flat_injected': value => $flat_injected }
|
||||
|
||||
nova_config {
|
||||
'DEFAULT/config_drive_format': value => pick($config_drive_format, $facts['os_service_default']);
|
||||
'DEFAULT/force_config_drive': value => $force_config_drive;
|
||||
'DEFAULT/instance_usage_audit': value => $instance_usage_audit;
|
||||
'DEFAULT/instance_usage_audit_period': value => $instance_usage_audit_period;
|
||||
'DEFAULT/flat_injected': value => $flat_injected;
|
||||
'DEFAULT/config_drive_format': value => pick($config_drive_format, $facts['os_service_default']);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -66,6 +66,8 @@ describe 'nova::compute' do
|
||||
it { is_expected.to contain_nova_config('compute/image_type_exclude_list').with_value('<SERVICE DEFAULT>') }
|
||||
it { is_expected.to contain_nova_config('DEFAULT/block_device_allocate_retries').with_value('<SERVICE DEFAULT>') }
|
||||
it { is_expected.to contain_nova_config('DEFAULT/block_device_allocate_retries_interval').with_value('<SERVICE DEFAULT>') }
|
||||
it { is_expected.to contain_nova_config('DEFAULT/instance_usage_audit').with_value('<SERVICE DEFAULT>') }
|
||||
it { is_expected.to contain_nova_config('DEFAULT/instance_usage_audit_period').with_value('<SERVICE DEFAULT>') }
|
||||
it { is_expected.to contain_nova_config('DEFAULT/flat_injected').with_value('<SERVICE DEFAULT>') }
|
||||
it { is_expected.to contain_nova_config('DEFAULT/config_drive_format').with_value('<SERVICE DEFAULT>') }
|
||||
|
||||
@ -289,22 +291,6 @@ describe 'nova::compute' do
|
||||
it { should raise_error(Puppet::Error, /vnc_enabled and spice_enabled is mutually exclusive/) }
|
||||
end
|
||||
|
||||
context 'with force_config_drive parameter set to true' do
|
||||
let :params do
|
||||
{ :force_config_drive => true }
|
||||
end
|
||||
|
||||
it { is_expected.to contain_nova_config('DEFAULT/force_config_drive').with_value(true) }
|
||||
end
|
||||
|
||||
context 'with flat_injected parameter set to true' do
|
||||
let :params do
|
||||
{ :flat_injected => true }
|
||||
end
|
||||
|
||||
it { is_expected.to contain_nova_config('DEFAULT/flat_injected').with_value(true) }
|
||||
end
|
||||
|
||||
context 'while not managing service state' do
|
||||
let :params do
|
||||
{
|
||||
@ -315,15 +301,6 @@ describe 'nova::compute' do
|
||||
it { is_expected.to_not contain_service('nova-compute') }
|
||||
end
|
||||
|
||||
context 'with instance_usage_audit parameter set to false' do
|
||||
let :params do
|
||||
{ :instance_usage_audit => false, }
|
||||
end
|
||||
|
||||
it { is_expected.to contain_nova_config('DEFAULT/instance_usage_audit').with_ensure('absent') }
|
||||
it { is_expected.to contain_nova_config('DEFAULT/instance_usage_audit_period').with_ensure('absent') }
|
||||
end
|
||||
|
||||
context 'with instance_usage_audit parameter and period' do
|
||||
let :params do
|
||||
{ :instance_usage_audit => true,
|
||||
@ -334,6 +311,21 @@ describe 'nova::compute' do
|
||||
it { is_expected.to contain_nova_config('DEFAULT/instance_usage_audit_period').with_value('year') }
|
||||
end
|
||||
|
||||
context 'with flat_injected parameter set to true' do
|
||||
let :params do
|
||||
{ :flat_injected => true }
|
||||
end
|
||||
|
||||
it { is_expected.to contain_nova_config('DEFAULT/flat_injected').with_value(true) }
|
||||
end
|
||||
|
||||
context 'with force_config_drive parameter set to true' do
|
||||
let :params do
|
||||
{ :force_config_drive => true }
|
||||
end
|
||||
|
||||
it { is_expected.to contain_nova_config('DEFAULT/force_config_drive').with_value(true) }
|
||||
end
|
||||
end
|
||||
|
||||
on_supported_os({
|
||||
|
Loading…
Reference in New Issue
Block a user