Browse Source

Update the method of configuring glance backends

This patch updates the method of configuring glance backends to use the
modern syntax associated with glance's Multi Store feature. Glance's
glance_store/stores and glance_store/default_store parameters were
deprecated in Rocky, and are scheduled for removal in Ussuri.

Backends are now specified using new glance::api::enabled_backends and
glance::api::default_backend parameters. A series of
glance::backend::multistore::* defined resources support configuring
multiple instances of each backend.

The legacy glance::api::stores and glance::api::default_store parameters,
as well as the glance::backend::* class resources, are deprecated, but
continue to function for backward compatibility.

The glance::backend::s3 class is completely deprecated. Glance removed
support for the s3 backend in Newton.

Closes-Bug: #1846808
Change-Id: I4f3ec9ee7c4147a4e62de961a9532bdc45526f6b
changes/22/686822/7
Alan Bishop 2 years ago
parent
commit
fd02761c6e
  1. 153
      manifests/api.pp
  2. 36
      manifests/backend/cinder.pp
  3. 11
      manifests/backend/file.pp
  4. 116
      manifests/backend/multistore/cinder.pp
  5. 49
      manifests/backend/multistore/file.pp
  6. 87
      manifests/backend/multistore/rbd.pp
  7. 125
      manifests/backend/multistore/swift.pp
  8. 109
      manifests/backend/multistore/vsphere.pp
  9. 26
      manifests/backend/rbd.pp
  10. 32
      manifests/backend/s3.pp
  11. 42
      manifests/backend/swift.pp
  12. 23
      manifests/backend/vsphere.pp
  13. 28
      releasenotes/notes/add-enabled_backends-b7b2ab71eed5f7c6.yaml
  14. 63
      spec/classes/glance_api_spec.rb
  15. 121
      spec/classes/glance_backend_s3_spec.rb
  16. 112
      spec/defines/glance_backend_multistore_cinder_spec.rb
  17. 61
      spec/defines/glance_backend_multistore_file_spec.rb
  18. 124
      spec/defines/glance_backend_multistore_rbd_spec.rb
  19. 112
      spec/defines/glance_backend_multistore_swift_spec.rb
  20. 88
      spec/defines/glance_backend_multistore_vsphere_spec.rb

153
manifests/api.pp

@ -157,34 +157,30 @@
# Defaults to $::os_service_default
#
# [*registry_client_cert_file*]
# (optinal) The path to the cert file to use in SSL connections to the
# (optional) The path to the cert file to use in SSL connections to the
# registry server.
# Defaults to $::os_service_default
#
# [*registry_client_key_file*]
# (optinal) The path to the private key file to use in SSL connections to the
# (optional) The path to the private key file to use in SSL connections to the
# registry server.
# Defaults to $::os_service_default
#
# [*registry_client_ca_file*]
# (optinal) The path to the CA certificate file to use in SSL connections to the
# (optional) The path to the CA certificate file to use in SSL connections to the
# registry server.
# Defaults to $::os_service_default
#
# [*stores*]
# (optional) List of which store classes and store class locations are
# currently known to glance at startup.
# Defaults to false.
# Example: ['file','http']
#
# [*default_store*]
# (optional) The default backend store, should be given as a string. Value
# must be provided if more than one store is listed in 'stores'.
# [*enabled_backends*]
# (optional) List of Key:Value pairs of store identifier and store type.
# Example: ['swift:swift', 'ceph1:ceph', 'ceph2:ceph']
# Defaults to undef
#
# [*multi_store*]
# (optional) Boolean describing if multiple backends will be configured
# Defaults to false
# [*default_backend*]
# (optional) The store identifier for the default backend in which data will
# be stored. The value must be defined as one of the keys in the dict
# defined by the enabled_backends.
# Defaults to undef
#
# [*image_cache_dir*]
# (optional) Base directory that the Image Cache uses.
@ -303,6 +299,23 @@
# http://auth_url:5000/v3
# Defaults to undef
#
# DEPRECATED PARAMETERS
#
# [*stores*]
# (optional) List of which store classes and store class locations are
# currently known to glance at startup.
# Defaults to undef
# Example: ['file','http']
#
# [*default_store*]
# (optional) The default backend store, should be given as a string. Value
# must be provided if more than one store is listed in 'stores'.
# Defaults to undef
#
# [*multi_store*]
# (optional) Boolean describing if multiple backends will be configured
# Defaults to false
#
class glance::api(
$package_ensure = 'present',
$bind_host = $::os_service_default,
@ -330,9 +343,8 @@ class glance::api(
$registry_client_cert_file = $::os_service_default,
$registry_client_key_file = $::os_service_default,
$registry_client_ca_file = $::os_service_default,
$stores = false,
$default_store = undef,
$multi_store = false,
$enabled_backends = undef,
$default_backend = undef,
$database_connection = undef,
$database_idle_timeout = undef,
$database_min_pool_size = undef,
@ -369,6 +381,10 @@ class glance::api(
$keymgr_backend = undef,
$keymgr_encryption_api_url = undef,
$keymgr_encryption_auth_url = undef,
# DEPRECATED PARAMETERS
$stores = undef,
$default_store = undef,
$multi_store = false,
) inherits glance {
include ::glance::deps
@ -430,46 +446,85 @@ class glance::api(
'taskflow_executor/conversion_format': value => $conversion_format,
}
if $default_store {
$default_store_real = $default_store
}
if ($stores and !empty($stores)) {
# determine value for glance_store/stores
if size(any2array($stores)) > 1 {
$stores_real = join($stores, ',')
} else {
$stores_real = $stores[0]
if $enabled_backends {
$enabled_backends_array = any2array($enabled_backends)
# Verify the backend types are valid.
$enabled_backends_array.each |$backend| {
$backend_type = split($backend, /:/)[1]
unless $backend_type =~ /file|http|swift|rbd|sheepdog|cinder|vsphere/ {
fail("\'${backend_type}\' is not a valid backend type.")
}
}
if !$default_store_real {
# set default store based on provided stores when it isn't explicitly set
warning("default_store not provided, it will be automatically set to ${stores[0]}")
$default_store_real = $stores[0]
# Verify the backend identifiers are unique and the default_backend is valid.
$backend_ids = $enabled_backends_array.map |$backend| { split($backend, /:/)[0] }
unless $backend_ids == unique($backend_ids) {
fail('All backend identifiers in enabled_backends must be unique.')
}
unless $default_backend {
fail('A glance default_backend must be specified.')
}
unless $default_backend in $backend_ids {
fail("The default_backend \'${default_backend}\' is not a valid backend identifier.")
}
} elsif $default_store_real {
# set stores based on default_store if only default_store is provided
$stores_real = $default_store
} else {
warning('Glance-api is being provisioned without any stores configured')
}
if $default_store_real and $multi_store {
glance_api_config {
'glance_store/default_store': value => $default_store_real;
'DEFAULT/enabled_backends': value => join($enabled_backends_array, ',');
'glance_store/default_backend': value => $default_backend;
'glance_store/stores': ensure => absent;
'glance_store/default_store': ensure => absent;
}
} elsif $multi_store {
glance_api_config {
'glance_store/default_store': ensure => absent;
} elsif $stores or $default_store {
warning('The stores and default_store parameters are deprecated. Please use \
enabled_backends instead.')
if $default_store {
$default_store_real = $default_store
}
if ($stores and !empty($stores)) {
# determine value for glance_store/stores
if size(any2array($stores)) > 1 {
$stores_real = join($stores, ',')
} else {
$stores_real = $stores[0]
}
if !$default_store_real {
# set default store based on provided stores when it isn't explicitly set
warning("default_store not provided, it will be automatically set to ${stores[0]}")
$default_store_real = $stores[0]
}
} elsif $default_store_real {
# set stores based on default_store if only default_store is provided
$stores_real = $default_store
} else {
warning('Glance-api is being provisioned without any stores configured')
}
}
if $stores_real {
glance_api_config {
'glance_store/stores': value => $stores_real;
if $default_store_real and $multi_store {
glance_api_config {
'glance_store/default_store': value => $default_store_real;
}
} elsif $multi_store {
glance_api_config {
'glance_store/default_store': ensure => absent;
}
}
} else {
glance_api_config {
'glance_store/stores': ensure => absent;
if $stores_real {
glance_api_config {
'glance_store/stores': value => $stores_real;
}
} else {
glance_api_config {
'glance_store/stores': ensure => absent;
}
}
} else {
warning('Glance-api is being provisioned without any backends')
}
glance_api_config {

36
manifests/backend/cinder.pp

@ -88,36 +88,26 @@ class glance::backend::cinder(
include ::glance::deps
warning('glance::backend::cinder is deprecated. Use glance::backend::multistore::cinder instead.')
if $os_region_name {
notice('The os_region_name parameter is deprecated and has no effect. Use glance::api::os_region_name instead.')
}
glance_api_config {
'glance_store/cinder_api_insecure': value => $cinder_api_insecure;
'glance_store/cinder_catalog_info': value => $cinder_catalog_info;
'glance_store/cinder_http_retries': value => $cinder_http_retries;
'glance_store/cinder_endpoint_template': value => $cinder_endpoint_template;
'glance_store/cinder_ca_certificates_file': value => $cinder_ca_certificates_file;
'glance_store/cinder_store_auth_address': value => $cinder_store_auth_address;
'glance_store/cinder_store_project_name': value => $cinder_store_project_name;
'glance_store/cinder_store_user_name': value => $cinder_store_user_name;
'glance_store/cinder_store_password': value => $cinder_store_password;
glance::backend::multistore::cinder { 'glance_store':
cinder_api_insecure => $cinder_api_insecure,
cinder_catalog_info => $cinder_catalog_info,
cinder_http_retries => $cinder_http_retries,
cinder_endpoint_template => $cinder_endpoint_template,
cinder_ca_certificates_file => $cinder_ca_certificates_file,
cinder_store_auth_address => $cinder_store_auth_address,
cinder_store_project_name => $cinder_store_project_name,
cinder_store_user_name => $cinder_store_user_name,
cinder_store_password => $cinder_store_password,
store_description => undef,
}
if !$multi_store {
glance_api_config { 'glance_store/default_store': value => 'cinder'; }
}
glance_cache_config {
'glance_store/cinder_api_insecure': value => $cinder_api_insecure;
'glance_store/cinder_catalog_info': value => $cinder_catalog_info;
'glance_store/cinder_http_retries': value => $cinder_http_retries;
'glance_store/cinder_endpoint_template': value => $cinder_endpoint_template;
'glance_store/cinder_ca_certificates_file': value => $cinder_ca_certificates_file;
'glance_store/cinder_store_auth_address': value => $cinder_store_auth_address;
'glance_store/cinder_store_project_name': value => $cinder_store_project_name;
'glance_store/cinder_store_user_name': value => $cinder_store_user_name;
'glance_store/cinder_store_password': value => $cinder_store_password;
}
}

11
manifests/backend/file.pp

@ -20,15 +20,14 @@ class glance::backend::file(
include ::glance::deps
glance_api_config {
'glance_store/filesystem_store_datadir': value => $filesystem_store_datadir;
warning('glance::backend::file is deprecated. Use glance::backend::multistore::file instead.')
glance::backend::multistore::file { 'glance_store':
filesystem_store_datadir => $filesystem_store_datadir,
store_description => undef,
}
if !$multi_store {
glance_api_config { 'glance_store/default_store': value => 'file'; }
}
glance_cache_config {
'glance_store/filesystem_store_datadir': value => $filesystem_store_datadir;
}
}

116
manifests/backend/multistore/cinder.pp

@ -0,0 +1,116 @@
#
# Copyright 2019 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# == Define: glance::backend::multistore::cinder
#
# Used to configure cinder backends for glance
#
# === Parameters
#
# [*cinder_catalog_info*]
# (optional) Info to match when looking for cinder in the service catalog.
# Format is : separated values of the form:
# <service_type>:<service_name>:<endpoint_type> (string value)
# Defaults to $::os_service_default.
#
# [*cinder_endpoint_template*]
# (optional) Override service catalog lookup with template for cinder endpoint.
# Should be a valid URL. Example: 'http://localhost:8776/v1/%(project_id)s'
# Defaults to $::os_service_default.
#
# [*os_region_name*]
# (optional) The os_region_name parameter is deprecated and has no effect.
# Use glance::api::os_region_name instead.
# Defaults to 'undef'
#
# [*cinder_ca_certificates_file*]
# (optional) Location of ca certicate file to use for cinder client requests.
# Should be a valid ca certicate file
# Defaults to $::os_service_default.
#
# [*cinder_http_retries*]
# (optional) Number of cinderclient retries on failed http calls.
# Should be a valid integer
# Defaults to $::os_service_default.
#
# [*cinder_api_insecure*]
# (optional) Allow to perform insecure SSL requests to cinder.
# Should be a valid boolean value
# Defaults to $::os_service_default.
#
# [*cinder_store_auth_address*]
# (optional) A valid authentication service address.
# Defaults to $::os_service_default.
#
# [*cinder_store_project_name*]
# (optional) Project name where the image volume is stored in cinder.
# Defaults to $::os_service_default.
#
# [*cinder_store_user_name*]
# (optional) User name to authenticate against cinder.
# Defaults to $::os_service_default.
#
# [*cinder_store_password*]
# (optional) A valid password for the user specified by `cinder_store_user_name'
# Defaults to $::os_service_default.
#
# [*store_description*]
# (optional) Provides constructive information about the store backend to
# end users.
# Defaults to $::os_service_default.
#
define glance::backend::multistore::cinder(
$cinder_ca_certificates_file = $::os_service_default,
$cinder_api_insecure = $::os_service_default,
$cinder_catalog_info = $::os_service_default,
$cinder_endpoint_template = $::os_service_default,
$cinder_http_retries = $::os_service_default,
$cinder_store_auth_address = $::os_service_default,
$cinder_store_project_name = $::os_service_default,
$cinder_store_user_name = $::os_service_default,
$cinder_store_password = $::os_service_default,
$store_description = $::os_service_default,
) {
include ::glance::deps
glance_api_config {
"${name}/cinder_api_insecure": value => $cinder_api_insecure;
"${name}/cinder_catalog_info": value => $cinder_catalog_info;
"${name}/cinder_http_retries": value => $cinder_http_retries;
"${name}/cinder_endpoint_template": value => $cinder_endpoint_template;
"${name}/cinder_ca_certificates_file": value => $cinder_ca_certificates_file;
"${name}/cinder_store_auth_address": value => $cinder_store_auth_address;
"${name}/cinder_store_project_name": value => $cinder_store_project_name;
"${name}/cinder_store_user_name": value => $cinder_store_user_name;
"${name}/cinder_store_password": value => $cinder_store_password;
"${name}/store_description": value => $store_description;
}
glance_cache_config {
"${name}/cinder_api_insecure": value => $cinder_api_insecure;
"${name}/cinder_catalog_info": value => $cinder_catalog_info;
"${name}/cinder_http_retries": value => $cinder_http_retries;
"${name}/cinder_endpoint_template": value => $cinder_endpoint_template;
"${name}/cinder_ca_certificates_file": value => $cinder_ca_certificates_file;
"${name}/cinder_store_auth_address": value => $cinder_store_auth_address;
"${name}/cinder_store_project_name": value => $cinder_store_project_name;
"${name}/cinder_store_user_name": value => $cinder_store_user_name;
"${name}/cinder_store_password": value => $cinder_store_password;
}
create_resources('glance_api_config', {})
create_resources('glance_cache_config', {})
}

49
manifests/backend/multistore/file.pp

@ -0,0 +1,49 @@
#
# Copyright 2019 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# == Define: glance::backend::multistore::file
#
# Used to configure file backends for glance
#
# === Parameters:
#
# [*filesystem_store_datadir*]
# Location where dist images are stored when the backend type is file.
# Defaults to $::os_service_default.
#
# [*store_description*]
# (optional) Provides constructive information about the store backend to
# end users.
# Defaults to $::os_service_default.
#
define glance::backend::multistore::file(
$filesystem_store_datadir = $::os_service_default,
$store_description = $::os_service_default,
) {
include ::glance::deps
glance_api_config {
"${name}/filesystem_store_datadir": value => $filesystem_store_datadir;
"${name}/store_description": value => $store_description;
}
glance_cache_config {
"${name}/filesystem_store_datadir": value => $filesystem_store_datadir;
}
create_resources('glance_api_config', {})
create_resources('glance_cache_config', {})
}

87
manifests/backend/multistore/rbd.pp

@ -0,0 +1,87 @@
#
# Copyright 2019 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# == Define: glance::backend::multistore::rbd
#
# configures the storage backend for glance
# as a rbd instance
#
# === Parameters:
#
# [*rbd_store_user*]
# Optional. Default: $::os_service_default.
#
# [*rbd_store_pool*]
# Optional. Default: $::os_service_default.
#
# [*rbd_store_ceph_conf*]
# Optional. Default: $::os_service_default.
#
# [*rbd_store_chunk_size*]
# Optional. Default: $::os_service_default.
#
# [*manage_packages*]
# Optional. Whether we should manage the packages.
# Defaults to true,
#
# [*package_ensure*]
# Optional. Desired ensure state of packages.
# accepts latest or specific versions.
# Defaults to present.
#
# [*rados_connect_timeout*]
# Optinal. Timeout value (in seconds) used when connecting
# to ceph cluster. If value <= 0, no timeout is set and
# default librados value is used.
# Default: $::os_service_default.
#
# [*store_description*]
# (optional) Provides constructive information about the store backend to
# end users.
# Defaults to $::os_service_default.
#
define glance::backend::multistore::rbd(
$rbd_store_user = $::os_service_default,
$rbd_store_ceph_conf = $::os_service_default,
$rbd_store_pool = $::os_service_default,
$rbd_store_chunk_size = $::os_service_default,
$manage_packages = true,
$package_ensure = 'present',
$rados_connect_timeout = $::os_service_default,
$store_description = $::os_service_default,
) {
include ::glance::deps
include ::glance::params
glance_api_config {
"${name}/rbd_store_ceph_conf": value => $rbd_store_ceph_conf;
"${name}/rbd_store_user": value => $rbd_store_user;
"${name}/rbd_store_pool": value => $rbd_store_pool;
"${name}/rbd_store_chunk_size": value => $rbd_store_chunk_size;
"${name}/rados_connect_timeout": value => $rados_connect_timeout;
"${name}/store_description": value => $store_description;
}
if $manage_packages and !defined(Package["${::glance::params::pyceph_package_name}"]) {
ensure_resource('package', 'python-ceph', {
ensure => $package_ensure,
name => $::glance::params::pyceph_package_name,
tag => 'glance-support-package',
})
}
create_resources('glance_api_config', {})
}

125
manifests/backend/multistore/swift.pp

@ -0,0 +1,125 @@
#
# Copyright 2019 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# == Define: glance::backend::swift
#
# configures the storage backend for glance
# as a swift instance
#
# === Parameters:
#
# [*swift_store_user*]
# Required. Swift store user.
#
# [*swift_store_key*]
# Required. Swift store key.
#
# [*swift_store_auth_address*]
# Optional. Default: 'http://127.0.0.1:5000/v3/'
#
# [*swift_store_auth_project_domain_id*]
# Optional. Useful when keystone auth is version 3. Default: default
#
# [*swift_store_auth_user_domain_id*]
# Optional. Useful when keystone auth is version 3. Default: default
#
# [*swift_store_container*]
# Optional. Default: $::os_service_default.
#
# [*swift_store_auth_version*]
# Optional. Default: '2'
#
# [*swift_store_large_object_size*]
# Optional. What size, in MB, should Glance start chunking image files
# and do a large object manifest in Swift?
# Default: $::os_service_default.
#
# [*swift_store_large_object_chunk_size*]
# Optional. When doing a large object manifest, what size, in MB, should
# Glance write chunks to Swift? This amount of data is written
# to a temporary disk buffer during the process of chunking.
# Default: $::os_service_default.
#
# [*swift_store_create_container_on_put*]
# Optional. Default: $::os_service_default.
#
# [*swift_store_endpoint_type*]
# Optional. Default: 'internalURL'
#
# [*swift_store_region*]
# Optional. Default: $::os_service_default.
#
# [*swift_store_config_file*]
# Optional. Default: $::os_service_default.
#
# [*default_swift_reference*]
# Optional. The reference to the default swift
# account/backing store parameters to use for adding
# new images. String value.
# Default to 'ref1'.
#
# [*store_description*]
# (optional) Provides constructive information about the store backend to
# end users.
# Defaults to $::os_service_default.
#
define glance::backend::multistore::swift(
$swift_store_user,
$swift_store_key,
$swift_store_auth_address = 'http://127.0.0.1:5000/v3/',
$swift_store_container = $::os_service_default,
$swift_store_auth_version = '2',
$swift_store_auth_project_domain_id = 'default',
$swift_store_auth_user_domain_id = 'default',
$swift_store_large_object_size = $::os_service_default,
$swift_store_large_object_chunk_size = $::os_service_default,
$swift_store_create_container_on_put = $::os_service_default,
$swift_store_endpoint_type = 'internalURL',
$swift_store_region = $::os_service_default,
$swift_store_config_file = $::os_service_default,
$default_swift_reference = 'ref1',
$store_description = $::os_service_default,
) {
include ::glance::deps
include ::swift::client
Class['swift::client'] -> Anchor['glance::install::end']
Service<| tag == 'swift-service' |> -> Service['glance-api']
glance_api_config {
"${name}/swift_store_region": value => $swift_store_region;
"${name}/swift_store_container": value => $swift_store_container;
"${name}/swift_store_create_container_on_put": value => $swift_store_create_container_on_put;
"${name}/swift_store_large_object_size": value => $swift_store_large_object_size;
"${name}/swift_store_large_object_chunk_size": value => $swift_store_large_object_chunk_size;
"${name}/swift_store_endpoint_type": value => $swift_store_endpoint_type;
"${name}/swift_store_config_file": value => $swift_store_config_file;
"${name}/default_swift_reference": value => $default_swift_reference;
"${name}/store_description": value => $store_description;
}
glance_swift_config {
"${default_swift_reference}/user": value => $swift_store_user;
"${default_swift_reference}/key": value => $swift_store_key;
"${default_swift_reference}/auth_address": value => $swift_store_auth_address;
"${default_swift_reference}/auth_version": value => $swift_store_auth_version;
"${default_swift_reference}/user_domain_id": value => $swift_store_auth_user_domain_id;
"${default_swift_reference}/project_domain_id": value => $swift_store_auth_project_domain_id;
}
create_resources('glance_api_config', {})
create_resources('glance_swift_config', {})
}

109
manifests/backend/multistore/vsphere.pp

@ -0,0 +1,109 @@
#
# Copyright 2019 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# == Define: glance::backend::multistore::vsphere
#
# Used to configure vsphere backends for glance
#
# === Parameters
#
# [*vmware_insecure*]
# (optional) If true, the ESX/vCenter server certificate is not verified.
# If false, then the default CA truststore is used for verification.
# This option is ignored if "vcenter_ca_file" is set.
# Defaults to 'True'.
#
# [*vmware_ca_file*]
# (optional) The name of the CA bundle file which will be used in
# verifying vCenter server certificate. If parameter is not set
# then system truststore is used. If parameter is set,
# vcenter_insecure value is ignored.
# Defaults to $::os_service_default.
#
# [*vmware_datastores*]
# (Multi-valued) A list of datastores where the image
# can be stored. This option may be specified multiple times
# for specifying multiple datastores. The datastore name should
# be specified after its datacenter path, separated by ":".
# An optional weight may be given after the datastore name,
# separated again by ":". Thus, the required format
# becomes <datacenter_path>:<datastore_name>:<optional_weight>.
# When adding an image, the datastore with highest weight will be selected,
# unless there is not enough free space available in cases where the image
# size is already known. If no weight is given, it is assumed to be
# zero and the directory will be considered for selection last.
# If multiple datastores have the same weight, then the one with the most
# free space available is selected.
# Defaults to $::os_service_default.
#
# [*vmware_server_host*]
# (required) vCenter/ESXi Server target system.
# Should be a valid an IP address or a DNS name.
#
# [*vmware_server_username*]
# (required) Username for authenticating with vCenter/ESXi server.
#
# [*vmware_server_password*]
# (required) Password for authenticating with vCenter/ESXi server.
#
# [*vmware_store_image_dir*]
# (required) The name of the directory where the glance images will be stored
# in the VMware datastore.
#
# [*vmware_task_poll_interval*]
# (optional) The interval used for polling remote tasks invoked on
# vCenter/ESXi server.
# Defaults to $::os_service_default.
#
# [*vmware_api_retry_count*]
# (optional) Number of times VMware ESX/VC server API must be retried upon
# connection related issues.
# Defaults to $::os_service_default.
#
# [*store_description*]
# (optional) Provides constructive information about the store backend to
# end users.
# Defaults to $::os_service_default.
#
define glance::backend::multistore::vsphere(
$vmware_server_host,
$vmware_server_username,
$vmware_server_password,
$vmware_store_image_dir,
$vmware_ca_file = $::os_service_default,
$vmware_datastores = $::os_service_default,
$vmware_insecure = 'True',
$vmware_task_poll_interval = $::os_service_default,
$vmware_api_retry_count = $::os_service_default,
$store_description = $::os_service_default,
) {
include ::glance::deps
glance_api_config {
"${name}/vmware_insecure": value => $vmware_insecure;
"${name}/vmware_ca_file": value => $vmware_ca_file;
"${name}/vmware_server_host": value => $vmware_server_host;
"${name}/vmware_server_username": value => $vmware_server_username;
"${name}/vmware_server_password": value => $vmware_server_password, secret => true;
"${name}/vmware_store_image_dir": value => $vmware_store_image_dir;
"${name}/vmware_task_poll_interval": value => $vmware_task_poll_interval;
"${name}/vmware_api_retry_count": value => $vmware_api_retry_count;
"${name}/vmware_datastores": value => $vmware_datastores;
"${name}/store_description": value => $store_description;
}
create_resources('glance_api_config', {})
}

26
manifests/backend/rbd.pp

@ -50,24 +50,20 @@ class glance::backend::rbd(
include ::glance::deps
include ::glance::params
glance_api_config {
'glance_store/rbd_store_ceph_conf': value => $rbd_store_ceph_conf;
'glance_store/rbd_store_user': value => $rbd_store_user;
'glance_store/rbd_store_pool': value => $rbd_store_pool;
'glance_store/rbd_store_chunk_size': value => $rbd_store_chunk_size;
'glance_store/rados_connect_timeout': value => $rados_connect_timeout;
warning('glance::backend::rbd is deprecated. Use glance::backend::multistore::rbd instead.')
glance::backend::multistore::rbd { 'glance_store':
rbd_store_ceph_conf => $rbd_store_ceph_conf,
rbd_store_user => $rbd_store_user,
rbd_store_pool => $rbd_store_pool,
rbd_store_chunk_size => $rbd_store_chunk_size,
rados_connect_timeout => $rados_connect_timeout,
manage_packages => $manage_packages,
package_ensure => $package_ensure,
store_description => undef,
}
if !$multi_store {
glance_api_config { 'glance_store/default_store': value => 'rbd'; }
}
if $manage_packages {
package { 'python-ceph':
ensure => $package_ensure,
name => $::glance::params::pyceph_package_name,
tag => 'glance-support-package',
}
}
}

32
manifests/backend/s3.pp

@ -64,35 +64,5 @@ class glance::backend::s3(
$multi_store = false,
) {
include ::glance::deps
if !is_service_default($large_object_chunk_size){
if !is_integer($large_object_chunk_size) or $large_object_chunk_size < 5 {
fail('glance::backend::s3::large_object_chunk_size must be an integer >= 5')
}
}
if !is_service_default($bucket_url_format){
if !($bucket_url_format in ['subdomain', 'path']) {
fail('glance::backend::s3::bucket_url_format must be either "subdomain" or "path"')
}
}
glance_api_config {
'glance_store/s3_store_access_key': value => $access_key, secret => true;
'glance_store/s3_store_secret_key': value => $secret_key, secret => true;
'glance_store/s3_store_host': value => $host;
'glance_store/s3_store_bucket': value => $bucket;
'glance_store/s3_store_bucket_url_format': value => $bucket_url_format;
'glance_store/s3_store_create_bucket_on_put': value => $create_bucket_on_put;
'glance_store/s3_store_large_object_size': value => $large_object_size;
'glance_store/s3_store_large_object_chunk_size': value => $large_object_chunk_size;
'glance_store/s3_store_thread_pools': value => $thread_pools;
'glance_store/s3_store_object_buffer_dir': value => $object_buffer_dir;
}
if !$multi_store {
glance_api_config { 'glance_store/default_store': value => 's3'; }
}
warning('glance::backend::s3 is deprecated and has no effect. Glance no longer supports the s3 backend.')
}

42
manifests/backend/swift.pp

@ -75,36 +75,28 @@ class glance::backend::swift(
include ::glance::deps
include ::swift::client
Class['swift::client'] -> Anchor['glance::install::end']
Service<| tag == 'swift-service' |> -> Service['glance-api']
glance_api_config {
'glance_store/swift_store_region': value => $swift_store_region;
'glance_store/swift_store_container': value => $swift_store_container;
'glance_store/swift_store_create_container_on_put':
value => $swift_store_create_container_on_put;
'glance_store/swift_store_large_object_size':
value => $swift_store_large_object_size;
'glance_store/swift_store_large_object_chunk_size':
value => $swift_store_large_object_chunk_size;
'glance_store/swift_store_endpoint_type':
value => $swift_store_endpoint_type;
warning('glance::backend::swift is deprecated. Use glance::backend::multistore::swift instead.')
'glance_store/swift_store_config_file': value => '/etc/glance/glance-swift.conf';
'glance_store/default_swift_reference': value => $default_swift_reference;
glance::backend::multistore::swift { 'glance_store':
swift_store_user => $swift_store_user,
swift_store_key => $swift_store_key,
swift_store_auth_address => $swift_store_auth_address,
swift_store_container => $swift_store_container,
swift_store_auth_version => $swift_store_auth_version,
swift_store_auth_project_domain_id => $swift_store_auth_project_domain_id,
swift_store_auth_user_domain_id => $swift_store_auth_user_domain_id,
swift_store_large_object_size => $swift_store_large_object_size,
swift_store_large_object_chunk_size => $swift_store_large_object_chunk_size,
swift_store_create_container_on_put => $swift_store_create_container_on_put,
swift_store_endpoint_type => $swift_store_endpoint_type,
swift_store_region => $swift_store_region,
swift_store_config_file => '/etc/glance/glance-swift.conf',
default_swift_reference => $default_swift_reference,
store_description => undef,
}
if !$multi_store {
glance_api_config { 'glance_store/default_store': value => 'swift'; }
}
glance_swift_config {
"${default_swift_reference}/user": value => $swift_store_user;
"${default_swift_reference}/key": value => $swift_store_key;
"${default_swift_reference}/auth_address": value => $swift_store_auth_address;
"${default_swift_reference}/auth_version": value => $swift_store_auth_version;
"${default_swift_reference}/user_domain_id": value => $swift_store_auth_user_domain_id;
"${default_swift_reference}/project_domain_id": value => $swift_store_auth_project_domain_id;
}
}

23
manifests/backend/vsphere.pp

@ -93,16 +93,19 @@ class glance::backend::vsphere(
include ::glance::deps
glance_api_config {
'glance_store/vmware_insecure': value => $vcenter_insecure;
'glance_store/vmware_ca_file': value => $vcenter_ca_file;
'glance_store/vmware_server_host': value => $vcenter_host;
'glance_store/vmware_server_username': value => $vcenter_user;
'glance_store/vmware_server_password': value => $vcenter_password, secret => true;
'glance_store/vmware_store_image_dir': value => $vcenter_image_dir;
'glance_store/vmware_task_poll_interval': value => $vcenter_task_poll_interval;
'glance_store/vmware_api_retry_count': value => $vcenter_api_retry_count;
'glance_store/vmware_datastores': value => $vcenter_datastores;
warning('glance::backend::vsphere is deprecated. Use glance::backend::multistore::vsphere instead.')
glance::backend::multistore::vsphere { 'glance_store':
vmware_server_host => $vcenter_host,
vmware_server_username => $vcenter_user,
vmware_server_password => $vcenter_password,
vmware_store_image_dir => $vcenter_image_dir,
vmware_ca_file => $vcenter_ca_file,
vmware_datastores => $vcenter_datastores,
vmware_insecure => $vcenter_insecure,
vmware_task_poll_interval => $vcenter_task_poll_interval,
vmware_api_retry_count => $vcenter_api_retry_count,
store_description => undef,
}
if !$multi_store {

28
releasenotes/notes/add-enabled_backends-b7b2ab71eed5f7c6.yaml

@ -0,0 +1,28 @@
---
features:
- |
Add glance::api::enabled_backends and glance::api::default_backend
parameters for configuring glance backends. The parameters implement
glance's Multi Store syntax, which supports configuring multiple backends
of the same type (e.g. multiple rbd backends). Multiple backends of the
same type may be specified using new glance::backend::multistore::*
defined resource types.
deprecations:
- |
The following parameters are deprecated due to the corresponding parameters
being deprecated in glance. They are replaced by the new
glance::api::enabled_backends and glance::api::default_backend parameters.
* glance::api::stores
* glance::api::default_store
* glance::api::multi_store
The following backend resources are deprecated because they are associated
with the deprecated glance::api::stores parameter. They are replaced by
corresponding glance::backend::multistore resources, except for the s3
backend which was removed from glance in Newton.
* glance::backend::cinder
* glance::backend::file
* glance::backend::rbd
* glance::backend::s3
* glance::backend::swift
* glance::backend::vsphere

63
spec/classes/glance_api_spec.rb

@ -27,7 +27,6 @@ describe 'glance::api' do
:purge_config => false,
:delayed_delete => '<SERVICE DEFAULT>',
:scrub_time => '<SERVICE DEFAULT>',
:default_store => false,
:image_cache_dir => '/var/lib/glance/image-cache',
:image_import_plugins => '<SERVICE DEFAULT>',
:image_conversion_output_format => '<SERVICE DEFAULT>',
@ -323,14 +322,74 @@ describe 'glance::api' do
end
end
describe 'with stores by default' do
describe 'with enabled_backends and stores by default' do
let :params do
default_params
end
it { is_expected.to_not contain_glance_api_config('DEFAULT/enabled_backends').with_value('<SERVICE DEFAULT>') }
it { is_expected.to_not contain_glance_api_config('glance_store/stores').with_value('<SERVICE DEFAULT>') }
end
describe 'with enabled_backends' do
let :params do
default_params.merge({
:enabled_backends => ['file1:file','http1:http'],
:default_backend => 'file1',
:stores => ['file','http'],
:default_store => 'file',
})
end
it { is_expected.to contain_glance_api_config('DEFAULT/enabled_backends').with_value('file1:file,http1:http') }
it { is_expected.to contain_glance_api_config('glance_store/default_backend').with_value('file1') }
it { is_expected.to contain_glance_api_config('glance_store/stores').with_ensure('absent') }
it { is_expected.to contain_glance_api_config('glance_store/default_store').with_ensure('absent') }
end
describe 'with invalid backend type' do
let :params do
default_params.merge({
:enabled_backends => ['file1:file','bad1:mybad'],
:default_backend => 'file',
})
end
it_raises 'a Puppet::Error', / is not a valid backend type./
end
describe 'with enabled_backends but no default_backend' do
let :params do
default_params.merge({
:enabled_backends => ['file1:file','http1:http'],
})
end
it_raises 'a Puppet::Error', /A glance default_backend must be specified./
end
describe 'with duplicate backend identifiers' do
let :params do
default_params.merge({
:enabled_backends => ['file1:file','file1:http'],
:default_backend => 'file1',
})
end
it_raises 'a Puppet::Error', /All backend identifiers in enabled_backends must be unique./
end
describe 'with invalid default_backend' do
let :params do
default_params.merge({
:enabled_backends => ['file1:file','http1:http'],
:default_backend => 'file2',
})
end
it_raises 'a Puppet::Error', / is not a valid backend identifier./
end
describe 'with stores override' do
let :params do
default_params.merge({

121
spec/classes/glance_backend_s3_spec.rb

@ -1,121 +0,0 @@
require 'spec_helper'
describe 'glance::backend::s3' do
shared_examples_for 'glance::backend::s3' do
let :params do
{
:access_key => 'access',
:secret_key => 'secret',
:host => 'host',
:bucket => 'bucket'
}
end
describe 'when default parameters' do
it 'configures glance-api.conf' do
is_expected.to contain_glance_api_config('glance_store/default_store').with_value('s3')
is_expected.to contain_glance_api_config('glance_store/s3_store_access_key').with_value('access').with_secret(true)
is_expected.to contain_glance_api_config('glance_store/s3_store_secret_key').with_value('secret').with_secret(true)
is_expected.to contain_glance_api_config('glance_store/s3_store_host').with_value('host')
is_expected.to contain_glance_api_config('glance_store/s3_store_bucket').with_value('bucket')
is_expected.to contain_glance_api_config('glance_store/s3_store_bucket_url_format').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('glance_store/s3_store_create_bucket_on_put').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('glance_store/s3_store_large_object_size').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('glance_store/s3_store_large_object_chunk_size').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('glance_store/s3_store_object_buffer_dir').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('glance_store/s3_store_thread_pools').with_value('<SERVICE DEFAULT>')
end
end
describe 'when overriding parameters' do
let :params do
{
:access_key => 'access2',
:secret_key => 'secret2',
:host => 'host2',
:bucket => 'bucket2',
:bucket_url_format => 'path',
:create_bucket_on_put => true,
:large_object_size => 200,
:large_object_chunk_size => 20,
:object_buffer_dir => '/tmp',
:thread_pools => 20,
}
end
it 'configures glance-api.conf' do
is_expected.to contain_glance_api_config('glance_store/s3_store_access_key').with_value('access2').with_secret(true)
is_expected.to contain_glance_api_config('glance_store/s3_store_secret_key').with_value('secret2').with_secret(true)
is_expected.to contain_glance_api_config('glance_store/s3_store_host').with_value('host2')
is_expected.to contain_glance_api_config('glance_store/s3_store_bucket').with_value('bucket2')
is_expected.to contain_glance_api_config('glance_store/s3_store_bucket_url_format').with_value('path')
is_expected.to contain_glance_api_config('glance_store/s3_store_create_bucket_on_put').with_value('true')
is_expected.to contain_glance_api_config('glance_store/s3_store_large_object_size').with_value('200')
is_expected.to contain_glance_api_config('glance_store/s3_store_large_object_chunk_size').with_value('20')
is_expected.to contain_glance_api_config('glance_store/s3_store_object_buffer_dir').with_value('/tmp')
is_expected.to contain_glance_api_config('glance_store/s3_store_thread_pools').with_value('20')
end
end
describe 'with invalid bucket_url_format' do
let :params do
{
:access_key => 'access',
:secret_key => 'secret',
:host => 'host',
:bucket => 'bucket',
:bucket_url_format => 'invalid'
}
end
it 'throws errors' do
is_expected.to raise_error(Puppet::Error, /glance::backend::s3::bucket_url_format must be either "subdomain" or "path"/)
end
end
describe 'with invalid large_object_chunk_size' do
let :params do
{
:access_key => 'access',
:secret_key => 'secret',
:host => 'host',
:bucket => 'bucket',
:large_object_chunk_size => 1
}
end
it 'throws error' do
is_expected.to raise_error(Puppet::Error, /glance::backend::s3::large_object_chunk_size must be an integer >= 5/)
end
end
describe 'with non-integer large_object_chunk_size' do
let :params do
{
:access_key => 'access',
:secret_key => 'secret',
:host => 'host',
:bucket => 'bucket',
:large_object_chunk_size => 'string'
}
end
it 'throws error' do
is_expected.to raise_error(Puppet::Error, /glance::backend::s3::large_object_chunk_size must be an integer >= 5/)
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_configures 'glance::backend::s3'
end
end
end

112
spec/defines/glance_backend_multistore_cinder_spec.rb

@ -0,0 +1,112 @@
#
# Copyright 2019 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# Unit tests for glance::backend::multistore::cinder
#
require 'spec_helper'
describe 'glance::backend::multistore::cinder' do
let (:title) { 'cinder' }
let :pre_condition do
'class { "glance::api::authtoken": password => "pass" }'
end
shared_examples_for 'glance::backend::multistore::cinder' do
context 'when default parameters' do
it 'configures glance-api.conf' do
is_expected.to contain_glance_api_config('cinder/store_description').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('cinder/cinder_api_insecure').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('cinder/cinder_catalog_info').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('cinder/cinder_http_retries').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('cinder/cinder_ca_certificates_file').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('cinder/cinder_endpoint_template').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('cinder/cinder_store_auth_address').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('cinder/cinder_store_project_name').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('cinder/cinder_store_user_name').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('cinder/cinder_store_password').with_value('<SERVICE DEFAULT>')
end
it 'configures glance-cache.conf' do
is_expected.to_not contain_glance_cache_config('cinder/store_description')
is_expected.to contain_glance_cache_config('cinder/cinder_api_insecure').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_cache_config('cinder/cinder_catalog_info').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_cache_config('cinder/cinder_http_retries').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_cache_config('cinder/cinder_ca_certificates_file').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_cache_config('cinder/cinder_endpoint_template').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_cache_config('cinder/cinder_store_auth_address').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_cache_config('cinder/cinder_store_project_name').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_cache_config('cinder/cinder_store_user_name').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_cache_config('cinder/cinder_store_password').with_value('<SERVICE DEFAULT>')
end
end
context 'when overriding parameters' do
let :params do
{
:store_description => 'My cinder store',
:cinder_api_insecure => true,
:cinder_ca_certificates_file => '/etc/ssh/ca.crt',
:cinder_catalog_info => 'volume:cinder:internalURL',
:cinder_endpoint_template => 'http://srv-foo:8776/v1/%(project_id)s',
:cinder_http_retries => '10',
:cinder_store_auth_address => '127.0.0.2:8080/v3/',
:cinder_store_project_name => 'services',
:cinder_store_user_name => 'glance',
:cinder_store_password => 'glance',
}
end
it 'configures glance-api.conf' do
is_expected.to contain_glance_api_config('cinder/store_description').with_value('My cinder store')
is_expected.to contain_glance_api_config('cinder/cinder_api_insecure').with_value(true)
is_expected.to contain_glance_api_config('cinder/cinder_ca_certificates_file').with_value('/etc/ssh/ca.crt')
is_expected.to contain_glance_api_config('cinder/cinder_catalog_info').with_value('volume:cinder:internalURL')
is_expected.to contain_glance_api_config('cinder/cinder_endpoint_template').with_value('http://srv-foo:8776/v1/%(project_id)s')
is_expected.to contain_glance_api_config('cinder/cinder_http_retries').with_value('10')
is_expected.to contain_glance_api_config('cinder/cinder_store_auth_address').with_value('127.0.0.2:8080/v3/')
is_expected.to contain_glance_api_config('cinder/cinder_store_project_name').with_value('services')
is_expected.to contain_glance_api_config('cinder/cinder_store_user_name').with_value('glance')
is_expected.to contain_glance_api_config('cinder/cinder_store_password').with_value('glance')
end
it 'configures glance-cache.conf' do
is_expected.to_not contain_glance_cache_config('cinder/store_description')
is_expected.to contain_glance_cache_config('cinder/cinder_api_insecure').with_value(true)
is_expected.to contain_glance_cache_config('cinder/cinder_ca_certificates_file').with_value('/etc/ssh/ca.crt')
is_expected.to contain_glance_cache_config('cinder/cinder_catalog_info').with_value('volume:cinder:internalURL')
is_expected.to contain_glance_cache_config('cinder/cinder_endpoint_template').with_value('http://srv-foo:8776/v1/%(project_id)s')
is_expected.to contain_glance_cache_config('cinder/cinder_http_retries').with_value('10')
is_expected.to contain_glance_cache_config('cinder/cinder_store_auth_address').with_value('127.0.0.2:8080/v3/')
is_expected.to contain_glance_cache_config('cinder/cinder_store_project_name').with_value('services')
is_expected.to contain_glance_cache_config('cinder/cinder_store_user_name').with_value('glance')
is_expected.to contain_glance_cache_config('cinder/cinder_store_password').with_value('glance')
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::multistore::cinder'
end
end
end

61
spec/defines/glance_backend_multistore_file_spec.rb

@ -0,0 +1,61 @@
#
# Copyright 2019 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# Unit tests for glance::backend::multistore::file
#
require 'spec_helper'
describe 'glance::backend::multistore::file' do
let (:title) { 'file' }
shared_examples_for 'glance::backend::multistore::file' do
it 'configures glance-api.conf' do
is_expected.to contain_glance_api_config('file/store_description').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('file/filesystem_store_datadir').with_value('<SERVICE DEFAULT>')
end
it 'configures glance-cache.conf' do
is_expected.to_not contain_glance_cache_config('file/store_description')
is_expected.to contain_glance_cache_config('file/filesystem_store_datadir').with_value('<SERVICE DEFAULT>')
end
describe 'when overriding datadir' do
let :params do
{:filesystem_store_datadir => '/tmp/'}
end
it 'configures glance-api.conf' do
is_expected.to contain_glance_api_config('file/filesystem_store_datadir').with_value('/tmp/')
end
it 'configures glance-cache.conf' do
is_expected.to contain_glance_cache_config('file/filesystem_store_datadir').with_value('/tmp/')
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::multistore::file'
end
end
end

124
spec/defines/glance_backend_multistore_rbd_spec.rb

@ -0,0 +1,124 @@
#
# Copyright 2019 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# Unit tests for glance::backend::multistore::rbd
#
require 'spec_helper'
describe 'glance::backend::multistore::rbd' do
let (:title) { 'rbd' }
shared_examples 'glance::backend::multistore::rbd' do
context 'with default params' do
it { should contain_glance_api_config('rbd/store_description').with_value('<SERVICE DEFAULT>') }
it { should contain_glance_api_config('rbd/rbd_store_pool').with_value('<SERVICE DEFAULT>') }
it { should contain_glance_api_config('rbd/rbd_store_ceph_conf').with_value('<SERVICE DEFAULT>') }
it { should contain_glance_api_config('rbd/rbd_store_chunk_size').with_value('<SERVICE DEFAULT>') }
it { should contain_glance_api_config('rbd/rados_connect_timeout').with_value('<SERVICE DEFAULT>')}
it { should contain_glance_api_config('rbd/rbd_store_user').with_value('<SERVICE DEFAULT>')}
it { should contain_package('python-ceph').with(
:name => platform_params[:pyceph_package_name],
:ensure => 'present'
)}
end
context 'when passing params' do
let :params do
{
:store_description => 'My rbd store',
:rbd_store_user => 'user',
:rbd_store_chunk_size => '2',
:package_ensure => 'latest',
:rados_connect_timeout => '30',
}
end
it { should contain_glance_api_config('rbd/store_description').with_value('My rbd store') }
it { should contain_glance_api_config('rbd/rbd_store_user').with_value('user') }
it { should contain_glance_api_config('rbd/rbd_store_chunk_size').with_value('2') }
it { should contain_glance_api_config('rbd/rados_connect_timeout').with_value('30')}
it { should contain_package('python-ceph').with(
:name => platform_params[:pyceph_package_name],
:ensure => 'latest'
)}
end
context 'when not managing packages' do
let :params do
{
:manage_packages => false,
}
end
it { should_not contain_package('python-ceph') }
end
end
shared_examples 'glance::backend::multistore::rbd on RedHat' do
context 'when el6' do
before do
facts.merge!( :operatingsystemrelease => '6.5' )
end
it { should contain_package('python-ceph').with(
:name => 'python-ceph',
:ensure => 'present'
)}
end
context 'when el7' do
before do
facts.merge!( :operatingsystemrelease => '7.0' )
end
it { should contain_package('python-ceph').with(
:name => 'python-rbd',
:ensure => 'present'
)}
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
let(:platform_params) do
case facts[:osfamily]
when 'Debian'
if facts[:os_package_type] == 'debian'
{ :pyceph_package_name => 'python3-ceph' }
else
{ :pyceph_package_name => 'python3-rbd' }
end
when 'RedHat'
{ :pyceph_package_name => 'python-rbd' }
end
end
it_behaves_like 'glance::backend::multistore::rbd'
if facts[:osfamily] == 'RedHat'
it_behaves_like 'glance::backend::multistore::rbd on RedHat'
end
end
end
end

112
spec/defines/glance_backend_multistore_swift_spec.rb

@ -0,0 +1,112 @@
#
# Copyright 2019 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# Unit tests for glance::backend::multistore::swift
#
require 'spec_helper'
describe 'glance::backend::multistore::swift' do
let (:title) { 'swift' }
shared_examples_for 'glance::backend::multistore::swift' do
let :params do
{
:swift_store_user => 'user',
:swift_store_key => 'key',
}
end
let :pre_condition do
'class { "glance::api::authtoken": password => "pass" }
include ::glance::api'
end
describe 'when default parameters' do
it { is_expected.to contain_class 'swift::client' }
it 'configures glance-api.conf' do
is_expected.to contain_glance_api_config('swift/store_description').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('swift/swift_store_large_object_size').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('swift/swift_store_large_object_chunk_size').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('swift/swift_store_container').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('swift/swift_store_create_container_on_put').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('swift/swift_store_endpoint_type').with_value('internalURL')
is_expected.to contain_glance_api_config('swift/swift_store_region').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('swift/swift_store_config_file').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('swift/default_swift_reference').with_value('ref1')
is_expected.to contain_glance_swift_config('ref1/key').with_value('key')
is_expected.to contain_glance_swift_config('ref1/user').with_value('user')
is_expected.to contain_glance_swift_config('ref1/auth_version').with_value('2')
is_expected.to contain_glance_swift_config('ref1/auth_address').with_value('http://127.0.0.1:5000/v3/')
is_expected.to contain_glance_swift_config('ref1/user_domain_id').with_value('default')
is_expected.to contain_glance_swift_config('ref1/project_domain_id').with_value('default')
end
end
describe 'when overriding parameters' do
let :params do
{
:store_description => 'My swift store',
:swift_store_user => 'user2',
:swift_store_key => 'key2',
:swift_store_auth_version => '1',
:swift_store_auth_project_domain_id => 'proj_domain',
:swift_store_auth_user_domain_id => 'user_domain',
:swift_store_large_object_size => '100',
:swift_store_large_object_chunk_size => '50',
:swift_store_auth_address => '127.0.0.2:8080/v1.0/',
:swift_store_container => 'swift',
:swift_store_create_container_on_put => true,
:swift_store_endpoint_type => 'publicURL',
:swift_store_region => 'RegionTwo',
:swift_store_config_file => '/etc/glance/glance-swift.conf',
:default_swift_reference => 'swift_creds',
}
end
it 'configures glance-api.conf' do
is_expected.to contain_glance_api_config('swift/store_description').with_value('My swift store')
is_expected.to contain_glance_api_config('swift/swift_store_container').with_value('swift')
is_expected.to contain_glance_api_config('swift/swift_store_create_container_on_put').with_value(true)
is_expected.to contain_glance_api_config('swift/swift_store_large_object_size').with_value('100')
is_expected.to contain_glance_api_config('swift/swift_store_large_object_chunk_size').with_value('50')
is_expected.to contain_glance_api_config('swift/swift_store_endpoint_type').with_value('publicURL')
is_expected.to contain_glance_api_config('swift/swift_store_region').with_value('RegionTwo')
is_expected.to contain_glance_api_config('swift/swift_store_config_file').with_value('/etc/glance/glance-swift.conf')
is_expected.to contain_glance_api_config('swift/default_swift_reference').with_value('swift_creds')
is_expected.to contain_glance_swift_config('swift_creds/key').with_value('key2')
is_expected.to contain_glance_swift_config('swift_creds/user').with_value('user2')
is_expected.to contain_glance_swift_config('swift_creds/auth_version').with_value('1')
is_expected.to contain_glance_swift_config('swift_creds/auth_address').with_value('127.0.0.2:8080/v1.0/')
is_expected.to contain_glance_swift_config('swift_creds/user_domain_id').with_value('user_domain')
is_expected.to contain_glance_swift_config('swift_creds/project_domain_id').with_value('proj_domain')
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::multistore::swift'
end
end
end

88
spec/defines/glance_backend_multistore_vsphere_spec.rb

@ -0,0 +1,88 @@
#
# Copyright 2019 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# Unit tests for glance::backend::multistore::vsphere
#
require 'spec_helper'
describe 'glance::backend::multistore::vsphere' do
let (:title) { 'vsphere' }
let :pre_condition do
'class { "glance::api::authtoken": password => "pass" }'
end
shared_examples_for 'glance::backend::multistore::vsphere' do
context 'when default parameters' do
let :params do
{