From c089c85b0c9a6689a7f40485a51e586142015b7f Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Thu, 14 Jan 2021 09:48:36 +0900 Subject: [PATCH] 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 896bf1ff5e17543197d6fb759bf293879481c909) --- manifests/glance.pp | 47 ++++++++++++++++ ...age-download-via-rbd-159f6ccd7fada555.yaml | 5 ++ spec/classes/nova_glance_spec.rb | 53 +++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 manifests/glance.pp create mode 100644 releasenotes/notes/image-download-via-rbd-159f6ccd7fada555.yaml create mode 100644 spec/classes/nova_glance_spec.rb diff --git a/manifests/glance.pp b/manifests/glance.pp new file mode 100644 index 000000000..4599b1e33 --- /dev/null +++ b/manifests/glance.pp @@ -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; + } +} diff --git a/releasenotes/notes/image-download-via-rbd-159f6ccd7fada555.yaml b/releasenotes/notes/image-download-via-rbd-159f6ccd7fada555.yaml new file mode 100644 index 000000000..799870f1a --- /dev/null +++ b/releasenotes/notes/image-download-via-rbd-159f6ccd7fada555.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Now puppet-nova supports configurations required to download Glance images + into the libvirt image cache via RBD. diff --git a/spec/classes/nova_glance_spec.rb b/spec/classes/nova_glance_spec.rb new file mode 100644 index 000000000..b8713e07f --- /dev/null +++ b/spec/classes/nova_glance_spec.rb @@ -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('') + is_expected.to contain_nova_config('glance/rbd_user').with_value('') + is_expected.to contain_nova_config('glance/rbd_connect_timeout').with_value('') + is_expected.to contain_nova_config('glance/rbd_pool').with_value('') + is_expected.to contain_nova_config('glance/rbd_ceph_conf').with_value('') + 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