Add support for [backend_defaults] options

The latest release of glance_store introduced the mechanism to define
default values used for all backends, by using the [backend_defaults]
options. Add support for these options so that users can leverage
this new feature to simplify config management.

Depends-on: https://review.opendev.org/946512
Change-Id: I6a8e5470e212db1cb30eca72e59265aa0e848ea4
Signed-off-by: Takashi Kajinami <kajinamit@oss.nttdata.com>
This commit is contained in:
Takashi Kajinami
2025-07-11 14:32:57 +09:00
parent a93781c2d3
commit 17823ff226
11 changed files with 592 additions and 5 deletions

View File

@@ -0,0 +1,52 @@
# == Class: glance::backend::defaults::file
#
# Configure common defaults for all file backends
#
# === Parameters:
#
# [*filesystem_store_datadir*]
# (optional) Directory where dist images are stored.
# Defaults to $facts['os_service_default'].
#
# [*filesystem_store_metadata_file*]
# (optional) Filesystem store metadata file.
# Defaults to $facts['os_service_default'].
#
# [*filesystem_store_file_perm*]
# (optional) File access permissions for the image files.
# Defaults to $facts['os_service_default'].
#
# [*filesystem_store_chunk_size*]
# (optional) Chunk size, in bytes.
# Defaults to $facts['os_service_default'].
#
# [*filesystem_thin_provisioning*]
# (optional) Boolean describing if thin provisioning is enabled or not
# Defaults to $facts['os_service_default']
#
class glance::backend::defaults::file(
$filesystem_store_datadir = $facts['os_service_default'],
$filesystem_store_metadata_file = $facts['os_service_default'],
$filesystem_store_file_perm = $facts['os_service_default'],
$filesystem_store_chunk_size = $facts['os_service_default'],
$filesystem_thin_provisioning = $facts['os_service_default'],
) {
include glance::deps
glance_api_config {
'backend_defaults/filesystem_store_datadir': value => $filesystem_store_datadir;
'backend_defaults/filesystem_store_metadata_file': value => $filesystem_store_metadata_file;
'backend_defaults/filesystem_store_file_perm': value => $filesystem_store_file_perm;
'backend_defaults/filesystem_store_chunk_size': value => $filesystem_store_chunk_size;
'backend_defaults/filesystem_thin_provisioning': value => $filesystem_thin_provisioning;
}
glance_cache_config {
'backend_defaults/filesystem_store_datadir': value => $filesystem_store_datadir;
'backend_defaults/filesystem_store_metadata_file': value => $filesystem_store_metadata_file;
'backend_defaults/filesystem_store_file_perm': value => $filesystem_store_file_perm;
'backend_defaults/filesystem_store_chunk_size': value => $filesystem_store_chunk_size;
'backend_defaults/filesystem_thin_provisioning': value => $filesystem_thin_provisioning;
}
}

View File

@@ -0,0 +1,55 @@
# == Class: glance::backend::defaults::rbd
#
# Configure common defaults for all rbd backends
#
# === Parameters:
#
# [*rbd_store_user*]
# Optional. Default: $facts['os_service_default'].
#
# [*rbd_store_pool*]
# Optional. Default: $facts['os_service_default'].
#
# [*rbd_store_ceph_conf*]
# Optional. Default: $facts['os_service_default'].
#
# [*rbd_store_chunk_size*]
# Optional. Default: $facts['os_service_default'].
#
# [*rbd_thin_provisioning*]
# Optional. Boolean describing if thin provisioning is enabled or not
# Defaults to $facts['os_service_default']
#
# [*rados_connect_timeout*]
# Optional. Timeout value (in seconds) used when connecting to ceph cluster.
# Default: $facts['os_service_default'].
#
class glance::backend::defaults::rbd(
$rbd_store_user = $facts['os_service_default'],
$rbd_store_ceph_conf = $facts['os_service_default'],
$rbd_store_pool = $facts['os_service_default'],
$rbd_store_chunk_size = $facts['os_service_default'],
$rbd_thin_provisioning = $facts['os_service_default'],
$rados_connect_timeout = $facts['os_service_default'],
) {
include glance::deps
glance_api_config {
'backend_defaults/rbd_store_user': value => $rbd_store_user;
'backend_defaults/rbd_store_ceph_conf': value => $rbd_store_ceph_conf;
'backend_defaults/rbd_store_pool': value => $rbd_store_pool;
'backend_defaults/rbd_store_chunk_size': value => $rbd_store_chunk_size;
'backend_defaults/rbd_thin_provisioning': value => $rbd_thin_provisioning;
'backend_defaults/rados_connect_timeout': value => $rados_connect_timeout;
}
glance_cache_config {
'backend_defaults/rbd_store_user': value => $rbd_store_user;
'backend_defaults/rbd_store_ceph_conf': value => $rbd_store_ceph_conf;
'backend_defaults/rbd_store_pool': value => $rbd_store_pool;
'backend_defaults/rbd_store_chunk_size': value => $rbd_store_chunk_size;
'backend_defaults/rbd_thin_provisioning': value => $rbd_thin_provisioning;
'backend_defaults/rados_connect_timeout': value => $rados_connect_timeout;
}
}

View File

@@ -0,0 +1,82 @@
# == Class: glance::backend::defaults::s3
#
# Configure common defaults for all rbd backends
#
# === Parameters:
#
# [*s3_store_host*]
# (required) The host where the S3 server is listening.
# Defaults to $facts['os_service_default'].
#
# [*s3_store_access_key*]
# (required) The S3 query token access key.
# Defaults to $facts['os_service_default'].
#
# [*s3_store_secret_key*]
# (required) The S3 query token secret key.
# Defaults to $facts['os_service_default'].
#
# [*s3_store_bucket*]
# (required) The S3 bucket to be used to store the Glance data.
# Defaults to $facts['os_service_default'].
#
# [*s3_store_create_bucket_on_put*]
# (optional) Determine whether S3 should create a new bucket.
# Defaults to $facts['os_service_default'].
#
# [*s3_store_bucket_url_format*]
# (optional) The S3 calling format used to determine the object.
# Defaults to $facts['os_service_default'].
#
# [*s3_store_large_object_size*]
# (optional) What size, in MB, should S3 start chunking image files and do
# a multipart upload in S3.
# Defaults to $facts['os_service_default'].
#
# [*s3_store_large_object_chunk_size*]
# (optional) What multipart upload part size, in MB, should S3 use when
# uploading parts.
# Defaults to $facts['os_service_default'].
#
# [*s3_store_thread_pools*]
# (optional) The number of thread pools to perform a multipart upload in S3.
# Defaults to $facts['os_service_default'].
#
class glance::backend::defaults::s3(
$s3_store_host = $facts['os_service_default'],
$s3_store_access_key = $facts['os_service_default'],
$s3_store_secret_key = $facts['os_service_default'],
$s3_store_bucket = $facts['os_service_default'],
$s3_store_create_bucket_on_put = $facts['os_service_default'],
$s3_store_bucket_url_format = $facts['os_service_default'],
$s3_store_large_object_size = $facts['os_service_default'],
$s3_store_large_object_chunk_size = $facts['os_service_default'],
$s3_store_thread_pools = $facts['os_service_default'],
) {
include glance::deps
glance_api_config {
'backend_defaults/s3_store_host': value => $s3_store_host;
'backend_defaults/s3_store_access_key': value => $s3_store_access_key, secret => true;
'backend_defaults/s3_store_secret_key': value => $s3_store_secret_key, secret => true;
'backend_defaults/s3_store_bucket': value => $s3_store_bucket;
'backend_defaults/s3_store_create_bucket_on_put': value => $s3_store_create_bucket_on_put;
'backend_defaults/s3_store_bucket_url_format': value => $s3_store_bucket_url_format;
'backend_defaults/s3_store_large_object_size': value => $s3_store_large_object_size;
'backend_defaults/s3_store_large_object_chunk_size': value => $s3_store_large_object_chunk_size;
'backend_defaults/s3_store_thread_pools': value => $s3_store_thread_pools;
}
glance_cache_config {
'backend_defaults/s3_store_host': value => $s3_store_host;
'backend_defaults/s3_store_access_key': value => $s3_store_access_key, secret => true;
'backend_defaults/s3_store_secret_key': value => $s3_store_secret_key, secret => true;
'backend_defaults/s3_store_bucket': value => $s3_store_bucket;
'backend_defaults/s3_store_create_bucket_on_put': value => $s3_store_create_bucket_on_put;
'backend_defaults/s3_store_bucket_url_format': value => $s3_store_bucket_url_format;
'backend_defaults/s3_store_large_object_size': value => $s3_store_large_object_size;
'backend_defaults/s3_store_large_object_chunk_size': value => $s3_store_large_object_chunk_size;
'backend_defaults/s3_store_thread_pools': value => $s3_store_thread_pools;
}
}

View File

@@ -0,0 +1,92 @@
# == Class: glance::backend::defaults::swift
#
# Configure common defaults for all rbd backends
#
# === Parameters:
#
# [*swift_store_container*]
# (Optional) Name of single container to store images/name prefix for
# multiple containers.
# Defaults to $facts['os_service_default'].
#
# [*swift_store_large_object_size*]
# (Optional) The size threshold, in MB, after which Glance will start
# segmenting image data.
# Defaults to $facts['os_service_default'].
#
# [*swift_store_large_object_chunk_size*]
# (Optional) The maximum size, in MB, of the segments when image data is
# segmented.
# Defaults to $facts['os_service_default'].
#
# [*swift_store_create_container_on_put*]
# (Optional) Create container, if it doesn't already exist, when uploading
# image.
# Defaults to $facts['os_service_default'].
#
# [*swift_store_endpoint_type*]
# (Optional) Endpoint type of Swift service.
# Defaults to $facts['os_service_default'].
#
# [*swift_store_service_type*]
# (Optional) Type of the swift service to use.
# Defaults to $facts['os_service_default'].
#
# [*swift_store_region*]
# (Optional) The region of Swift endpoint to use by Glance.
# Defaults to $facts['os_service_default'].
#
# [*swift_buffer_on_upload*]
# (Optional) Buffer image segments before upload to Swift.
# Defaults to $facts['os_service_default'].
#
# [*swift_upload_buffer_dir*]
# (Optional) Directory to buffer image segments before upload to Swift.
# Defaults to $facts['os_service_default'].
#
# [*swift_store_retry_get_count*]
# (Optional) The number of times a Swift download will be retried before
# the request fails.
# Defaults to $facts['os_service_default'].
#
class glance::backend::defaults::swift(
$swift_store_container = $facts['os_service_default'],
$swift_store_large_object_size = $facts['os_service_default'],
$swift_store_large_object_chunk_size = $facts['os_service_default'],
$swift_store_create_container_on_put = $facts['os_service_default'],
$swift_store_endpoint_type = $facts['os_service_default'],
$swift_store_service_type = $facts['os_service_default'],
$swift_store_region = $facts['os_service_default'],
$swift_buffer_on_upload = $facts['os_service_default'],
$swift_upload_buffer_dir = $facts['os_service_default'],
$swift_store_retry_get_count = $facts['os_service_default'],
) {
include glance::deps
include swift::client
glance_api_config {
'backend_defaults/swift_store_region': value => $swift_store_region;
'backend_defaults/swift_store_container': value => $swift_store_container;
'backend_defaults/swift_store_create_container_on_put': value => $swift_store_create_container_on_put;
'backend_defaults/swift_store_large_object_size': value => $swift_store_large_object_size;
'backend_defaults/swift_store_large_object_chunk_size': value => $swift_store_large_object_chunk_size;
'backend_defaults/swift_store_endpoint_type': value => $swift_store_endpoint_type;
'backend_defaults/swift_store_service_type': value => $swift_store_service_type;
'backend_defaults/swift_buffer_on_upload': value => $swift_buffer_on_upload;
'backend_defaults/swift_upload_buffer_dir': value => $swift_upload_buffer_dir;
'backend_defaults/swift_store_retry_get_count': value => $swift_store_retry_get_count;
}
glance_cache_config {
'backend_defaults/swift_store_region': value => $swift_store_region;
'backend_defaults/swift_store_container': value => $swift_store_container;
'backend_defaults/swift_store_create_container_on_put': value => $swift_store_create_container_on_put;
'backend_defaults/swift_store_large_object_size': value => $swift_store_large_object_size;
'backend_defaults/swift_store_large_object_chunk_size': value => $swift_store_large_object_chunk_size;
'backend_defaults/swift_store_endpoint_type': value => $swift_store_endpoint_type;
'backend_defaults/swift_store_service_type': value => $swift_store_service_type;
'backend_defaults/swift_buffer_on_upload': value => $swift_buffer_on_upload;
'backend_defaults/swift_upload_buffer_dir': value => $swift_upload_buffer_dir;
'backend_defaults/swift_store_retry_get_count': value => $swift_store_retry_get_count;
}
}

View File

@@ -15,8 +15,7 @@
#
# == Define: glance::backend::multistore::rbd
#
# configures the storage backend for glance
# as a rbd instance
# configures the storage backend for glance as a rbd instance
#
# === Parameters:
#

View File

@@ -13,10 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
#
# == Define: glance::backend::swift
# == Define: glance::backend::multistore::swift
#
# configures the storage backend for glance
# as a swift instance
# configures the storage backend for glance as a swift instance
#
# === Parameters:
#

View File

@@ -0,0 +1,5 @@
---
features:
- |
Added support for managing options in the new ``[backend_defaults]``
section.

View File

@@ -0,0 +1,72 @@
require 'spec_helper'
describe 'glance::backend::defaults::file' do
shared_examples_for 'glance::backend::defaults::file' do
it 'configures glance-api.conf' do
is_expected.to contain_glance_api_config('backend_defaults/filesystem_store_datadir').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('backend_defaults/filesystem_store_metadata_file').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('backend_defaults/filesystem_store_file_perm').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('backend_defaults/filesystem_store_chunk_size').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('backend_defaults/filesystem_thin_provisioning').with_value('<SERVICE DEFAULT>')
end
it 'configures glance-cache.conf' do
is_expected.to contain_glance_cache_config('backend_defaults/filesystem_store_datadir').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_cache_config('backend_defaults/filesystem_store_metadata_file').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_cache_config('backend_defaults/filesystem_store_file_perm').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_cache_config('backend_defaults/filesystem_store_chunk_size').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_cache_config('backend_defaults/filesystem_thin_provisioning').with_value('<SERVICE DEFAULT>')
end
describe 'when overriding datadir' do
let :params do
{
:filesystem_store_datadir => '/var/lib/glance/images',
:filesystem_store_metadata_file => '/var/lib/glance/metadata.json',
:filesystem_store_file_perm => 0,
:filesystem_store_chunk_size => 65536,
:filesystem_thin_provisioning => true,
}
end
it 'configures glance-api.conf' do
is_expected.to contain_glance_api_config('backend_defaults/filesystem_store_datadir')\
.with_value('/var/lib/glance/images')
is_expected.to contain_glance_api_config('backend_defaults/filesystem_store_metadata_file')\
.with_value('/var/lib/glance/metadata.json')
is_expected.to contain_glance_api_config('backend_defaults/filesystem_store_file_perm')\
.with_value(0)
is_expected.to contain_glance_api_config('backend_defaults/filesystem_store_chunk_size')\
.with_value(65536)
is_expected.to contain_glance_api_config('backend_defaults/filesystem_thin_provisioning')\
.with_value(true)
end
it 'configures glance-cache.conf' do
is_expected.to contain_glance_cache_config('backend_defaults/filesystem_store_datadir')\
.with_value('/var/lib/glance/images')
is_expected.to contain_glance_cache_config('backend_defaults/filesystem_store_metadata_file')\
.with_value('/var/lib/glance/metadata.json')
is_expected.to contain_glance_cache_config('backend_defaults/filesystem_store_file_perm')\
.with_value(0)
is_expected.to contain_glance_cache_config('backend_defaults/filesystem_store_chunk_size')\
.with_value(65536)
is_expected.to contain_glance_cache_config('backend_defaults/filesystem_thin_provisioning')\
.with_value(true)
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 'glance::backend::defaults::file'
end
end
end

View File

@@ -0,0 +1,60 @@
require 'spec_helper'
describe 'glance::backend::defaults::rbd' do
shared_examples 'glance::backend::defaults::rbd' do
context 'with default params' do
it 'configures glance-api.conf' do
should contain_glance_api_config('backend_defaults/rbd_store_user').with_value('<SERVICE DEFAULT>')
should contain_glance_api_config('backend_defaults/rbd_store_pool').with_value('<SERVICE DEFAULT>')
should contain_glance_api_config('backend_defaults/rbd_store_ceph_conf').with_value('<SERVICE DEFAULT>')
should contain_glance_api_config('backend_defaults/rbd_store_chunk_size').with_value('<SERVICE DEFAULT>')
should contain_glance_api_config('backend_defaults/rbd_thin_provisioning').with_value('<SERVICE DEFAULT>')
should contain_glance_api_config('backend_defaults/rados_connect_timeout').with_value('<SERVICE DEFAULT>')
end
it 'configures glance-cache.conf' do
should contain_glance_cache_config('backend_defaults/rbd_store_user').with_value('<SERVICE DEFAULT>')
should contain_glance_cache_config('backend_defaults/rbd_store_pool').with_value('<SERVICE DEFAULT>')
should contain_glance_cache_config('backend_defaults/rbd_store_ceph_conf').with_value('<SERVICE DEFAULT>')
should contain_glance_cache_config('backend_defaults/rbd_store_chunk_size').with_value('<SERVICE DEFAULT>')
should contain_glance_cache_config('backend_defaults/rbd_thin_provisioning').with_value('<SERVICE DEFAULT>')
should contain_glance_cache_config('backend_defaults/rados_connect_timeout').with_value('<SERVICE DEFAULT>')
end
end
context 'when passing params' do
let :params do
{
:rbd_store_user => 'user',
:rbd_store_chunk_size => '2',
:rbd_thin_provisioning => 'true',
:rados_connect_timeout => '30',
}
end
it 'configures glance-api.conf' do
should contain_glance_api_config('backend_defaults/rbd_store_user').with_value('user')
should contain_glance_api_config('backend_defaults/rbd_store_chunk_size').with_value('2')
should contain_glance_api_config('backend_defaults/rbd_thin_provisioning').with_value('true')
should contain_glance_api_config('backend_defaults/rados_connect_timeout').with_value('30')
end
it 'configures glance-cache.conf' do
should contain_glance_cache_config('backend_defaults/rbd_store_user').with_value('user')
should contain_glance_cache_config('backend_defaults/rbd_store_chunk_size').with_value('2')
should contain_glance_cache_config('backend_defaults/rbd_thin_provisioning').with_value('true')
should contain_glance_cache_config('backend_defaults/rados_connect_timeout').with_value('30')
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 'glance::backend::defaults::rbd'
end
end
end

View File

@@ -0,0 +1,83 @@
require 'spec_helper'
describe 'glance::backend::defaults::s3' do
shared_examples_for 'glance::backend::defaults::s3' do
context 'with defaults' do
it 'configures glance-api.conf' do
is_expected.to contain_glance_api_config('backend_defaults/s3_store_host').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('backend_defaults/s3_store_access_key').with_value('<SERVICE DEFAULT>').with_secret(true)
is_expected.to contain_glance_api_config('backend_defaults/s3_store_secret_key').with_value('<SERVICE DEFAULT>').with_secret(true)
is_expected.to contain_glance_api_config('backend_defaults/s3_store_bucket').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('backend_defaults/s3_store_create_bucket_on_put').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('backend_defaults/s3_store_bucket_url_format').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('backend_defaults/s3_store_large_object_size').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('backend_defaults/s3_store_large_object_chunk_size').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('backend_defaults/s3_store_thread_pools').with_value('<SERVICE DEFAULT>')
end
it 'configures glance-cache.conf' do
is_expected.to contain_glance_cache_config('backend_defaults/s3_store_host').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_cache_config('backend_defaults/s3_store_access_key').with_value('<SERVICE DEFAULT>').with_secret(true)
is_expected.to contain_glance_cache_config('backend_defaults/s3_store_secret_key').with_value('<SERVICE DEFAULT>').with_secret(true)
is_expected.to contain_glance_cache_config('backend_defaults/s3_store_bucket').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_cache_config('backend_defaults/s3_store_create_bucket_on_put').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_cache_config('backend_defaults/s3_store_bucket_url_format').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_cache_config('backend_defaults/s3_store_large_object_size').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_cache_config('backend_defaults/s3_store_large_object_chunk_size').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_cache_config('backend_defaults/s3_store_thread_pools').with_value('<SERVICE DEFAULT>')
end
end
context 'when overriding datadir' do
let :params do
{
:s3_store_host => 'host',
:s3_store_access_key => 'access',
:s3_store_secret_key => 'secret',
:s3_store_bucket => 'bucket',
:s3_store_create_bucket_on_put => false,
:s3_store_bucket_url_format => 'auto',
:s3_store_large_object_size => 100,
:s3_store_large_object_chunk_size => 10,
:s3_store_thread_pools => 11,
}
end
it 'configures glance-api.conf' do
is_expected.to contain_glance_api_config('backend_defaults/s3_store_host').with_value('host')
is_expected.to contain_glance_api_config('backend_defaults/s3_store_access_key').with_value('access').with_secret(true)
is_expected.to contain_glance_api_config('backend_defaults/s3_store_secret_key').with_value('secret').with_secret(true)
is_expected.to contain_glance_api_config('backend_defaults/s3_store_bucket').with_value('bucket')
is_expected.to contain_glance_api_config('backend_defaults/s3_store_create_bucket_on_put').with_value(false)
is_expected.to contain_glance_api_config('backend_defaults/s3_store_bucket_url_format').with_value('auto')
is_expected.to contain_glance_api_config('backend_defaults/s3_store_large_object_size').with_value(100)
is_expected.to contain_glance_api_config('backend_defaults/s3_store_large_object_chunk_size').with_value(10)
is_expected.to contain_glance_api_config('backend_defaults/s3_store_thread_pools').with_value(11)
end
it 'configures glance-cache.conf' do
is_expected.to contain_glance_cache_config('backend_defaults/s3_store_host').with_value('host')
is_expected.to contain_glance_cache_config('backend_defaults/s3_store_access_key').with_value('access').with_secret(true)
is_expected.to contain_glance_cache_config('backend_defaults/s3_store_secret_key').with_value('secret').with_secret(true)
is_expected.to contain_glance_cache_config('backend_defaults/s3_store_bucket').with_value('bucket')
is_expected.to contain_glance_cache_config('backend_defaults/s3_store_create_bucket_on_put').with_value(false)
is_expected.to contain_glance_cache_config('backend_defaults/s3_store_bucket_url_format').with_value('auto')
is_expected.to contain_glance_cache_config('backend_defaults/s3_store_large_object_size').with_value(100)
is_expected.to contain_glance_cache_config('backend_defaults/s3_store_large_object_chunk_size').with_value(10)
is_expected.to contain_glance_cache_config('backend_defaults/s3_store_thread_pools').with_value(11)
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 'glance::backend::defaults::s3'
end
end
end

View File

@@ -0,0 +1,88 @@
require 'spec_helper'
describe 'glance::backend::defaults::swift' do
shared_examples_for 'glance::backend::defaults::swift' do
describe 'when default parameters' do
it 'configures glance-api.conf' do
is_expected.to contain_glance_api_config('backend_defaults/swift_store_large_object_size').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('backend_defaults/swift_store_large_object_chunk_size').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('backend_defaults/swift_store_container').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('backend_defaults/swift_store_create_container_on_put').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('backend_defaults/swift_store_endpoint_type').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('backend_defaults/swift_store_service_type').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('backend_defaults/swift_store_region').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('backend_defaults/swift_buffer_on_upload').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('backend_defaults/swift_upload_buffer_dir').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('backend_defaults/swift_store_retry_get_count').with_value('<SERVICE DEFAULT>')
end
it 'configures glance-cache.conf' do
is_expected.to contain_glance_cache_config('backend_defaults/swift_store_large_object_size').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_cache_config('backend_defaults/swift_store_large_object_chunk_size').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_cache_config('backend_defaults/swift_store_container').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_cache_config('backend_defaults/swift_store_create_container_on_put').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_cache_config('backend_defaults/swift_store_endpoint_type').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_cache_config('backend_defaults/swift_store_service_type').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_cache_config('backend_defaults/swift_store_region').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_cache_config('backend_defaults/swift_buffer_on_upload').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_cache_config('backend_defaults/swift_upload_buffer_dir').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_cache_config('backend_defaults/swift_store_retry_get_count').with_value('<SERVICE DEFAULT>')
end
end
describe 'when overriding parameters' do
let :params do
{
:swift_store_large_object_size => '100',
:swift_store_large_object_chunk_size => '50',
:swift_store_container => 'swift',
:swift_store_create_container_on_put => true,
:swift_store_endpoint_type => 'publicURL',
:swift_store_service_type => 'object-store',
:swift_store_region => 'RegionTwo',
:swift_buffer_on_upload => true,
:swift_upload_buffer_dir => '/var/glance/swift',
:swift_store_retry_get_count => 3,
}
end
it 'configures glance-api.conf' do
is_expected.to contain_glance_api_config('backend_defaults/swift_store_container').with_value('swift')
is_expected.to contain_glance_api_config('backend_defaults/swift_store_create_container_on_put').with_value(true)
is_expected.to contain_glance_api_config('backend_defaults/swift_store_large_object_size').with_value('100')
is_expected.to contain_glance_api_config('backend_defaults/swift_store_large_object_chunk_size').with_value('50')
is_expected.to contain_glance_api_config('backend_defaults/swift_store_endpoint_type').with_value('publicURL')
is_expected.to contain_glance_api_config('backend_defaults/swift_store_service_type').with_value('object-store')
is_expected.to contain_glance_api_config('backend_defaults/swift_store_region').with_value('RegionTwo')
is_expected.to contain_glance_api_config('backend_defaults/swift_buffer_on_upload').with_value(true)
is_expected.to contain_glance_api_config('backend_defaults/swift_upload_buffer_dir').with_value('/var/glance/swift')
is_expected.to contain_glance_api_config('backend_defaults/swift_store_retry_get_count').with_value(3)
end
it 'configures glance-cache.conf' do
is_expected.to contain_glance_cache_config('backend_defaults/swift_store_container').with_value('swift')
is_expected.to contain_glance_cache_config('backend_defaults/swift_store_create_container_on_put').with_value(true)
is_expected.to contain_glance_cache_config('backend_defaults/swift_store_large_object_size').with_value('100')
is_expected.to contain_glance_cache_config('backend_defaults/swift_store_large_object_chunk_size').with_value('50')
is_expected.to contain_glance_cache_config('backend_defaults/swift_store_endpoint_type').with_value('publicURL')
is_expected.to contain_glance_cache_config('backend_defaults/swift_store_service_type').with_value('object-store')
is_expected.to contain_glance_cache_config('backend_defaults/swift_store_region').with_value('RegionTwo')
is_expected.to contain_glance_cache_config('backend_defaults/swift_buffer_on_upload').with_value(true)
is_expected.to contain_glance_cache_config('backend_defaults/swift_upload_buffer_dir').with_value('/var/glance/swift')
is_expected.to contain_glance_cache_config('backend_defaults/swift_store_retry_get_count').with_value(3)
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 'glance::backend::defaults::swift'
end
end
end