2013-03-19 14:34:35 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
describe 'nova::compute::libvirt' do
|
|
|
|
|
|
|
|
let :pre_condition do
|
2013-03-20 12:59:19 -07:00
|
|
|
"include nova\ninclude nova::compute"
|
2013-03-19 14:34:35 -04:00
|
|
|
end
|
|
|
|
|
2014-01-30 17:09:21 -05:00
|
|
|
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
|
2013-03-19 14:34:35 -04:00
|
|
|
|
2014-01-30 17:09:21 -05:00
|
|
|
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
|
2013-03-19 14:34:35 -04:00
|
|
|
end
|
|
|
|
|
2014-01-30 17:09:21 -05:00
|
|
|
context 'with overridden parameters' do
|
2013-03-19 14:34:35 -04:00
|
|
|
let :params do
|
2014-01-30 17:09:21 -05:00
|
|
|
{ :libvirt_type => 'qemu' }
|
2013-03-19 14:34:35 -04:00
|
|
|
end
|
|
|
|
|
2013-04-12 15:00:50 -07:00
|
|
|
it { should contain_nova_config('DEFAULT/libvirt_type').with_value('qemu')}
|
2013-03-19 14:34:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'with migration_support enabled' do
|
2014-01-30 17:09:21 -05:00
|
|
|
let :params do
|
|
|
|
{ :migration_support => true }
|
|
|
|
end
|
2013-03-19 14:34:35 -04:00
|
|
|
|
|
|
|
context 'with vncserver_listen set to 0.0.0.0' do
|
2014-01-30 17:09:21 -05:00
|
|
|
before do
|
|
|
|
params.merge!( :vncserver_listen => '0.0.0.0' )
|
2013-03-19 14:34:35 -04:00
|
|
|
end
|
|
|
|
|
2014-01-30 17:09:21 -05:00
|
|
|
it {
|
|
|
|
should contain_class('nova::migration::libvirt')
|
|
|
|
should contain_nova_config('DEFAULT/vncserver_listen').with_value('0.0.0.0')
|
|
|
|
}
|
2013-03-19 14:34:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'with vncserver_listen not set to 0.0.0.0' do
|
2014-01-30 17:09:21 -05:00
|
|
|
before do
|
|
|
|
params.merge!( :vncserver_listen => '127.0.0.1' )
|
2013-03-19 14:34:35 -04:00
|
|
|
end
|
|
|
|
|
2014-01-30 17:09:21 -05:00
|
|
|
it_raises 'a Puppet::Error', /For migration support to work, you MUST set vncserver_listen to '0.0.0.0'/
|
2013-03-19 14:34:35 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-01-30 17:09:21 -05:00
|
|
|
context 'on Debian platforms' do
|
2013-03-19 14:34:35 -04:00
|
|
|
let :facts do
|
2014-01-30 17:09:21 -05:00
|
|
|
{ :osfamily => 'Debian' }
|
2013-03-19 14:34:35 -04:00
|
|
|
end
|
|
|
|
|
2014-01-30 17:09:21 -05:00
|
|
|
let :platform_params do
|
|
|
|
{ :libvirt_package_name => 'libvirt-bin',
|
|
|
|
:libvirt_service_name => 'libvirt-bin' }
|
|
|
|
end
|
2013-03-19 14:34:35 -04:00
|
|
|
|
2014-01-30 17:09:21 -05:00
|
|
|
it { should contain_package('nova-compute-kvm').with(
|
|
|
|
:ensure => 'present',
|
|
|
|
:before => 'Package[nova-compute]'
|
|
|
|
) }
|
2013-03-19 14:34:35 -04:00
|
|
|
|
2014-01-30 17:09:21 -05:00
|
|
|
context 'on Debian operating systems' do
|
|
|
|
before do
|
|
|
|
facts.merge!(:operatingsystem => 'Debian')
|
|
|
|
platform_params.merge!(:special_service_provider => nil)
|
|
|
|
end
|
2013-03-19 14:34:35 -04:00
|
|
|
|
2014-01-30 17:09:21 -05:00
|
|
|
it_behaves_like 'nova-compute with libvirt'
|
2013-03-19 14:34:35 -04:00
|
|
|
end
|
|
|
|
|
2014-01-30 17:09:21 -05:00
|
|
|
context 'on Ubuntu operating systems' do
|
|
|
|
before do
|
|
|
|
facts.merge!(:operatingsystem => 'Ubuntu')
|
|
|
|
platform_params.merge!(:special_service_provider => 'upstart')
|
2013-03-19 14:34:35 -04:00
|
|
|
end
|
|
|
|
|
2014-01-30 17:09:21 -05:00
|
|
|
it_behaves_like 'nova-compute with libvirt'
|
2013-03-19 14:34:35 -04:00
|
|
|
end
|
2014-01-30 17:09:21 -05:00
|
|
|
end
|
2013-03-19 14:34:35 -04:00
|
|
|
|
2014-01-30 17:09:21 -05:00
|
|
|
context 'on RedHat platforms' do
|
|
|
|
let :facts do
|
|
|
|
{ :osfamily => 'RedHat' }
|
|
|
|
end
|
2013-03-19 14:34:35 -04:00
|
|
|
|
2014-01-30 17:09:21 -05:00
|
|
|
let :platform_params do
|
|
|
|
{ :libvirt_package_name => 'libvirt',
|
|
|
|
:libvirt_service_name => 'libvirtd',
|
|
|
|
:special_service_provider => 'init' }
|
|
|
|
end
|
2013-03-19 14:34:35 -04:00
|
|
|
|
2014-01-30 17:09:21 -05:00
|
|
|
context 'on Fedora operating systems' do
|
|
|
|
before do
|
|
|
|
facts.merge!(:operatingsystem => 'Fedora')
|
|
|
|
platform_params.merge!(:special_service_provider => nil)
|
2013-03-19 14:34:35 -04:00
|
|
|
end
|
|
|
|
|
2014-01-30 17:09:21 -05:00
|
|
|
it_behaves_like 'nova-compute with libvirt'
|
2013-03-19 14:34:35 -04:00
|
|
|
end
|
2013-04-05 10:48:35 -04:00
|
|
|
|
2014-01-30 17:09:21 -05:00
|
|
|
context 'on other operating systems' do
|
|
|
|
before do
|
|
|
|
facts.merge!(:operatingsystem => 'RedHat')
|
|
|
|
platform_params.merge!(:special_service_provider => 'init')
|
2013-04-05 10:48:35 -04:00
|
|
|
end
|
|
|
|
|
2014-01-30 17:09:21 -05:00
|
|
|
it_behaves_like 'nova-compute with libvirt'
|
2013-04-05 10:48:35 -04:00
|
|
|
|
2014-01-30 17:09:21 -05:00
|
|
|
it { should contain_service('messagebus').with(
|
2013-04-05 10:48:35 -04:00
|
|
|
:ensure => 'running',
|
2014-01-30 17:09:21 -05:00
|
|
|
:enable => true,
|
|
|
|
:before => 'Service[libvirt]',
|
|
|
|
:provider => platform_params[:special_service_provider]
|
|
|
|
) }
|
2013-04-05 10:48:35 -04:00
|
|
|
end
|
2013-03-19 14:34:35 -04:00
|
|
|
end
|
|
|
|
end
|