Add support for image download via rbd

This change introduces some new parameters to the nova::glance class,
which are required for the new feature to download glance image via
RBD instead of API[1].

[1] https://review.opendev.org/c/openstack/nova/+/574301

Conflicts:
  manifests/glance.pp
  spec/classes/nova_glance_spec.rb

Change-Id: I0c9ebc5fd980204c59cc903372820e1ee1245630
(cherry picked from commit 896bf1ff5e)
This commit is contained in:
Takashi Kajinami 2021-01-14 09:48:36 +09:00 committed by Martin Schuppert
parent ba47f9844f
commit c089c85b0c
3 changed files with 105 additions and 0 deletions

47
manifests/glance.pp Normal file
View File

@ -0,0 +1,47 @@
# == Class: nova::glance
#
# Configure usage of the glance service in nova
#
# === Parameters
#
# [*enable_rbd_download*]
# (optional) Enable download of Glance images directly via RBD
# Defaults to $::os_service_default
#
# [*rbd_user*]
# (optional) The RADOS client name for accessing Glance images stored as
# rbd volumes.
# Defaults to $::os_service_default
#
# [*rbd_connect_timeout*]
# (optional) THe RADOS client timeout in seconds when initially connecting
# to the cluster.
# Defaults to $::os_service_default
#
# [*rbd_pool*]
# (optional) The RADOS pool in which the Glance images are stored as rbd
# volumes.
# Defaults to $::os_service_default
#
# [*rbd_ceph_conf*]
# (optional) Path to the ceph configuration file to use.
# Defaults to $::os_service_default
#
class nova::glance (
$enable_rbd_download = $::os_service_default,
$rbd_user = $::os_service_default,
$rbd_connect_timeout = $::os_service_default,
$rbd_pool = $::os_service_default,
$rbd_ceph_conf = $::os_service_default,
) {
include nova::deps
nova_config {
'glance/enable_rbd_download': value => $enable_rbd_download;
'glance/rbd_user': value => $rbd_user;
'glance/rbd_connect_timeout': value => $rbd_connect_timeout;
'glance/rbd_pool': value => $rbd_pool;
'glance/rbd_ceph_conf': value => $rbd_ceph_conf;
}
}

View File

@ -0,0 +1,5 @@
---
features:
- |
Now puppet-nova supports configurations required to download Glance images
into the libvirt image cache via RBD.

View File

@ -0,0 +1,53 @@
require 'spec_helper'
describe 'nova::glance' do
shared_examples_for 'nova::glance' do
context 'with default params' do
let :params do
{}
end
it 'configure default params' do
is_expected.to contain_nova_config('glance/enable_rbd_download').with_value('<SERVICE DEFAULT>')
is_expected.to contain_nova_config('glance/rbd_user').with_value('<SERVICE DEFAULT>')
is_expected.to contain_nova_config('glance/rbd_connect_timeout').with_value('<SERVICE DEFAULT>')
is_expected.to contain_nova_config('glance/rbd_pool').with_value('<SERVICE DEFAULT>')
is_expected.to contain_nova_config('glance/rbd_ceph_conf').with_value('<SERVICE DEFAULT>')
end
end
context 'with specific parameters' do
let :params do
{
:enable_rbd_download => true,
:rbd_user => 'nova',
:rbd_connect_timeout => 5,
:rbd_pool => 'images',
:rbd_ceph_conf => '/etc/ceph/ceph.conf',
}
end
it 'configure glance params' do
is_expected.to contain_nova_config('glance/enable_rbd_download').with_value(true)
is_expected.to contain_nova_config('glance/rbd_user').with_value('nova')
is_expected.to contain_nova_config('glance/rbd_connect_timeout').with_value(5)
is_expected.to contain_nova_config('glance/rbd_pool').with_value('images')
is_expected.to contain_nova_config('glance/rbd_ceph_conf').with_value('/etc/ceph/ceph.conf')
end
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'nova::glance'
end
end
end