compute: allow more granularity on hypervisor nodes

- Allow to enable / disable RBD storage for:
  * Instances & Volumes
  * Volumes only (instances will be stored locally then)
- Deprecate has_ceph param with backward compatibility
- If RBD backend for instances is enabled on Red Hat, fail with a
  message.

Closes-bug #486
Signed-off-by: Emilien Macchi <emilien.macchi@enovance.com>
This commit is contained in:
Emilien Macchi 2014-06-03 15:42:44 +02:00
parent 7d8333c937
commit 7cb25b3729
2 changed files with 121 additions and 25 deletions

View File

@ -19,10 +19,14 @@
#
# === Parameters:
#
# [*has_ceph]
# (optional) Enable or not ceph capabilities on compute node.
# If Ceph is used as a backend for Cinder or Nova, this option should be
# set to True.
# [*vm_rbd]
# (optional) Enable or not ceph capabilities on compute node to store
# nova instances on ceph storage.
# Default to false.
#
# [*volume_rbd]
# (optional) Enable or not ceph capabilities on compute node to attach
# cinder volumes backend by ceph on nova instances.
# Default to false.
#
@ -37,6 +41,9 @@ class cloud::compute::hypervisor(
$cinder_rbd_user = 'cinder',
$nova_rbd_pool = 'vms',
$nova_rbd_secret_uuid = undef,
$vm_rbd = false,
$volume_rbd = false,
# DEPRECATED
$has_ceph = false
) {
@ -44,6 +51,17 @@ class cloud::compute::hypervisor(
include 'cloud::telemetry'
include 'cloud::network'
# Backward compatibility
# if has_ceph was enabled, we consider deployments run Ceph for Nova & Cinder
if $has_ceph {
warning('has_ceph parameter is deprecated. Please use vm_rbd and volume_rbd parameters.')
$vm_rbd_real = true
$volume_rbd_real = true
} else {
$vm_rbd_real = $vm_rbd
$volume_rbd_real = $volume_rbd
}
file{ '/var/lib/nova/.ssh':
ensure => directory,
mode => '0700',
@ -103,12 +121,9 @@ Host *
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.')
if $has_ceph or $vm_rbd {
fail('Red Hat does not support RBD backend for VMs.')
}
$has_ceph_real = false
} else {
$has_ceph_real = $has_ceph
}
if $::operatingsystem == 'Ubuntu' {
@ -125,14 +140,23 @@ Host *
class { 'nova::compute::neutron': }
if $has_ceph_real {
if $vm_rbd_real or $volume_rbd_real {
$libvirt_disk_cachemodes_real = ['network=writeback']
include 'cloud::storage::rbd'
class { 'nova::compute::rbd':
libvirt_rbd_user => $cinder_rbd_user,
libvirt_images_rbd_pool => $nova_rbd_pool
$libvirt_disk_cachemodes_real = ['network=writeback']
# when nova uses ceph for instances storage
if $vm_rbd_real {
class { 'nova::compute::rbd':
libvirt_rbd_user => $cinder_rbd_user,
libvirt_images_rbd_pool => $nova_rbd_pool
}
} else {
# when nova only needs to attach ceph volumes to instances
nova_config {
'libvirt/rbd_user': value => $cinder_rbd_user;
}
}
# we don't want puppet-nova manages keyring
nova_config {

View File

@ -74,6 +74,8 @@ describe 'cloud::compute::hypervisor' do
:nova_ssh_private_key => 'secrete',
:nova_ssh_public_key => 'public',
:ks_nova_public_proto => 'http',
:vm_rbd => false,
:volume_rbd => false,
:ks_nova_public_host => '10.0.0.1' }
end
@ -221,6 +223,7 @@ describe 'cloud::compute::hypervisor' do
it 'should not configure nova-compute for RBD backend' do
should_not contain_nova_config('libvirt/rbd_user').with('value' => 'cinder')
should_not contain_nova_config('libvirt/images_type').with('value' => 'rbd')
end
it 'configure libvirt driver without disk cachemodes' do
@ -255,7 +258,73 @@ describe 'cloud::compute::hypervisor' do
end
end
context 'with RBD backend on Debian plaforms' do
context 'with RBD backend for instances and volumes on Debian plaforms' do
before :each do
facts.merge!( :osfamily => 'Debian' )
params.merge!(
:vm_rbd => true,
:volume_rbd => true,
:cinder_rbd_user => 'cinder',
:nova_rbd_pool => 'nova',
:nova_rbd_secret_uuid => 'secrete' )
end
it 'configure nova-compute to support RBD backend' do
should contain_nova_config('libvirt/images_type').with('value' => 'rbd')
should contain_nova_config('libvirt/images_rbd_pool').with('value' => 'nova')
should contain_nova_config('libvirt/images_rbd_ceph_conf').with('value' => '/etc/ceph/ceph.conf')
should contain_nova_config('libvirt/rbd_user').with('value' => 'cinder')
should contain_nova_config('libvirt/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
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
end
context 'with RBD support only for volumes on Debian plaforms' do
before :each do
facts.merge!( :osfamily => 'Debian' )
params.merge!(
:vm_rbd => false,
:volume_rbd => true,
:cinder_rbd_user => 'cinder',
:nova_rbd_secret_uuid => 'secrete' )
end
it 'configure nova-compute to support RBD backend' do
should_not contain_nova_config('libvirt/images_type').with('value' => 'rbd')
should_not contain_nova_config('libvirt/images_rbd_pool').with('value' => 'nova')
should contain_nova_config('libvirt/rbd_user').with('value' => 'cinder')
should contain_nova_config('libvirt/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
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
end
context 'with RBD backend on Debian plaforms using deprecated parameter' do
before :each do
facts.merge!( :osfamily => 'Debian' )
params.merge!(
@ -289,6 +358,18 @@ describe 'cloud::compute::hypervisor' do
end
context 'when trying to enable RBD backend on RedHat plaforms' do
before :each do
facts.merge!( :operatingsystem => 'RedHat' )
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./
end
context 'when trying to enable RBD backend with deprecated parameter on RedHat plaforms' do
before :each do
facts.merge!( :operatingsystem => 'RedHat' )
params.merge!(
@ -297,17 +378,8 @@ describe 'cloud::compute::hypervisor' do
: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
it_raises 'a Puppet::Error', /Red Hat does not support RBD backend for VMs./
end
end
context 'on Debian platforms' do