hypervisor: ensure RBD can't be enabled on RHEL

RHEL does not support RBD backend for VMs storage.
We need to ensure that nova will never be configured with RBD
parameters, even if has_ceph is true on Red Hat hypervisor nodes.

Also add more unit tests.
This commit is contained in:
Emilien Macchi
2014-04-23 21:24:43 +02:00
parent d894d334ec
commit d81aab1bfd
2 changed files with 62 additions and 32 deletions

View File

@@ -102,6 +102,13 @@ Host *
mode => '0644', mode => '0644',
notify => Service['libvirtd'] notify => Service['libvirtd']
} }
# Nova support for RBD backend is not supported in Red Hat packages
if $has_ceph {
warning('Red Hat does not support RBD backend for VMs.')
}
$has_ceph_real = false
} else {
$has_ceph_real = $has_ceph
} }
if $::operatingsystem == 'Ubuntu' { if $::operatingsystem == 'Ubuntu' {
@@ -118,7 +125,7 @@ Host *
class { 'nova::compute::neutron': } class { 'nova::compute::neutron': }
if $has_ceph { if $has_ceph_real {
$libvirt_disk_cachemodes_real = ['network=writeback'] $libvirt_disk_cachemodes_real = ['network=writeback']
include 'cloud::storage::rbd' include 'cloud::storage::rbd'

View File

@@ -70,10 +70,7 @@ describe 'cloud::compute::hypervisor' do
{ :libvirt_type => 'kvm', { :libvirt_type => 'kvm',
:server_proxyclient_address => '7.0.0.1', :server_proxyclient_address => '7.0.0.1',
:spice_port => '6082', :spice_port => '6082',
:has_ceph => true, :has_ceph => false,
:cinder_rbd_user => 'cinder',
:nova_rbd_pool => 'nova',
:nova_rbd_secret_uuid => 'secrete',
:nova_ssh_private_key => 'secrete', :nova_ssh_private_key => 'secrete',
:nova_ssh_public_key => 'public', :nova_ssh_public_key => 'public',
:ks_nova_public_proto => 'http', :ks_nova_public_proto => 'http',
@@ -213,15 +210,6 @@ describe 'cloud::compute::hypervisor' do
) )
end end
it 'configure libvirt driver' do
should contain_class('nova::compute::libvirt').with(
:libvirt_type => 'kvm',
:vncserver_listen => '0.0.0.0',
:migration_support => true,
:libvirt_disk_cachemodes => ['network=writeback']
)
end
it 'configure nova compute with neutron' do it 'configure nova compute with neutron' do
should contain_class('nova::compute::neutron') should contain_class('nova::compute::neutron')
end end
@@ -230,18 +218,17 @@ describe 'cloud::compute::hypervisor' do
should contain_class('ceilometer::agent::compute') should contain_class('ceilometer::agent::compute')
end end
it 'configure nova-compute to support RBD backend' do it 'should not configure nova-compute for RBD backend' do
should contain_nova_config('DEFAULT/libvirt_images_type').with('value' => 'rbd') should_not contain_nova_config('DEFAULT/rbd_user').with('value' => 'cinder')
should contain_nova_config('DEFAULT/libvirt_images_rbd_pool').with('value' => 'nova') end
should contain_nova_config('DEFAULT/libvirt_images_rbd_ceph_conf').with('value' => '/etc/ceph/ceph.conf')
should contain_nova_config('DEFAULT/rbd_user').with('value' => 'cinder') it 'configure libvirt driver without disk cachemodes' do
should contain_nova_config('DEFAULT/rbd_secret_uuid').with('value' => 'secrete') should contain_class('nova::compute::libvirt').with(
should contain_group('cephkeyring').with(:ensure => 'present') :libvirt_type => 'kvm',
should contain_exec('add-nova-to-group').with( :vncserver_listen => '0.0.0.0',
:command => 'usermod -a -G cephkeyring nova', :migration_support => true,
:unless => 'groups nova | grep cephkeyring', :libvirt_disk_cachemodes => []
:path => ['/usr/sbin', '/usr/bin', '/bin', '/sbin'] )
)
end end
it 'configure nova-compute with extra parameters' do it 'configure nova-compute with extra parameters' do
@@ -267,23 +254,59 @@ describe 'cloud::compute::hypervisor' do
end end
end end
context 'without RBD backend' do context 'with RBD backend on Debian plaforms' do
before :each do before :each do
params.merge!( :has_ceph => false ) facts.merge!( :osfamily => 'Debian' )
params.merge!(
:has_ceph => true,
:cinder_rbd_user => 'cinder',
:nova_rbd_pool => 'nova',
:nova_rbd_secret_uuid => 'secrete' )
end end
it 'should not configure nova-compute for RBD backend' do it 'configure nova-compute to support RBD backend' do
should_not contain_nova_config('DEFAULT/rbd_user').with('value' => 'cinder') should contain_nova_config('DEFAULT/libvirt_images_type').with('value' => 'rbd')
should contain_nova_config('DEFAULT/libvirt_images_rbd_pool').with('value' => 'nova')
should contain_nova_config('DEFAULT/libvirt_images_rbd_ceph_conf').with('value' => '/etc/ceph/ceph.conf')
should contain_nova_config('DEFAULT/rbd_user').with('value' => 'cinder')
should contain_nova_config('DEFAULT/rbd_secret_uuid').with('value' => 'secrete')
should contain_group('cephkeyring').with(:ensure => 'present')
should contain_exec('add-nova-to-group').with(
:command => 'usermod -a -G cephkeyring nova',
:unless => 'groups nova | grep cephkeyring'
)
end end
it 'configure libvirt driver without disk cachemodes' do
it 'configure libvirt driver' do
should contain_class('nova::compute::libvirt').with( should contain_class('nova::compute::libvirt').with(
:libvirt_type => 'kvm', :libvirt_type => 'kvm',
:vncserver_listen => '0.0.0.0', :vncserver_listen => '0.0.0.0',
:migration_support => true, :migration_support => true,
:libvirt_disk_cachemodes => [] :libvirt_disk_cachemodes => ['network=writeback']
) )
end end
end end
context 'when trying to enable RBD backend on RedHat plaforms' do
before :each do
facts.merge!( :operatingsystem => 'RedHat' )
params.merge!(
:has_ceph => true,
:cinder_rbd_user => 'cinder',
:nova_rbd_pool => 'nova',
:nova_rbd_secret_uuid => 'secrete' )
end
it 'configure libvirt driver without libvirt_disk_cachemodes' do
should contain_class('nova::compute::libvirt').with(
:libvirt_type => 'kvm',
:vncserver_listen => '0.0.0.0',
:migration_support => true,
:libvirt_disk_cachemodes => []
)
end
end
end end
context 'on Debian platforms' do context 'on Debian platforms' do