nova/rbd: use operatingsystemmajrelease fact & fix tests

* Fix the condition with () and use operatingsystemmajrelease to match
  the correct fact.
* Update unit tests to cover more situations of deployments.
This commit is contained in:
Emilien Macchi 2014-10-21 08:57:08 -04:00
parent 3c019d7cfc
commit a4fa7d0cec
2 changed files with 22 additions and 21 deletions

View File

@ -217,9 +217,9 @@ Host *
mode => '0644',
notify => Service['libvirtd']
}
# Nova support for RBD backend is not supported in Red Hat 6.x packages
if $has_ceph or $vm_rbd and $::operatingsystemrelease < 7 {
fail('Red Hat does not support RBD backend for VMs.')
# Nova support for RBD backend is not supported before RHEL 7 (OSP5).
if ($has_ceph or $vm_rbd) and ($::operatingsystemmajrelease < 7) {
fail("RBD image backend in Nova is not supported in RHEL ${::operatingsystemmajrelease}.")
}
}

View File

@ -340,10 +340,9 @@ describe 'cloud::compute::hypervisor' do
end
end
context 'with RBD backend for instances and volumes on Debian plaforms' do
context 'with RBD backend for instances and volumes' do
before :each do
facts.merge!( :osfamily => 'Debian',
:vtx => true )
facts.merge!( :vtx => true )
params.merge!(
:vm_rbd => true,
:volume_rbd => true,
@ -375,10 +374,9 @@ describe 'cloud::compute::hypervisor' do
end
end
context 'with RBD support only for volumes on Debian plaforms' do
context 'with RBD support only for volumes' do
before :each do
facts.merge!( :osfamily => 'Debian',
:vtx => true )
facts.merge!( :vtx => true )
params.merge!(
:vm_rbd => false,
:volume_rbd => true,
@ -408,10 +406,9 @@ describe 'cloud::compute::hypervisor' do
end
end
context 'with RBD backend on Debian plaforms using deprecated parameter' do
context 'with RBD backend plaforms using deprecated parameter' do
before :each do
facts.merge!( :osfamily => 'Debian',
:vtx => true )
facts.merge!( :vtx => true )
params.merge!(
:has_ceph => true,
:cinder_rbd_user => 'cinder',
@ -442,16 +439,17 @@ describe 'cloud::compute::hypervisor' do
end
end
context 'when trying to enable RBD backend on RedHat plaforms' do
context 'when trying to enable RBD backend on RedHat OSP < 7 plaforms' do
before :each do
facts.merge!( :osfamily => 'RedHat' )
facts.merge!( :osfamily => 'RedHat',
:operatingsystemmajrelease => '6' )
params.merge!(
:vm_rbd => true,
:cinder_rbd_user => 'cinder',
:nova_rbd_pool => 'nova',
:nova_rbd_secret_uuid => 'secrete' )
end
it_raises 'a Puppet::Error', /Red Hat does not support RBD backend for VMs./
it_raises 'a Puppet::Error', /RBD image backend in Nova is not supported in RHEL 6./
end
context 'when running KVM libvirt driver without VTX enabled' do
@ -463,14 +461,15 @@ describe 'cloud::compute::hypervisor' do
context 'when trying to enable RBD backend with deprecated parameter on RedHat plaforms' do
before :each do
facts.merge!( :osfamily => 'RedHat' )
facts.merge!( :osfamily => 'RedHat',
:operatingsystemmajrelease => '6' )
params.merge!(
:has_ceph => true,
:cinder_rbd_user => 'cinder',
:nova_rbd_pool => 'nova',
:nova_rbd_secret_uuid => 'secrete' )
end
it_raises 'a Puppet::Error', /Red Hat does not support RBD backend for VMs./
it_raises 'a Puppet::Error', /RBD image backend in Nova is not supported in RHEL 6./
end
context 'when configuring spice with backward compatibility' do
@ -545,11 +544,13 @@ describe 'cloud::compute::hypervisor' do
context 'on RedHat platforms' do
let :facts do
{ :osfamily => 'RedHat',
:vtx => true,
:concat_basedir => '/var/lib/puppet/concat',
{ :osfamily => 'RedHat',
:vtx => true,
:concat_basedir => '/var/lib/puppet/concat',
# required for rbd support check
:operatingsystemmajrelease => '7',
# required for nfs module
:lsbmajdistrelease => '7'
:lsbmajdistrelease => '7'
}
end