Add nova::compute::libvirt::qemu class to configure limits
This change adds a class meant to configure the max_files and max_processes limits in libvirt/qemu.conf, it uses augeas and supports config cleanup. Change-Id: I5fa423a4b212d14f6e9ff6a270931b569558b54e
This commit is contained in:
parent
8ee6ab2918
commit
88a7bc8b20
55
manifests/compute/libvirt/qemu.pp
Normal file
55
manifests/compute/libvirt/qemu.pp
Normal file
@ -0,0 +1,55 @@
|
||||
# == Class: nova::compute::libvirt::qemu
|
||||
#
|
||||
# Configures qemu limits for use by libvirt
|
||||
#
|
||||
# === Parameters:
|
||||
#
|
||||
# [*configure_qemu*]
|
||||
# (optional) Whether or not configure qemu bits.
|
||||
# Defaults to false.
|
||||
#
|
||||
# [*max_files*]
|
||||
# (optional) Maximum number of opened files, per process.
|
||||
# Defaults to 1024.
|
||||
#
|
||||
# [*max_processes*]
|
||||
# (optional) Maximum number of processes that can be run by qemu user.
|
||||
# Defaults to 4096.
|
||||
#
|
||||
class nova::compute::libvirt::qemu(
|
||||
$configure_qemu = false,
|
||||
$max_files = 1024,
|
||||
$max_processes = 4096,
|
||||
){
|
||||
|
||||
include ::nova::deps
|
||||
require ::nova::compute::libvirt
|
||||
|
||||
Anchor['nova::config::begin']
|
||||
-> Augeas<| tag == 'qemu-conf-augeas'|>
|
||||
-> Anchor['nova::config::end']
|
||||
|
||||
Augeas<| tag == 'qemu-conf-augeas'|>
|
||||
~> Service['libvirt']
|
||||
|
||||
if $configure_qemu {
|
||||
|
||||
augeas { 'qemu-conf-limits':
|
||||
context => '/files/etc/libvirt/qemu.conf',
|
||||
changes => [
|
||||
"set max_files ${max_files}",
|
||||
"set max_processes ${max_processes}",
|
||||
],
|
||||
tag => 'qemu-conf-augeas',
|
||||
}
|
||||
} else {
|
||||
augeas { 'qemu-conf-limits':
|
||||
context => '/files/etc/libvirt/qemu.conf',
|
||||
changes => [
|
||||
'rm max_files',
|
||||
'rm max_processes',
|
||||
],
|
||||
tag => 'qemu-conf-augeas',
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- A new nova::compute::libvirt::qemu class has been added
|
||||
with the initial purpose of configuring the max_files
|
||||
and max_processes limits in qemu.conf
|
66
spec/classes/nova_compute_libvirt_qemu_spec.rb
Normal file
66
spec/classes/nova_compute_libvirt_qemu_spec.rb
Normal file
@ -0,0 +1,66 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'nova::compute::libvirt::qemu' do
|
||||
|
||||
let :pre_condition do
|
||||
'include nova
|
||||
include nova::compute
|
||||
include nova::compute::libvirt'
|
||||
end
|
||||
|
||||
shared_examples_for 'nova compute libvirt with qemu' do
|
||||
|
||||
context 'when not configuring qemu' do
|
||||
let :params do
|
||||
{
|
||||
:configure_qemu => false
|
||||
}
|
||||
end
|
||||
it { is_expected.to contain_augeas('qemu-conf-limits').with({
|
||||
:context => '/files/etc/libvirt/qemu.conf',
|
||||
:changes => [ "rm max_files", "rm max_processes" ],
|
||||
}).that_notifies('Service[libvirt]') }
|
||||
end
|
||||
|
||||
context 'when configuring qemu by default' do
|
||||
let :params do
|
||||
{
|
||||
:configure_qemu => true
|
||||
}
|
||||
end
|
||||
it { is_expected.to contain_augeas('qemu-conf-limits').with({
|
||||
:context => '/files/etc/libvirt/qemu.conf',
|
||||
:changes => [ "set max_files 1024", "set max_processes 4096" ],
|
||||
:tag => 'qemu-conf-augeas',
|
||||
}).that_notifies('Service[libvirt]') }
|
||||
end
|
||||
|
||||
context 'when configuring qemu with overriden parameters' do
|
||||
let :params do
|
||||
{
|
||||
:configure_qemu => true,
|
||||
:max_files => 32768,
|
||||
:max_processes => 131072,
|
||||
}
|
||||
end
|
||||
it { is_expected.to contain_augeas('qemu-conf-limits').with({
|
||||
:context => '/files/etc/libvirt/qemu.conf',
|
||||
:changes => [ "set max_files 32768", "set max_processes 131072" ],
|
||||
:tag => 'qemu-conf-augeas',
|
||||
}).that_notifies('Service[libvirt]') }
|
||||
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 libvirt with qemu'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue
Block a user