Add support for image_cache options
This patch introduces a new class named nova::compute::image_cache, to support parameters in image_cache sections, which were recently added into nova[1]. [1] 828e8047e5c8651ea757bda7922670889d5e8818 Change-Id: I61d81667e4c58b62c453e37072d9aef461923b46
This commit is contained in:
parent
1d848e5aa0
commit
76a91ab0e1
63
manifests/compute/image_cache.pp
Normal file
63
manifests/compute/image_cache.pp
Normal file
@ -0,0 +1,63 @@
|
||||
# == Class: nova::compute::image_cache
|
||||
#
|
||||
# Configures image caching in nova
|
||||
#
|
||||
# === Parameters:
|
||||
#
|
||||
# [*manager_interval*]
|
||||
# (optional) Number of seconds to wait between runs of the image cache manager.
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*subdirectory_name*]
|
||||
# (optional) Location of cached images.
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*remove_unused_base_images*]
|
||||
# (optional) Should unused base images be removed?
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*remove_unused_original_minimum_age_seconds*]
|
||||
# (optional) Unused unresized base images younger than this will not be removed.
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*remove_unused_resized_minimum_age_seconds*]
|
||||
# (optional) Unused resized base images younger than this will not be removed.
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*precache_concurrency*]
|
||||
# (optional) Maximum number of compute hosts to trigger image precaching
|
||||
# in parallel.
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
class nova::compute::image_cache (
|
||||
$manager_interval = $::os_service_default,
|
||||
$subdirectory_name = $::os_service_default,
|
||||
$remove_unused_base_images = $::os_service_default,
|
||||
$remove_unused_original_minimum_age_seconds = $::os_service_default,
|
||||
$remove_unused_resized_minimum_age_seconds = $::os_service_default,
|
||||
$precache_concurrency = $::os_service_default
|
||||
) {
|
||||
|
||||
include nova::deps
|
||||
|
||||
$remove_unused_base_images_real = pick(
|
||||
$::nova::compute::libvirt::remove_unused_base_images,
|
||||
$remove_unused_base_images)
|
||||
|
||||
$remove_unused_original_minimum_age_seconds_real = pick(
|
||||
$::nova::compute::libvirt::remove_unused_original_minimum_age_seconds,
|
||||
$remove_unused_original_minimum_age_seconds)
|
||||
|
||||
$remove_unused_resized_minimum_age_seconds_real = pick(
|
||||
$::nova::compute::libvirt::remove_unused_resized_minimum_age_seconds,
|
||||
$remove_unused_resized_minimum_age_seconds)
|
||||
|
||||
nova_config {
|
||||
'image_cache/manager_interval': value => $manager_interval;
|
||||
'image_cache/subdirectory_name': value => $subdirectory_name;
|
||||
'image_cache/remove_unused_base_images': value => $remove_unused_base_images_real;
|
||||
'image_cache/remove_unused_original_minimum_age_seconds': value => $remove_unused_original_minimum_age_seconds_real;
|
||||
'image_cache/remove_unused_resized_minimum_age_seconds': value => $remove_unused_resized_minimum_age_seconds_real;
|
||||
'image_cache/precache_concurrency': value => $precache_concurrency;
|
||||
}
|
||||
}
|
@ -82,28 +82,6 @@
|
||||
# which you may need to search key words ``VIR_PERF_PARAM_*``
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*remove_unused_base_images*]
|
||||
# (optional) Should unused base images be removed?
|
||||
# If undef is specified, remove the line in nova.conf
|
||||
# otherwise, use a boolean to remove or not the base images.
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*remove_unused_resized_minimum_age_seconds*]
|
||||
# (optional) Unused resized base images younger
|
||||
# than this will not be removed
|
||||
# If undef is specified, remove the line in nova.conf
|
||||
# otherwise, use a integer or a string to define after
|
||||
# how many seconds it will be removed.
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*remove_unused_original_minimum_age_seconds*]
|
||||
# (optional) Unused unresized base images younger
|
||||
# than this will not be removed
|
||||
# If undef is specified, remove the line in nova.conf
|
||||
# otherwise, use a integer or a string to define after
|
||||
# how many seconds it will be removed.
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*libvirt_service_name*]
|
||||
# (optional) libvirt service name.
|
||||
# Defaults to $::nova::params::libvirt_service_name
|
||||
@ -282,6 +260,28 @@
|
||||
# which you may need to search key words ``VIR_PERF_PARAM_*``
|
||||
# Defaults to undef
|
||||
#
|
||||
# [*remove_unused_base_images*]
|
||||
# (optional) Should unused base images be removed?
|
||||
# If undef is specified, remove the line in nova.conf
|
||||
# otherwise, use a boolean to remove or not the base images.
|
||||
# Defaults to undef
|
||||
#
|
||||
# [*remove_unused_resized_minimum_age_seconds*]
|
||||
# (optional) Unused resized base images younger
|
||||
# than this will not be removed
|
||||
# If undef is specified, remove the line in nova.conf
|
||||
# otherwise, use a integer or a string to define after
|
||||
# how many seconds it will be removed.
|
||||
# Defaults to undef
|
||||
#
|
||||
# [*remove_unused_original_minimum_age_seconds*]
|
||||
# (optional) Unused unresized base images younger
|
||||
# than this will not be removed
|
||||
# If undef is specified, remove the line in nova.conf
|
||||
# otherwise, use a integer or a string to define after
|
||||
# how many seconds it will be removed.
|
||||
# Defaults to undef
|
||||
#
|
||||
class nova::compute::libvirt (
|
||||
$ensure_package = 'present',
|
||||
$virt_type = 'kvm',
|
||||
@ -298,9 +298,6 @@ class nova::compute::libvirt (
|
||||
$inject_key = false,
|
||||
$inject_partition = -2,
|
||||
$enabled_perf_events = $::os_service_default,
|
||||
$remove_unused_base_images = $::os_service_default,
|
||||
$remove_unused_resized_minimum_age_seconds = $::os_service_default,
|
||||
$remove_unused_original_minimum_age_seconds = $::os_service_default,
|
||||
$libvirt_service_name = $::nova::params::libvirt_service_name,
|
||||
$virtlock_service_name = $::nova::params::virtlock_service_name,
|
||||
$virtlog_service_name = $::nova::params::virtlog_service_name,
|
||||
@ -335,11 +332,40 @@ class nova::compute::libvirt (
|
||||
$libvirt_inject_key = undef,
|
||||
$libvirt_inject_partition = undef,
|
||||
$libvirt_enabled_perf_events = undef,
|
||||
$remove_unused_base_images = undef,
|
||||
$remove_unused_resized_minimum_age_seconds = undef,
|
||||
$remove_unused_original_minimum_age_seconds = undef,
|
||||
) inherits nova::params {
|
||||
|
||||
include nova::deps
|
||||
include nova::params
|
||||
|
||||
if $remove_unused_base_images != undef {
|
||||
warning('The remove_unused_base_images parameter was deprecated and \
|
||||
will be removed in a future release. Use the nova::compute::image_cache class')
|
||||
}
|
||||
|
||||
if $remove_unused_resized_minimum_age_seconds != undef {
|
||||
warning('The remove_unused_resized_minimum_age_seconds parameter was deprecated and \
|
||||
will be removed in a future release. Use the nova::compute::image_cache class')
|
||||
}
|
||||
|
||||
if $remove_unused_original_minimum_age_seconds != undef {
|
||||
warning('The remove_unused_original_minimum_age_seconds parameter was deprecated and \
|
||||
will be removed in a future release. Use the nova::compute::image_cache class')
|
||||
}
|
||||
|
||||
# TODO(tkajinam): Remove this when removing deprecated image cache parameters
|
||||
include nova::compute::image_cache
|
||||
|
||||
# Cleanup deprecated image cache parameters
|
||||
nova_config {
|
||||
'DEFAULT/remove_unused_base_images': ensure => 'absent';
|
||||
'DEFAULT/remove_unused_original_minimum_age_seconds': ensure => 'absent';
|
||||
'libvirt/remove_unused_resize_minimum_age_seconds': ensure => 'absent';
|
||||
}
|
||||
|
||||
|
||||
if $libvirt_virt_type != undef {
|
||||
warning('The libvirt_virt_type parameter was deprecated and will be removed \
|
||||
in a future release. Use the virt_type parameter instead')
|
||||
@ -601,40 +627,4 @@ in a future release. Use the cpu_models parameter instead')
|
||||
'libvirt/disk_cachemodes': ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
if $remove_unused_resized_minimum_age_seconds == undef {
|
||||
warning('Use $::os_service_default instead of undef for the remove_unused_resized_minimum_age_seconds \
|
||||
parameter. The current behavior for undef will be changed in a future release')
|
||||
nova_config {
|
||||
'libvirt/remove_unused_resized_minimum_age_seconds': ensure => absent;
|
||||
}
|
||||
} else {
|
||||
nova_config {
|
||||
'libvirt/remove_unused_resized_minimum_age_seconds': value => $remove_unused_resized_minimum_age_seconds;
|
||||
}
|
||||
}
|
||||
|
||||
if $remove_unused_base_images == undef {
|
||||
warning('Use $::os_service_default instead of undef for the remove_unused_base_images \
|
||||
parameter. The current behavior for undef will be changed in a future release')
|
||||
nova_config {
|
||||
'DEFAULT/remove_unused_base_images': ensure => absent;
|
||||
}
|
||||
} else {
|
||||
nova_config {
|
||||
'DEFAULT/remove_unused_base_images': value => $remove_unused_base_images;
|
||||
}
|
||||
}
|
||||
|
||||
if $remove_unused_original_minimum_age_seconds == undef {
|
||||
warning('Use $::os_service_default instead of undef for the remove_unused_original_minimum_age_seconds \
|
||||
parameter. The current behavior for undef will be changed in a future release')
|
||||
nova_config {
|
||||
'DEFAULT/remove_unused_original_minimum_age_seconds': ensure => absent;
|
||||
}
|
||||
} else {
|
||||
nova_config {
|
||||
'DEFAULT/remove_unused_original_minimum_age_seconds': value => $remove_unused_original_minimum_age_seconds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
14
releasenotes/notes/compute-image_cache-11d66c225ce11596.yaml
Normal file
14
releasenotes/notes/compute-image_cache-11d66c225ce11596.yaml
Normal file
@ -0,0 +1,14 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
The new ``nova::compute::image_cache`` class has been added to manage
|
||||
parameters for image cache feature.
|
||||
deprecations:
|
||||
- |
|
||||
The following parameters in the ``nova::compute::libvirt`` class have been
|
||||
deprecated and will be removed in a future release. Use the corresponding
|
||||
parameter in the new ``nova::compute::image_cache`` class.
|
||||
|
||||
- ``remove_unused_base_images``
|
||||
- ``remove_unused_original_minimum_age_seconds``
|
||||
- ``remove_unused_resize_minimum_age_seconds``
|
52
spec/classes/nova_compute_image_cache_spec.rb
Normal file
52
spec/classes/nova_compute_image_cache_spec.rb
Normal file
@ -0,0 +1,52 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'nova::compute::image_cache' do
|
||||
|
||||
shared_examples 'nova::compute::image_cache' do
|
||||
context 'with no parameters' do
|
||||
|
||||
it 'configures image cache in nova.conf' do
|
||||
should contain_nova_config('image_cache/manager_interval').with_value('<SERVICE DEFAULT>')
|
||||
should contain_nova_config('image_cache/subdirectory_name').with_value('<SERVICE DEFAULT>')
|
||||
should contain_nova_config('image_cache/remove_unused_base_images').with_value('<SERVICE DEFAULT>')
|
||||
should contain_nova_config('image_cache/remove_unused_original_minimum_age_seconds').with_value('<SERVICE DEFAULT>')
|
||||
should contain_nova_config('image_cache/remove_unused_resized_minimum_age_seconds').with_value('<SERVICE DEFAULT>')
|
||||
should contain_nova_config('image_cache/precache_concurrency').with_value('<SERVICE DEFAULT>')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when specified parameters' do
|
||||
let :params do
|
||||
{
|
||||
:manager_interval => 2400,
|
||||
:subdirectory_name => '_base',
|
||||
:remove_unused_base_images => true,
|
||||
:remove_unused_original_minimum_age_seconds => 86400,
|
||||
:remove_unused_resized_minimum_age_seconds => 3600,
|
||||
:precache_concurrency => 1,
|
||||
}
|
||||
end
|
||||
|
||||
it 'configures image cache in nova.conf' do
|
||||
should contain_nova_config('image_cache/manager_interval').with_value(2400)
|
||||
should contain_nova_config('image_cache/subdirectory_name').with_value('_base')
|
||||
should contain_nova_config('image_cache/remove_unused_base_images').with_value(true)
|
||||
should contain_nova_config('image_cache/remove_unused_original_minimum_age_seconds').with_value(86400)
|
||||
should contain_nova_config('image_cache/remove_unused_resized_minimum_age_seconds').with_value(3600)
|
||||
should contain_nova_config('image_cache/precache_concurrency').with_value(1)
|
||||
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_behaves_like 'nova::compute::image_cache'
|
||||
end
|
||||
end
|
||||
end
|
@ -58,9 +58,6 @@ describe 'nova::compute::libvirt' do
|
||||
it { is_expected.to contain_nova_config('libvirt/inject_key').with_value(false)}
|
||||
it { is_expected.to contain_nova_config('libvirt/inject_partition').with_value(-2)}
|
||||
it { is_expected.to contain_nova_config('vnc/server_listen').with_value('127.0.0.1')}
|
||||
it { is_expected.to contain_nova_config('DEFAULT/remove_unused_base_images').with_value('<SERVICE DEFAULT>')}
|
||||
it { is_expected.to contain_nova_config('DEFAULT/remove_unused_original_minimum_age_seconds').with_value('<SERVICE DEFAULT>')}
|
||||
it { is_expected.to contain_nova_config('libvirt/remove_unused_resized_minimum_age_seconds').with_value('<SERVICE DEFAULT>')}
|
||||
it { is_expected.to contain_nova_config('libvirt/rx_queue_size').with_value('<SERVICE DEFAULT>')}
|
||||
it { is_expected.to contain_nova_config('libvirt/tx_queue_size').with_value('<SERVICE DEFAULT>')}
|
||||
it { is_expected.to contain_nova_config('libvirt/volume_use_multipath').with_value('<SERVICE DEFAULT>')}
|
||||
@ -90,9 +87,6 @@ describe 'nova::compute::libvirt' do
|
||||
:hw_disk_discard => 'unmap',
|
||||
:hw_machine_type => 'x86_64=machinetype1,armv7l=machinetype2',
|
||||
:enabled_perf_events => ['cmt', 'mbml', 'mbmt'],
|
||||
:remove_unused_base_images => true,
|
||||
:remove_unused_resized_minimum_age_seconds => 3600,
|
||||
:remove_unused_original_minimum_age_seconds => 3600,
|
||||
:libvirt_service_name => 'custom_service',
|
||||
:virtlock_service_name => 'virtlock',
|
||||
:virtlog_service_name => 'virtlog',
|
||||
@ -132,9 +126,6 @@ describe 'nova::compute::libvirt' do
|
||||
it { is_expected.to contain_nova_config('libvirt/hw_machine_type').with_value('x86_64=machinetype1,armv7l=machinetype2')}
|
||||
it { is_expected.to contain_nova_config('libvirt/enabled_perf_events').with_value('cmt,mbml,mbmt')}
|
||||
it { is_expected.to contain_nova_config('vnc/server_listen').with_value('0.0.0.0')}
|
||||
it { is_expected.to contain_nova_config('DEFAULT/remove_unused_base_images').with_value(true)}
|
||||
it { is_expected.to contain_nova_config('DEFAULT/remove_unused_original_minimum_age_seconds').with_value(3600)}
|
||||
it { is_expected.to contain_nova_config('libvirt/remove_unused_resized_minimum_age_seconds').with_value(3600)}
|
||||
it { is_expected.to contain_nova_config('libvirt/rx_queue_size').with_value(512)}
|
||||
it { is_expected.to contain_nova_config('libvirt/tx_queue_size').with_value(1024)}
|
||||
it { is_expected.to contain_nova_config('libvirt/volume_use_multipath').with_value(false)}
|
||||
@ -320,9 +311,6 @@ describe 'nova::compute::libvirt' do
|
||||
it { is_expected.to contain_nova_config('libvirt/inject_key').with_value(false)}
|
||||
it { is_expected.to contain_nova_config('libvirt/inject_partition').with_value(-2)}
|
||||
it { is_expected.to contain_nova_config('vnc/server_listen').with_value('127.0.0.1')}
|
||||
it { is_expected.to contain_nova_config('DEFAULT/remove_unused_base_images').with_value('<SERVICE DEFAULT>')}
|
||||
it { is_expected.to contain_nova_config('DEFAULT/remove_unused_original_minimum_age_seconds').with_value('<SERVICE DEFAULT>')}
|
||||
it { is_expected.to contain_nova_config('libvirt/remove_unused_resized_minimum_age_seconds').with_value('<SERVICE DEFAULT>')}
|
||||
it { is_expected.to contain_nova_config('libvirt/nfs_mount_options').with_value('<SERVICE DEFAULT>')}
|
||||
end
|
||||
|
||||
@ -330,9 +318,6 @@ describe 'nova::compute::libvirt' do
|
||||
let :params do
|
||||
{ :virt_type => 'qemu',
|
||||
:vncserver_listen => '0.0.0.0',
|
||||
:remove_unused_base_images => true,
|
||||
:remove_unused_resized_minimum_age_seconds => 3600,
|
||||
:remove_unused_original_minimum_age_seconds => 3600,
|
||||
:enabled_perf_events => ['cmt', 'mbml', 'mbmt'],
|
||||
:nfs_mount_options => 'rw,intr,nolock',
|
||||
:mem_stats_period_seconds => 20,
|
||||
@ -341,9 +326,6 @@ describe 'nova::compute::libvirt' do
|
||||
|
||||
it { is_expected.to contain_nova_config('libvirt/virt_type').with_value('qemu')}
|
||||
it { is_expected.to contain_nova_config('vnc/server_listen').with_value('0.0.0.0')}
|
||||
it { is_expected.to contain_nova_config('DEFAULT/remove_unused_base_images').with_value(true)}
|
||||
it { is_expected.to contain_nova_config('DEFAULT/remove_unused_original_minimum_age_seconds').with_value(3600)}
|
||||
it { is_expected.to contain_nova_config('libvirt/remove_unused_resized_minimum_age_seconds').with_value(3600)}
|
||||
it { is_expected.to contain_nova_config('libvirt/enabled_perf_events').with_value('cmt,mbml,mbmt')}
|
||||
it { is_expected.to contain_nova_config('libvirt/nfs_mount_options').with_value('rw,intr,nolock')}
|
||||
it { is_expected.to contain_nova_config('libvirt/mem_stats_period_seconds').with_value(20)}
|
||||
|
Loading…
x
Reference in New Issue
Block a user