Add parameters for image copy when using multiple RBD Glance stores

Expose the Nova config options to allow an image to be automatically
copied into the local Glance store when Glance is configured to use
multiple RBD stores.

Related Nova change: Ia839ad418b0f2887cb8e8f5ee3e660a0751db9ce

Change-Id: I227f40111591cfe1026ce992b3de3e28d092f329
(cherry picked from commit 920f2fbf7e)
(cherry picked from commit 885da96c66)
This commit is contained in:
Oliver Walsh 2021-04-15 13:55:40 +01:00
parent 0700c1159c
commit 3fab23231c
3 changed files with 68 additions and 24 deletions

View File

@ -30,6 +30,23 @@
# (optional) The path to the ceph configuration file to use.
# Defaults to '/etc/ceph/ceph.conf'.
#
# [*libvirt_images_rbd_glance_store_name*]
# (optional) Name of the Glance store that represents the local rbd cluster.
# If set, this will allow Nova to request that Glance copy an image from
# an existing non-local store into the one named by this option before
# booting so that proper Copy-on-Write behavior is maintained.
# Defaults to $::os_service_default.
#
# [*libvirt_images_rbd_glance_copy_poll_interval*]
# (optional) The interval in seconds with which to poll Glance after asking
# for it to copy an image to the local rbd store.
# Defaults to $::os_service_default.
#
# [*libvirt_images_rbd_glance_copy_timeout*]
# (optional) The overall maximum time we will wait for Glance to complete
# an image copy to our local rbd store.
# Defaults to $::os_service_default.
#
# [*libvirt_rbd_user*]
# (Required) The RADOS client name for accessing rbd volumes.
#
@ -62,16 +79,20 @@
# (optional) Ensure value for ceph client package.
# Defaults to 'present'.
class nova::compute::rbd (
$libvirt_rbd_user,
$libvirt_rbd_secret_uuid = false,
$libvirt_rbd_secret_key = undef,
$libvirt_images_rbd_pool = 'rbd',
$libvirt_images_rbd_ceph_conf = '/etc/ceph/ceph.conf',
$rbd_keyring = 'client.nova',
$ephemeral_storage = true,
$manage_ceph_client = true,
$ceph_client_ensure = 'present',
$libvirt_rbd_secret_uuid = false,
$libvirt_rbd_secret_key = undef,
$libvirt_images_rbd_pool = 'rbd',
$libvirt_images_rbd_ceph_conf = '/etc/ceph/ceph.conf',
$libvirt_images_rbd_glance_store_name = $::os_service_default,
$libvirt_images_rbd_glance_copy_poll_interval = $::os_service_default,
$libvirt_images_rbd_glance_copy_timeout = $::os_service_default,
$rbd_keyring = 'client.nova',
$ephemeral_storage = true,
$manage_ceph_client = true,
$ceph_client_ensure = 'present',
) {
include nova::deps
@ -126,14 +147,21 @@ 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;
'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/images_rbd_glance_store_name': value => $libvirt_images_rbd_glance_store_name;
'libvirt/images_rbd_glance_copy_poll_interval': value => $libvirt_images_rbd_glance_copy_poll_interval;
'libvirt/images_rbd_glance_copy_timeout': value => $libvirt_images_rbd_glance_copy_timeout;
}
} else {
nova_config {
'libvirt/images_rbd_pool': ensure => absent;
'libvirt/images_rbd_ceph_conf': ensure => absent;
'libvirt/images_rbd_pool': ensure => absent;
'libvirt/images_rbd_ceph_conf': ensure => absent;
'libvirt/images_rbd_glance_store_name': ensure => absent;
'libvirt/images_rbd_glance_copy_poll_interval': ensure => absent;
'libvirt/images_rbd_glance_copy_timeout': ensure => absent;
}
}

View File

@ -0,0 +1,8 @@
---
features:
- |
Add parameters for Nova/Glance image copy when using multiple RBD Glance stores.
- ``nova::compute::rbd::libvirt_images_rbd_glance_store_name``
- ``nova::compute::rbd::libvirt_images_rbd_glance_copy_poll_interval``
- ``nova::compute::rbd::libvirt_images_rbd_glance_copy_timeout``

View File

@ -23,11 +23,7 @@ require 'spec_helper'
describe 'nova::compute::rbd' do
let :params do
{ :libvirt_rbd_user => 'nova',
:libvirt_rbd_secret_uuid => false,
:libvirt_images_rbd_pool => 'rbd',
:libvirt_images_rbd_ceph_conf => '/etc/ceph/ceph.conf',
:ephemeral_storage => true }
{ :libvirt_rbd_user => 'nova' }
end
shared_examples_for 'nova compute rbd' do
@ -39,6 +35,9 @@ describe 'nova::compute::rbd' do
is_expected.to contain_nova_config('libvirt/images_rbd_pool').with_value('rbd')
is_expected.to contain_nova_config('libvirt/images_rbd_ceph_conf').with_value('/etc/ceph/ceph.conf')
is_expected.to contain_nova_config('libvirt/rbd_user').with_value('nova')
is_expected.to contain_nova_config('libvirt/images_rbd_glance_store_name').with_value('<SERVICE DEFAULT>')
is_expected.to contain_nova_config('libvirt/images_rbd_glance_copy_poll_interval').with_value('<SERVICE DEFAULT>')
is_expected.to contain_nova_config('libvirt/images_rbd_glance_copy_timeout').with_value('<SERVICE DEFAULT>')
end
it 'installs client package' do
@ -51,10 +50,13 @@ describe 'nova::compute::rbd' do
context 'when overriding default parameters' do
before :each do
params.merge!(
:libvirt_rbd_user => 'joe',
:libvirt_rbd_secret_uuid => false,
:libvirt_images_rbd_pool => 'AnotherPool',
:libvirt_images_rbd_ceph_conf => '/tmp/ceph.conf'
:libvirt_rbd_user => 'joe',
:libvirt_rbd_secret_uuid => false,
:libvirt_images_rbd_pool => 'AnotherPool',
:libvirt_images_rbd_ceph_conf => '/tmp/ceph.conf',
:libvirt_images_rbd_glance_store_name => 'glance_rbd_store',
:libvirt_images_rbd_glance_copy_poll_interval => 30,
:libvirt_images_rbd_glance_copy_timeout => 300
)
end
@ -63,6 +65,9 @@ describe 'nova::compute::rbd' do
is_expected.to contain_nova_config('libvirt/images_rbd_pool').with_value('AnotherPool')
is_expected.to contain_nova_config('libvirt/images_rbd_ceph_conf').with_value('/tmp/ceph.conf')
is_expected.to contain_nova_config('libvirt/rbd_user').with_value('joe')
is_expected.to contain_nova_config('libvirt/images_rbd_glance_store_name').with_value('glance_rbd_store')
is_expected.to contain_nova_config('libvirt/images_rbd_glance_copy_poll_interval').with_value(30)
is_expected.to contain_nova_config('libvirt/images_rbd_glance_copy_timeout').with_value(300)
end
end
@ -123,8 +128,11 @@ describe 'nova::compute::rbd' do
end
it 'should only set user and secret_uuid in nova.conf ' do
is_expected.to_not contain_nova_config('libvirt/images_rbd_pool').with_value('rbd')
is_expected.to_not contain_nova_config('libvirt/images_rbd_ceph_conf').with_value('/etc/ceph/ceph.conf')
is_expected.to contain_nova_config('libvirt/images_rbd_pool').with_ensure('absent')
is_expected.to contain_nova_config('libvirt/images_rbd_ceph_conf').with_ensure('absent')
is_expected.to contain_nova_config('libvirt/images_rbd_glance_store_name').with_ensure('absent')
is_expected.to contain_nova_config('libvirt/images_rbd_glance_copy_poll_interval').with_ensure('absent')
is_expected.to contain_nova_config('libvirt/images_rbd_glance_copy_timeout').with_ensure('absent')
is_expected.to contain_nova_config('libvirt/rbd_user').with_value('nova')
is_expected.to contain_nova_config('libvirt/rbd_secret_uuid').with_value('UUID')
end