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:
@@ -5,8 +5,9 @@
|
|||||||
#
|
#
|
||||||
# === Parameters:
|
# === Parameters:
|
||||||
#
|
#
|
||||||
# [*libvirt_type*]
|
# [*libvirt_virt_type*]
|
||||||
# (optional) Libvirt domain type. Options are: kvm, lxc, qemu, uml, xen
|
# (optional) Libvirt domain type. Options are: kvm, lxc, qemu, uml, xen
|
||||||
|
# Replaces libvirt_type
|
||||||
# Defaults to 'kvm'
|
# Defaults to 'kvm'
|
||||||
#
|
#
|
||||||
# [*vncserver_listen*]
|
# [*vncserver_listen*]
|
||||||
@@ -18,17 +19,26 @@
|
|||||||
# Defaults to false
|
# Defaults to false
|
||||||
#
|
#
|
||||||
class nova::compute::libvirt (
|
class nova::compute::libvirt (
|
||||||
$libvirt_type = 'kvm',
|
$libvirt_virt_type = 'kvm',
|
||||||
$vncserver_listen = '127.0.0.1',
|
$vncserver_listen = '127.0.0.1',
|
||||||
$migration_support = false
|
$migration_support = false,
|
||||||
|
# DEPRECATED PARAMETER
|
||||||
|
$libvirt_type = false
|
||||||
) {
|
) {
|
||||||
|
|
||||||
include nova::params
|
include nova::params
|
||||||
|
|
||||||
Service['libvirt'] -> Service['nova-compute']
|
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') {
|
if($::osfamily == 'Debian') {
|
||||||
package { "nova-compute-${libvirt_type}":
|
package { "nova-compute-${libvirt_virt_type_real}":
|
||||||
ensure => present,
|
ensure => present,
|
||||||
before => Package['nova-compute'],
|
before => Package['nova-compute'],
|
||||||
}
|
}
|
||||||
@@ -66,8 +76,7 @@ class nova::compute::libvirt (
|
|||||||
|
|
||||||
nova_config {
|
nova_config {
|
||||||
'DEFAULT/compute_driver': value => 'libvirt.LibvirtDriver';
|
'DEFAULT/compute_driver': value => 'libvirt.LibvirtDriver';
|
||||||
'DEFAULT/libvirt_type': value => $libvirt_type;
|
|
||||||
'DEFAULT/connection_type': value => 'libvirt';
|
|
||||||
'DEFAULT/vncserver_listen': value => $vncserver_listen;
|
'DEFAULT/vncserver_listen': value => $vncserver_listen;
|
||||||
|
'libvirt/virt_type': value => $libvirt_virt_type_real;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,6 +20,6 @@ class nova::compute::neutron (
|
|||||||
}
|
}
|
||||||
|
|
||||||
nova_config {
|
nova_config {
|
||||||
'DEFAULT/libvirt_vif_driver': value => $libvirt_vif_driver;
|
'libvirt/vif_driver': value => $libvirt_vif_driver;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -5,136 +5,183 @@ describe 'nova::compute::libvirt' do
|
|||||||
"include nova\ninclude nova::compute"
|
"include nova\ninclude nova::compute"
|
||||||
end
|
end
|
||||||
|
|
||||||
shared_examples 'nova-compute with libvirt' do
|
describe 'on debian platforms' 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
|
|
||||||
let :facts do
|
let :facts do
|
||||||
{ :osfamily => 'Debian' }
|
{ :osfamily => 'Debian' }
|
||||||
end
|
end
|
||||||
|
|
||||||
let :platform_params do
|
describe 'with default parameters' do
|
||||||
{ :libvirt_package_name => 'libvirt-bin',
|
|
||||||
:libvirt_service_name => 'libvirt-bin' }
|
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
|
end
|
||||||
|
|
||||||
it { should contain_package('nova-compute-kvm').with(
|
describe 'with params' do
|
||||||
:ensure => 'present',
|
let :params do
|
||||||
:before => 'Package[nova-compute]'
|
{ :libvirt_virt_type => 'qemu',
|
||||||
) }
|
:vncserver_listen => '0.0.0.0'
|
||||||
|
}
|
||||||
context 'on Debian operating systems' do
|
|
||||||
before do
|
|
||||||
facts.merge!(:operatingsystem => 'Debian')
|
|
||||||
platform_params.merge!(:special_service_provider => nil)
|
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
context 'on Ubuntu operating systems' do
|
describe 'with deprecated params' do
|
||||||
before do
|
let :params do
|
||||||
facts.merge!(:operatingsystem => 'Ubuntu')
|
{ :libvirt_type => 'qemu'
|
||||||
platform_params.merge!(:special_service_provider => 'upstart')
|
}
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'on RedHat platforms' do
|
|
||||||
|
describe 'on rhel platforms' do
|
||||||
let :facts do
|
let :facts do
|
||||||
{ :osfamily => 'RedHat' }
|
{ :operatingsystem => 'RedHat', :osfamily => 'RedHat' }
|
||||||
end
|
end
|
||||||
|
|
||||||
let :platform_params do
|
describe 'with default parameters' do
|
||||||
{ :libvirt_package_name => 'libvirt',
|
|
||||||
:libvirt_service_name => 'libvirtd',
|
|
||||||
:special_service_provider => 'init' }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'on Fedora operating systems' do
|
it { should contain_class('nova::params')}
|
||||||
before do
|
|
||||||
facts.merge!(:operatingsystem => 'Fedora')
|
|
||||||
platform_params.merge!(:special_service_provider => nil)
|
|
||||||
end
|
|
||||||
|
|
||||||
it_behaves_like 'nova-compute with libvirt'
|
it { should contain_package('libvirt').with(
|
||||||
end
|
:name => 'libvirt',
|
||||||
|
:ensure => 'present'
|
||||||
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_service('libvirt').with(
|
||||||
|
:name => 'libvirtd',
|
||||||
|
:ensure => 'running',
|
||||||
|
:provider => 'init',
|
||||||
|
:require => 'Package[libvirt]',
|
||||||
|
:before => 'Service[nova-compute]'
|
||||||
|
)}
|
||||||
it { should contain_service('messagebus').with(
|
it { should contain_service('messagebus').with(
|
||||||
:ensure => 'running',
|
:ensure => 'running',
|
||||||
:enable => true,
|
:enable => true,
|
||||||
:before => 'Service[libvirt]',
|
: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
|
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
|
||||||
end
|
end
|
||||||
|
@@ -1,13 +1,13 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
describe 'nova::compute::neutron' do
|
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
|
context 'when overriding params' do
|
||||||
let :params do
|
let :params do
|
||||||
{:libvirt_vif_driver => 'foo' }
|
{:libvirt_vif_driver => 'foo' }
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
context 'when overriding with a removed libvirt_vif_driver param' do
|
context 'when overriding with a removed libvirt_vif_driver param' do
|
||||||
|
Reference in New Issue
Block a user