Add parameter to control use of rbd for the ephemeral storage

Currently the rbd class configures Nova so that it uses the
rbd driver for both the ephemeral and the persistent storage.
One might want to use it to attach Cinder volumes (persistent)
but not for the ephemeral storage instead, which be on local
disks or even backed by a different driver.

This change adds a parameter to control use of rbd driver for
the ephemeral storage, setting it to true by default to
preserve the old behavior.

Co-Authored-By: Giulio Fidente <gfidente@redhat.com>
Co-Authored-By: Emilien Macchi <emilien@redhat.com>

Change-Id: I4ae0fd605c5a57aa23bea83b06530a50844d24a0
Closes-bug: 1365554
This commit is contained in:
David Moreau Simard
2014-09-04 11:31:23 -04:00
committed by Sebastien Badia
parent 7a4e067e92
commit 2374ee3e2b
2 changed files with 58 additions and 5 deletions

View File

@@ -49,6 +49,11 @@
# (optional) The keyring name to use when retrieving the RBD secret
# Default to 'client.nova'
#
# [*ephemeral_storage*]
# (optional) Wether or not to use the rbd driver for the nova
# ephemeral storage or for the cinder volumes only.
# Defaults to true.
#
class nova::compute::rbd (
$libvirt_rbd_user,
@@ -57,15 +62,13 @@ class nova::compute::rbd (
$libvirt_images_rbd_pool = 'rbd',
$libvirt_images_rbd_ceph_conf = '/etc/ceph/ceph.conf',
$rbd_keyring = 'client.nova',
$ephemeral_storage = true,
) {
include ::nova::params
nova_config {
'libvirt/images_type': value => 'rbd';
'libvirt/images_rbd_pool': value => $libvirt_images_rbd_pool;
'libvirt/images_rbd_ceph_conf': value => $libvirt_images_rbd_ceph_conf;
'libvirt/rbd_user': value => $libvirt_rbd_user;
'libvirt/rbd_user': value => $libvirt_rbd_user;
}
if $libvirt_rbd_secret_uuid {
@@ -97,4 +100,17 @@ class nova::compute::rbd (
}
if $ephemeral_storage {
nova_config {
'libvirt/images_type': value => 'rbd';
'libvirt/images_rbd_pool': value => $libvirt_images_rbd_pool;
'libvirt/images_rbd_ceph_conf': value => $libvirt_images_rbd_ceph_conf;
}
} else {
nova_config {
'libvirt/images_rbd_pool': ensure => absent;
'libvirt/images_rbd_ceph_conf': ensure => absent;
}
}
}

View File

@@ -26,7 +26,8 @@ describe 'nova::compute::rbd' do
{ :libvirt_rbd_user => 'nova',
:libvirt_rbd_secret_uuid => false,
:libvirt_images_rbd_pool => 'rbd',
:libvirt_images_rbd_ceph_conf => '/etc/ceph/ceph.conf' }
:libvirt_images_rbd_ceph_conf => '/etc/ceph/ceph.conf',
:ephemeral_storage => true }
end
shared_examples_for 'nova compute rbd' do
@@ -105,6 +106,42 @@ describe 'nova::compute::rbd' do
end
end
context 'when using cephx but disabling ephemeral storage' do
before :each do
params.merge!(
:libvirt_rbd_secret_uuid => 'UUID',
:rbd_keyring => 'client.rbd_test',
:ephemeral_storage => false
)
end
it 'should only set user and secret_uuid in nova.conf ' do
should_not contain_nova_config('libvirt/images_rbd_pool').with_value('rbd')
should_not contain_nova_config('libvirt/images_rbd_ceph_conf').with_value('/etc/ceph/ceph.conf')
should contain_nova_config('libvirt/rbd_user').with_value('nova')
should contain_nova_config('libvirt/rbd_secret_uuid').with_value('UUID')
end
it 'configure ceph on compute nodes' do
verify_contents(catalogue, '/etc/nova/secret.xml', [
"<secret ephemeral=\'no\' private=\'no\'>",
" <usage type=\'ceph\'>",
" <name>client.rbd_test secret</name>",
" </usage>",
" <uuid>UUID</uuid>",
"</secret>"
])
is_expected.to contain_exec('get-or-set virsh secret').with(
:command => '/usr/bin/virsh secret-define --file /etc/nova/secret.xml | /usr/bin/awk \'{print $2}\' | sed \'/^$/d\' > /etc/nova/virsh.secret',
:creates => '/etc/nova/virsh.secret',
:require => 'File[/etc/nova/secret.xml]'
)
is_expected.to contain_exec('set-secret-value virsh').with(
:command => "/usr/bin/virsh secret-set-value --secret UUID --base64 $(ceph auth get-key client.rbd_test)"
)
end
end
end
context 'on Debian platforms' do