Add class for migration options configuration in qemu.conf
Change-Id: I8d346c55de637324d4b80a80eb827140c46a984d Related-Bug: #1627476
This commit is contained in:
54
manifests/migration/qemu.pp
Normal file
54
manifests/migration/qemu.pp
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
# == Class: nova::migration::qemu
|
||||||
|
#
|
||||||
|
# Sets qemu config that is required for migration
|
||||||
|
#
|
||||||
|
# === Parameters:
|
||||||
|
#
|
||||||
|
# [*configure_qemu*]
|
||||||
|
# (optional) Whether or not configure qemu bits.
|
||||||
|
# Defaults to false.
|
||||||
|
#
|
||||||
|
# [*migration_port_min*]
|
||||||
|
# (optional) Lower limit of port range used for migration.
|
||||||
|
# Defaults to 49152.
|
||||||
|
#
|
||||||
|
# [*migration_port_max*]
|
||||||
|
# (optional) Higher limit of port range used for migration.
|
||||||
|
# Defaults to 49215.
|
||||||
|
#
|
||||||
|
class nova::migration::qemu(
|
||||||
|
$configure_qemu = false,
|
||||||
|
$migration_port_min = 49152,
|
||||||
|
$migration_port_max = 49215,
|
||||||
|
){
|
||||||
|
|
||||||
|
include ::nova::deps
|
||||||
|
|
||||||
|
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-migration-ports':
|
||||||
|
context => '/files/etc/libvirt/qemu.conf',
|
||||||
|
changes => [
|
||||||
|
"set migration_port_min ${migration_port_min}",
|
||||||
|
"set migration_port_max ${migration_port_max}",
|
||||||
|
],
|
||||||
|
tag => 'qemu-conf-augeas',
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
augeas { 'qemu-conf-migration-ports':
|
||||||
|
context => '/files/etc/libvirt/qemu.conf',
|
||||||
|
changes => [
|
||||||
|
'rm migration_port_min',
|
||||||
|
'rm migration_port_max',
|
||||||
|
],
|
||||||
|
tag => 'qemu-conf-augeas',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- Add class for management of migration
|
||||||
|
options in qemu.conf
|
66
spec/classes/nova_migration_qemu_spec.rb
Normal file
66
spec/classes/nova_migration_qemu_spec.rb
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe 'nova::migration::qemu' do
|
||||||
|
|
||||||
|
let :pre_condition do
|
||||||
|
'include nova
|
||||||
|
include nova::compute
|
||||||
|
include nova::compute::libvirt'
|
||||||
|
end
|
||||||
|
|
||||||
|
shared_examples_for 'nova migration with qemu' do
|
||||||
|
|
||||||
|
context 'when not configuring qemu' do
|
||||||
|
let :params do
|
||||||
|
{
|
||||||
|
:configure_qemu => false
|
||||||
|
}
|
||||||
|
end
|
||||||
|
it { is_expected.to contain_augeas('qemu-conf-migration-ports').with({
|
||||||
|
:context => '/files/etc/libvirt/qemu.conf',
|
||||||
|
:changes => [ "rm migration_port_min", "rm migration_port_max" ],
|
||||||
|
}).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-migration-ports').with({
|
||||||
|
:context => '/files/etc/libvirt/qemu.conf',
|
||||||
|
:changes => [ "set migration_port_min 49152", "set migration_port_max 49215" ],
|
||||||
|
:tag => 'qemu-conf-augeas',
|
||||||
|
}).that_notifies('Service[libvirt]') }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when configuring qemu with overriden parameters' do
|
||||||
|
let :params do
|
||||||
|
{
|
||||||
|
:configure_qemu => true,
|
||||||
|
:migration_port_min => 61138,
|
||||||
|
:migration_port_max => 61200,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
it { is_expected.to contain_augeas('qemu-conf-migration-ports').with({
|
||||||
|
:context => '/files/etc/libvirt/qemu.conf',
|
||||||
|
:changes => [ "set migration_port_min 61138", "set migration_port_max 61200" ],
|
||||||
|
: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 migration with qemu'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
Reference in New Issue
Block a user