Deprecates old libvirt config

Icehouse brings a new way to configure libvirt with a dedicated section.
This patch aims to configure libvirt in that way and fails when using
old method.

implement blueprint sync-libvirt-config
closes-bug #1259331

Change-Id: I57438e10d207da7df9c7912c311bac1e7fdfe8aa
Signed-off-by: Emilien Macchi <emilien.macchi@enovance.com>
This commit is contained in:
Emilien Macchi
2013-12-25 02:10:52 +01:00
parent c41567b147
commit 2fc85017e5
4 changed files with 169 additions and 113 deletions

View File

@@ -5,8 +5,9 @@
#
# === Parameters:
#
# [*libvirt_type*]
# [*libvirt_virt_type*]
# (optional) Libvirt domain type. Options are: kvm, lxc, qemu, uml, xen
# Replaces libvirt_type
# Defaults to 'kvm'
#
# [*vncserver_listen*]
@@ -18,17 +19,26 @@
# Defaults to false
#
class nova::compute::libvirt (
$libvirt_type = 'kvm',
$libvirt_virt_type = 'kvm',
$vncserver_listen = '127.0.0.1',
$migration_support = false
$migration_support = false,
# DEPRECATED PARAMETER
$libvirt_type = false
) {
include nova::params
Service['libvirt'] -> Service['nova-compute']
if $libvirt_type {
warning ('The libvirt_type parameter is deprecated, use libvirt_virt_type instead.')
$libvirt_virt_type_real = $libvirt_type
} else {
$libvirt_virt_type_real = $libvirt_virt_type
}
if($::osfamily == 'Debian') {
package { "nova-compute-${libvirt_type}":
package { "nova-compute-${libvirt_virt_type_real}":
ensure => present,
before => Package['nova-compute'],
}
@@ -66,8 +76,7 @@ class nova::compute::libvirt (
nova_config {
'DEFAULT/compute_driver': value => 'libvirt.LibvirtDriver';
'DEFAULT/libvirt_type': value => $libvirt_type;
'DEFAULT/connection_type': value => 'libvirt';
'DEFAULT/vncserver_listen': value => $vncserver_listen;
'libvirt/virt_type': value => $libvirt_virt_type_real;
}
}

View File

@@ -20,6 +20,6 @@ class nova::compute::neutron (
}
nova_config {
'DEFAULT/libvirt_vif_driver': value => $libvirt_vif_driver;
'libvirt/vif_driver': value => $libvirt_vif_driver;
}
}

View File

@@ -5,136 +5,183 @@ describe 'nova::compute::libvirt' do
"include nova\ninclude nova::compute"
end
shared_examples 'nova-compute with libvirt' do
it { should contain_class('nova::params') }
context 'with default parameters' do
it 'installs libvirt package and service' do
should contain_package('libvirt').with(
:name => platform_params[:libvirt_package_name],
:ensure => 'present'
)
should contain_service('libvirt').with(
:name => platform_params[:libvirt_service_name],
:ensure => 'running',
:provider => platform_params[:special_service_provider],
:require => 'Package[libvirt]',
:before => 'Service[nova-compute]'
)
end
it 'configures nova.conf' do
should contain_nova_config('DEFAULT/compute_driver').with_value('libvirt.LibvirtDriver')
should contain_nova_config('DEFAULT/libvirt_type').with_value('kvm')
should contain_nova_config('DEFAULT/connection_type').with_value('libvirt')
should contain_nova_config('DEFAULT/vncserver_listen').with_value('127.0.0.1')
end
end
context 'with overridden parameters' do
let :params do
{ :libvirt_type => 'qemu' }
end
it { should contain_nova_config('DEFAULT/libvirt_type').with_value('qemu')}
end
describe 'with migration_support enabled' do
let :params do
{ :migration_support => true }
end
context 'with vncserver_listen set to 0.0.0.0' do
before do
params.merge!( :vncserver_listen => '0.0.0.0' )
end
it {
should contain_class('nova::migration::libvirt')
should contain_nova_config('DEFAULT/vncserver_listen').with_value('0.0.0.0')
}
end
context 'with vncserver_listen not set to 0.0.0.0' do
before do
params.merge!( :vncserver_listen => '127.0.0.1' )
end
it_raises 'a Puppet::Error', /For migration support to work, you MUST set vncserver_listen to '0.0.0.0'/
end
end
end
context 'on Debian platforms' do
describe 'on debian platforms' do
let :facts do
{ :osfamily => 'Debian' }
end
let :platform_params do
{ :libvirt_package_name => 'libvirt-bin',
:libvirt_service_name => 'libvirt-bin' }
describe 'with default parameters' do
it { should contain_class('nova::params')}
it { should contain_package('nova-compute-kvm').with(
:ensure => 'present',
:before => 'Package[nova-compute]'
) }
it { should contain_package('libvirt').with(
:name => 'libvirt-bin',
:ensure => 'present'
) }
it { should contain_service('libvirt').with(
:name => 'libvirt-bin',
:ensure => 'running',
:provider => 'upstart',
:require => 'Package[libvirt]',
:before => 'Service[nova-compute]'
)}
it { should contain_nova_config('DEFAULT/compute_driver').with_value('libvirt.LibvirtDriver')}
it { should contain_nova_config('libvirt/virt_type').with_value('kvm')}
it { should contain_nova_config('DEFAULT/vncserver_listen').with_value('127.0.0.1')}
end
it { should contain_package('nova-compute-kvm').with(
:ensure => 'present',
:before => 'Package[nova-compute]'
) }
context 'on Debian operating systems' do
before do
facts.merge!(:operatingsystem => 'Debian')
platform_params.merge!(:special_service_provider => nil)
describe 'with params' do
let :params do
{ :libvirt_virt_type => 'qemu',
:vncserver_listen => '0.0.0.0'
}
end
it_behaves_like 'nova-compute with libvirt'
it { should contain_nova_config('libvirt/virt_type').with_value('qemu')}
it { should contain_nova_config('DEFAULT/vncserver_listen').with_value('0.0.0.0')}
end
context 'on Ubuntu operating systems' do
before do
facts.merge!(:operatingsystem => 'Ubuntu')
platform_params.merge!(:special_service_provider => 'upstart')
describe 'with deprecated params' do
let :params do
{ :libvirt_type => 'qemu'
}
end
it_behaves_like 'nova-compute with libvirt'
it { should contain_nova_config('libvirt/virt_type').with_value('qemu')}
end
describe 'with migration_support enabled' do
context 'with vncserver_listen set to 0.0.0.0' do
let :params do
{ :vncserver_listen => '0.0.0.0',
:migration_support => true }
end
it { should contain_class('nova::migration::libvirt')}
it { should contain_nova_config('DEFAULT/vncserver_listen').with_value('0.0.0.0')}
end
context 'with vncserver_listen not set to 0.0.0.0' do
let :params do
{ :vncserver_listen => '127.0.0.1',
:migration_support => true }
end
it { expect { should contain_class('nova::compute::libvirt') }.to \
raise_error(Puppet::Error, /For migration support to work, you MUST set vncserver_listen to '0.0.0.0'/) }
end
end
end
context 'on RedHat platforms' do
describe 'on rhel platforms' do
let :facts do
{ :osfamily => 'RedHat' }
{ :operatingsystem => 'RedHat', :osfamily => 'RedHat' }
end
let :platform_params do
{ :libvirt_package_name => 'libvirt',
:libvirt_service_name => 'libvirtd',
:special_service_provider => 'init' }
end
describe 'with default parameters' do
context 'on Fedora operating systems' do
before do
facts.merge!(:operatingsystem => 'Fedora')
platform_params.merge!(:special_service_provider => nil)
end
it { should contain_class('nova::params')}
it_behaves_like 'nova-compute with libvirt'
end
context 'on other operating systems' do
before do
facts.merge!(:operatingsystem => 'RedHat')
platform_params.merge!(:special_service_provider => 'init')
end
it_behaves_like 'nova-compute with libvirt'
it { should contain_package('libvirt').with(
:name => 'libvirt',
:ensure => 'present'
) }
it { should contain_service('libvirt').with(
:name => 'libvirtd',
:ensure => 'running',
:provider => 'init',
:require => 'Package[libvirt]',
:before => 'Service[nova-compute]'
)}
it { should contain_service('messagebus').with(
:ensure => 'running',
:enable => true,
:before => 'Service[libvirt]',
:provider => platform_params[:special_service_provider]
:provider => 'init'
) }
it { should contain_nova_config('DEFAULT/compute_driver').with_value('libvirt.LibvirtDriver')}
it { should contain_nova_config('libvirt/virt_type').with_value('kvm')}
it { should contain_nova_config('DEFAULT/vncserver_listen').with_value('127.0.0.1')}
end
describe 'with params' do
let :params do
{ :libvirt_virt_type => 'qemu',
:vncserver_listen => '0.0.0.0'
}
end
it { should contain_nova_config('libvirt/virt_type').with_value('qemu')}
it { should contain_nova_config('DEFAULT/vncserver_listen').with_value('0.0.0.0')}
end
describe 'with deprecated params' do
let :params do
{ :libvirt_type => 'qemu'
}
end
it { should contain_nova_config('libvirt/virt_type').with_value('qemu')}
end
describe 'with migration_support enabled' do
context 'with vncserver_listen set to 0.0.0.0' do
let :params do
{ :vncserver_listen => '0.0.0.0',
:migration_support => true }
end
it { should contain_class('nova::migration::libvirt')}
it { should contain_nova_config('DEFAULT/vncserver_listen').with_value('0.0.0.0')}
end
context 'with vncserver_listen not set to 0.0.0.0' do
let :params do
{ :vncserver_listen => '127.0.0.1',
:migration_support => true }
end
it { expect { should contain_class('nova::compute::libvirt') }.to \
raise_error(Puppet::Error, /For migration support to work, you MUST set vncserver_listen to '0.0.0.0'/) }
end
end
describe 'with default parameters on Fedora' do
let :facts do
{ :operatingsystem => 'Fedora', :osfamily => 'RedHat' }
end
it { should contain_class('nova::params')}
it { should contain_package('libvirt').with(
:name => 'libvirt',
:ensure => 'present'
) }
it { should contain_service('libvirt').with(
:name => 'libvirtd',
:ensure => 'running',
:provider => nil,
:require => 'Package[libvirt]',
:before => 'Service[nova-compute]'
)}
it { should contain_nova_config('DEFAULT/compute_driver').with_value('libvirt.LibvirtDriver')}
it { should contain_nova_config('libvirt/virt_type').with_value('kvm')}
it { should contain_nova_config('DEFAULT/vncserver_listen').with_value('127.0.0.1')}
end
end
end

View File

@@ -1,13 +1,13 @@
require 'spec_helper'
describe 'nova::compute::neutron' do
it { should contain_nova_config('DEFAULT/libvirt_vif_driver').with_value('nova.virt.libvirt.vif.LibvirtGenericVIFDriver')}
it { should contain_nova_config('libvirt/vif_driver').with_value('nova.virt.libvirt.vif.LibvirtGenericVIFDriver')}
context 'when overriding params' do
let :params do
{:libvirt_vif_driver => 'foo' }
end
it { should contain_nova_config('DEFAULT/libvirt_vif_driver').with_value('foo')}
it { should contain_nova_config('libvirt/vif_driver').with_value('foo')}
end
context 'when overriding with a removed libvirt_vif_driver param' do