Introduce glance::db class
Another modules already implement a <component>::db class that is not implemented in Glance. This commit aims to apply here the same logic. Change-Id: Icd65a3303ccd512d5e34598d3e3a78bc924f8128
This commit is contained in:
parent
acd95e6a3a
commit
d6d4ddbe8f
|
@ -115,11 +115,32 @@
|
|||
#
|
||||
# [*database_connection*]
|
||||
# (optional) Connection url to connect to nova database.
|
||||
# Defaults to 'sqlite:///var/lib/glance/glance.sqlite'
|
||||
# Defaults to undef
|
||||
#
|
||||
# [*database_idle_timeout*]
|
||||
# (optional) Timeout before idle db connections are reaped.
|
||||
# Defaults to 3600
|
||||
# Defaults to undef
|
||||
#
|
||||
# [*database_max_retries*]
|
||||
# (Optional) Maximum number of database connection retries during startup.
|
||||
# Set to -1 to specify an infinite retry count.
|
||||
# Defaults to undef.
|
||||
#
|
||||
# [*database_retry_interval*]
|
||||
# (optional) Interval between retries of opening a database connection.
|
||||
# Defaults to undef.
|
||||
#
|
||||
# [*database_min_pool_size*]
|
||||
# (optional) Minimum number of SQL connections to keep open in a pool.
|
||||
# Defaults to undef.
|
||||
#
|
||||
# [*database_max_pool_size*]
|
||||
# (optional) Maximum number of SQL connections to keep open in a pool.
|
||||
# Defaults to undef.
|
||||
#
|
||||
# [*database_max_overflow*]
|
||||
# (optional) If set, use this value for max_overflow with sqlalchemy.
|
||||
# Defaults to undef.
|
||||
#
|
||||
# [*use_syslog*]
|
||||
# (optional) Use syslog for logging.
|
||||
|
@ -219,8 +240,13 @@ class glance::api(
|
|||
$key_file = false,
|
||||
$ca_file = false,
|
||||
$known_stores = false,
|
||||
$database_connection = 'sqlite:///var/lib/glance/glance.sqlite',
|
||||
$database_idle_timeout = 3600,
|
||||
$database_connection = undef,
|
||||
$database_idle_timeout = undef,
|
||||
$database_min_pool_size = undef,
|
||||
$database_max_pool_size = undef,
|
||||
$database_max_retries = undef,
|
||||
$database_retry_interval = undef,
|
||||
$database_max_overflow = undef,
|
||||
$image_cache_dir = '/var/lib/glance/image-cache',
|
||||
$os_region_name = 'RegionOne',
|
||||
$validate = false,
|
||||
|
@ -234,6 +260,7 @@ class glance::api(
|
|||
) inherits glance {
|
||||
|
||||
include ::glance::policy
|
||||
include ::glance::api::db
|
||||
include ::glance::api::logging
|
||||
require keystone::python
|
||||
|
||||
|
@ -265,23 +292,6 @@ class glance::api(
|
|||
require => Class['glance']
|
||||
}
|
||||
|
||||
if $database_connection {
|
||||
if($database_connection =~ /mysql:\/\/\S+:\S+@\S+\/\S+/) {
|
||||
require 'mysql::bindings'
|
||||
require 'mysql::bindings::python'
|
||||
} elsif($database_connection =~ /postgresql:\/\/\S+:\S+@\S+\/\S+/) {
|
||||
|
||||
} elsif($database_connection =~ /sqlite:\/\//) {
|
||||
|
||||
} else {
|
||||
fail("Invalid db connection ${database_connection}")
|
||||
}
|
||||
glance_api_config {
|
||||
'database/connection': value => $database_connection, secret => true;
|
||||
'database/idle_timeout': value => $database_idle_timeout;
|
||||
}
|
||||
}
|
||||
|
||||
# basic service config
|
||||
glance_api_config {
|
||||
'DEFAULT/bind_host': value => $bind_host;
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
# == Class: glance::api::db
|
||||
#
|
||||
# Configure the Glance database
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*database_connection*]
|
||||
# Url used to connect to database.
|
||||
# (Optional) Defaults to 'sqlite:///var/lib/glance/glance.sqlite'.
|
||||
#
|
||||
# [*database_idle_timeout*]
|
||||
# Timeout when db connections should be reaped.
|
||||
# (Optional) Defaults to $::os_service_default.
|
||||
#
|
||||
# [*database_min_pool_size*]
|
||||
# Minimum number of SQL connections to keep open in a pool.
|
||||
# (Optional) Defaults to $::os_service_default.
|
||||
#
|
||||
# [*database_max_pool_size*]
|
||||
# Maximum number of SQL connections to keep open in a pool.
|
||||
# (Optional) Defaults to $::os_service_default.
|
||||
#
|
||||
# [*database_max_retries*]
|
||||
# Maximum db connection retries during startup.
|
||||
# Setting -1 implies an infinite retry count.
|
||||
# (Optional) Defaults to $::os_service_default.
|
||||
#
|
||||
# [*database_retry_interval*]
|
||||
# Interval between retries of opening a sql connection.
|
||||
# (Optional) Defaults to $::os_service_default.
|
||||
#
|
||||
# [*database_max_overflow*]
|
||||
# If set, use this value for max_overflow with sqlalchemy.
|
||||
# (Optional) Defaults to $::os_service_default.
|
||||
#
|
||||
class glance::api::db (
|
||||
$database_connection = 'sqlite:///var/lib/glance/glance.sqlite',
|
||||
$database_idle_timeout = $::os_service_default,
|
||||
$database_min_pool_size = $::os_service_default,
|
||||
$database_max_pool_size = $::os_service_default,
|
||||
$database_max_retries = $::os_service_default,
|
||||
$database_retry_interval = $::os_service_default,
|
||||
$database_max_overflow = $::os_service_default,
|
||||
) {
|
||||
|
||||
# NOTE(degorenko): In order to keep backward compatibility we rely on the pick function
|
||||
# to use glance::api::<myparam> if glance::api::db::<myparam> isn't specified.
|
||||
$database_connection_real = pick($::glance::api::database_connection, $database_connection)
|
||||
$database_idle_timeout_real = pick($::glance::api::database_idle_timeout, $database_idle_timeout)
|
||||
$database_min_pool_size_real = pick($::glance::api::database_min_pool_size, $database_min_pool_size)
|
||||
$database_max_pool_size_real = pick($::glance::api::database_max_pool_size, $database_max_pool_size)
|
||||
$database_max_retries_real = pick($::glance::api::database_max_retries, $database_max_retries)
|
||||
$database_retry_interval_real = pick($::glance::api::database_retry_interval, $database_retry_interval)
|
||||
$database_max_overflow_real = pick($::glance::api::database_max_overflow, $database_max_overflow)
|
||||
|
||||
validate_re($database_connection_real,
|
||||
'(sqlite|mysql|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
|
||||
|
||||
case $database_connection_real {
|
||||
/^mysql:\/\//: {
|
||||
$backend_package = false
|
||||
require 'mysql::bindings'
|
||||
require 'mysql::bindings::python'
|
||||
}
|
||||
/^postgresql:\/\//: {
|
||||
$backend_package = false
|
||||
require 'postgresql::lib::python'
|
||||
}
|
||||
/^sqlite:\/\//: {
|
||||
$backend_package = $::glance::params::sqlite_package_name
|
||||
}
|
||||
default: {
|
||||
fail('Unsupported backend configured')
|
||||
}
|
||||
}
|
||||
|
||||
if $backend_package and !defined(Package[$backend_package]) {
|
||||
package {'glance-backend-package':
|
||||
ensure => present,
|
||||
name => $backend_package,
|
||||
tag => 'openstack',
|
||||
}
|
||||
}
|
||||
|
||||
glance_api_config {
|
||||
'database/connection': value => $database_connection_real, secret => true;
|
||||
'database/idle_timeout': value => $database_idle_timeout_real;
|
||||
'database/min_pool_size': value => $database_min_pool_size_real;
|
||||
'database/max_retries': value => $database_max_retries_real;
|
||||
'database/retry_interval': value => $database_retry_interval_real;
|
||||
'database/max_pool_size': value => $database_max_pool_size_real;
|
||||
'database/max_overflow': value => $database_max_overflow_real;
|
||||
}
|
||||
|
||||
}
|
|
@ -19,6 +19,7 @@ class glance::params {
|
|||
} else {
|
||||
$pyceph_package_name = 'python-rbd'
|
||||
}
|
||||
$sqlite_package_name = undef
|
||||
}
|
||||
'Debian': {
|
||||
$api_package_name = 'glance-api'
|
||||
|
@ -27,6 +28,7 @@ class glance::params {
|
|||
$registry_service_name = 'glance-registry'
|
||||
$db_sync_command = 'glance-manage --config-file=/etc/glance/glance-registry.conf db_sync'
|
||||
$pyceph_package_name = 'python-ceph'
|
||||
$sqlite_package_name = 'python-pysqlite2'
|
||||
}
|
||||
default: {
|
||||
fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, module ${module_name} only support osfamily RedHat and Debian")
|
||||
|
|
|
@ -39,13 +39,34 @@
|
|||
# If set to boolean false, it will not log to any directory.
|
||||
# Defaults to undef.
|
||||
#
|
||||
# [*database_connection*]
|
||||
# (optional) Connection url to connect to nova database.
|
||||
# Defaults to 'sqlite:///var/lib/glance/glance.sqlite'
|
||||
# [*database_connection*]
|
||||
# (optional) Connection url to connect to nova database.
|
||||
# Defaults to undef
|
||||
#
|
||||
# [*database_idle_timeout*]
|
||||
# (optional) Timeout before idle db connections are reaped.
|
||||
# Defaults to 3600
|
||||
# [*database_idle_timeout*]
|
||||
# (optional) Timeout before idle db connections are reaped.
|
||||
# Defaults to undef
|
||||
#
|
||||
# [*database_max_retries*]
|
||||
# (Optional) Maximum number of database connection retries during startup.
|
||||
# Set to -1 to specify an infinite retry count.
|
||||
# Defaults to undef.
|
||||
#
|
||||
# [*database_retry_interval*]
|
||||
# (optional) Interval between retries of opening a database connection.
|
||||
# Defaults to undef.
|
||||
#
|
||||
# [*database_min_pool_size*]
|
||||
# (optional) Minimum number of SQL connections to keep open in a pool.
|
||||
# Defaults to undef.
|
||||
#
|
||||
# [*database_max_pool_size*]
|
||||
# (optional) Maximum number of SQL connections to keep open in a pool.
|
||||
# Defaults to undef.
|
||||
#
|
||||
# [*database_max_overflow*]
|
||||
# (optional) If set, use this value for max_overflow with sqlalchemy.
|
||||
# Defaults to undef.
|
||||
#
|
||||
# [*auth_type*]
|
||||
# (optional) Authentication type. Defaults to 'keystone'.
|
||||
|
@ -130,32 +151,37 @@
|
|||
#
|
||||
class glance::registry(
|
||||
$keystone_password,
|
||||
$package_ensure = 'present',
|
||||
$verbose = undef,
|
||||
$debug = undef,
|
||||
$bind_host = '0.0.0.0',
|
||||
$bind_port = '9191',
|
||||
$workers = $::processorcount,
|
||||
$log_file = undef,
|
||||
$log_dir = undef,
|
||||
$database_connection = 'sqlite:///var/lib/glance/glance.sqlite',
|
||||
$database_idle_timeout = 3600,
|
||||
$auth_type = 'keystone',
|
||||
$auth_uri = false,
|
||||
$identity_uri = false,
|
||||
$keystone_tenant = 'services',
|
||||
$keystone_user = 'glance',
|
||||
$pipeline = 'keystone',
|
||||
$use_syslog = undef,
|
||||
$use_stderr = undef,
|
||||
$log_facility = undef,
|
||||
$manage_service = true,
|
||||
$enabled = true,
|
||||
$purge_config = false,
|
||||
$cert_file = false,
|
||||
$key_file = false,
|
||||
$ca_file = false,
|
||||
$sync_db = true,
|
||||
$package_ensure = 'present',
|
||||
$verbose = undef,
|
||||
$debug = undef,
|
||||
$bind_host = '0.0.0.0',
|
||||
$bind_port = '9191',
|
||||
$workers = $::processorcount,
|
||||
$log_file = undef,
|
||||
$log_dir = undef,
|
||||
$database_connection = undef,
|
||||
$database_idle_timeout = undef,
|
||||
$database_min_pool_size = undef,
|
||||
$database_max_pool_size = undef,
|
||||
$database_max_retries = undef,
|
||||
$database_retry_interval = undef,
|
||||
$database_max_overflow = undef,
|
||||
$auth_type = 'keystone',
|
||||
$auth_uri = false,
|
||||
$identity_uri = false,
|
||||
$keystone_tenant = 'services',
|
||||
$keystone_user = 'glance',
|
||||
$pipeline = 'keystone',
|
||||
$use_syslog = undef,
|
||||
$use_stderr = undef,
|
||||
$log_facility = undef,
|
||||
$manage_service = true,
|
||||
$enabled = true,
|
||||
$purge_config = false,
|
||||
$cert_file = false,
|
||||
$key_file = false,
|
||||
$ca_file = false,
|
||||
$sync_db = true,
|
||||
# DEPRECATED PARAMETERS
|
||||
$auth_host = '127.0.0.1',
|
||||
$auth_port = '35357',
|
||||
|
@ -164,6 +190,7 @@ class glance::registry(
|
|||
) inherits glance {
|
||||
|
||||
include ::glance::registry::logging
|
||||
include ::glance::registry::db
|
||||
require keystone::python
|
||||
|
||||
if ( $glance::params::api_package_name != $glance::params::registry_package_name ) {
|
||||
|
@ -188,23 +215,6 @@ class glance::registry(
|
|||
require => Class['glance']
|
||||
}
|
||||
|
||||
if $database_connection {
|
||||
if($database_connection =~ /mysql:\/\/\S+:\S+@\S+\/\S+/) {
|
||||
require 'mysql::bindings'
|
||||
require 'mysql::bindings::python'
|
||||
} elsif($database_connection =~ /postgresql:\/\/\S+:\S+@\S+\/\S+/) {
|
||||
|
||||
} elsif($database_connection =~ /sqlite:\/\//) {
|
||||
|
||||
} else {
|
||||
fail("Invalid db connection ${database_connection}")
|
||||
}
|
||||
glance_registry_config {
|
||||
'database/connection': value => $database_connection, secret => true;
|
||||
'database/idle_timeout': value => $database_idle_timeout;
|
||||
}
|
||||
}
|
||||
|
||||
glance_registry_config {
|
||||
'DEFAULT/workers': value => $workers;
|
||||
'DEFAULT/bind_host': value => $bind_host;
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
# == Class: glance::registry::db
|
||||
#
|
||||
# Configure the Glance database
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*database_connection*]
|
||||
# Url used to connect to database.
|
||||
# (Optional) Defaults to 'sqlite:///var/lib/glance/glance.sqlite'.
|
||||
#
|
||||
# [*database_idle_timeout*]
|
||||
# Timeout when db connections should be reaped.
|
||||
# (Optional) Defaults to $::os_service_default.
|
||||
#
|
||||
# [*database_min_pool_size*]
|
||||
# Minimum number of SQL connections to keep open in a pool.
|
||||
# (Optional) Defaults to $::os_service_default.
|
||||
#
|
||||
# [*database_max_pool_size*]
|
||||
# Maximum number of SQL connections to keep open in a pool.
|
||||
# (Optional) Defaults to $::os_service_default.
|
||||
#
|
||||
# [*database_max_retries*]
|
||||
# Maximum db connection retries during startup.
|
||||
# Setting -1 implies an infinite retry count.
|
||||
# (Optional) Defaults to $::os_service_default.
|
||||
#
|
||||
# [*database_retry_interval*]
|
||||
# Interval between retries of opening a sql connection.
|
||||
# (Optional) Defaults to $::os_service_default.
|
||||
#
|
||||
# [*database_max_overflow*]
|
||||
# If set, use this value for max_overflow with sqlalchemy.
|
||||
# (Optional) Defaults to $::os_service_default.
|
||||
#
|
||||
class glance::registry::db (
|
||||
$database_connection = 'sqlite:///var/lib/glance/glance.sqlite',
|
||||
$database_idle_timeout = $::os_service_default,
|
||||
$database_min_pool_size = $::os_service_default,
|
||||
$database_max_pool_size = $::os_service_default,
|
||||
$database_max_retries = $::os_service_default,
|
||||
$database_retry_interval = $::os_service_default,
|
||||
$database_max_overflow = $::os_service_default,
|
||||
) {
|
||||
|
||||
# NOTE(degorenko): In order to keep backward compatibility we rely on the pick function
|
||||
# to use glance::registry::<myparam> if glance::registry::db::<myparam> isn't specified.
|
||||
$database_connection_real = pick($::glance::registry::database_connection, $database_connection)
|
||||
$database_idle_timeout_real = pick($::glance::registry::database_idle_timeout, $database_idle_timeout)
|
||||
$database_min_pool_size_real = pick($::glance::registry::database_min_pool_size, $database_min_pool_size)
|
||||
$database_max_pool_size_real = pick($::glance::registry::database_max_pool_size, $database_max_pool_size)
|
||||
$database_max_retries_real = pick($::glance::registry::database_max_retries, $database_max_retries)
|
||||
$database_retry_interval_real = pick($::glance::registry::database_retry_interval, $database_retry_interval)
|
||||
$database_max_overflow_real = pick($::glance::registry::database_max_overflow, $database_max_overflow)
|
||||
|
||||
validate_re($database_connection_real,
|
||||
'(sqlite|mysql|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
|
||||
|
||||
case $database_connection_real {
|
||||
/^mysql:\/\//: {
|
||||
$backend_package = false
|
||||
require 'mysql::bindings'
|
||||
require 'mysql::bindings::python'
|
||||
}
|
||||
/^postgresql:\/\//: {
|
||||
$backend_package = false
|
||||
require 'postgresql::lib::python'
|
||||
}
|
||||
/^sqlite:\/\//: {
|
||||
$backend_package = $::glance::params::sqlite_package_name
|
||||
}
|
||||
default: {
|
||||
fail('Unsupported backend configured')
|
||||
}
|
||||
}
|
||||
|
||||
if $backend_package and !defined(Package[$backend_package]) {
|
||||
package {'glance-backend-package':
|
||||
ensure => present,
|
||||
name => $backend_package,
|
||||
tag => 'openstack',
|
||||
}
|
||||
}
|
||||
|
||||
glance_registry_config {
|
||||
'database/connection': value => $database_connection_real, secret => true;
|
||||
'database/idle_timeout': value => $database_idle_timeout_real;
|
||||
'database/min_pool_size': value => $database_min_pool_size_real;
|
||||
'database/max_retries': value => $database_max_retries_real;
|
||||
'database/retry_interval': value => $database_retry_interval_real;
|
||||
'database/max_pool_size': value => $database_max_pool_size_real;
|
||||
'database/max_overflow': value => $database_max_overflow_real;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'glance::api::db' do
|
||||
|
||||
shared_examples 'glance::api::db' do
|
||||
context 'with default parameters' do
|
||||
it { is_expected.to contain_glance_api_config('database/connection').with_value('sqlite:///var/lib/glance/glance.sqlite').with_secret(true) }
|
||||
it { is_expected.to contain_glance_api_config('database/idle_timeout').with_value('<SERVICE DEFAULT>') }
|
||||
it { is_expected.to contain_glance_api_config('database/min_pool_size').with_value('<SERVICE DEFAULT>') }
|
||||
it { is_expected.to contain_glance_api_config('database/max_retries').with_value('<SERVICE DEFAULT>') }
|
||||
it { is_expected.to contain_glance_api_config('database/retry_interval').with_value('<SERVICE DEFAULT>') }
|
||||
it { is_expected.to contain_glance_api_config('database/max_pool_size').with_value('<SERVICE DEFAULT>') }
|
||||
it { is_expected.to contain_glance_api_config('database/max_overflow').with_value('<SERVICE DEFAULT>') }
|
||||
end
|
||||
|
||||
context 'with specific parameters' do
|
||||
let :params do
|
||||
{ :database_connection => 'mysql://glance_api:glance@localhost/glance',
|
||||
:database_idle_timeout => '3601',
|
||||
:database_min_pool_size => '2',
|
||||
:database_max_retries => '11',
|
||||
:database_retry_interval => '11',
|
||||
:database_max_pool_size => '11',
|
||||
:database_max_overflow => '21',
|
||||
}
|
||||
end
|
||||
|
||||
it { is_expected.to contain_glance_api_config('database/connection').with_value('mysql://glance_api:glance@localhost/glance').with_secret(true) }
|
||||
it { is_expected.to contain_glance_api_config('database/idle_timeout').with_value('3601') }
|
||||
it { is_expected.to contain_glance_api_config('database/min_pool_size').with_value('2') }
|
||||
it { is_expected.to contain_glance_api_config('database/max_retries').with_value('11') }
|
||||
it { is_expected.to contain_glance_api_config('database/retry_interval').with_value('11') }
|
||||
it { is_expected.to contain_glance_api_config('database/max_pool_size').with_value('11') }
|
||||
it { is_expected.to contain_glance_api_config('database/max_overflow').with_value('21') }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
@default_facts.merge({ :osfamily => 'Debian' })
|
||||
end
|
||||
|
||||
it_configures 'glance::api::db'
|
||||
end
|
||||
|
||||
context 'on Redhat platforms' do
|
||||
let :facts do
|
||||
@default_facts.merge({ :osfamily => 'RedHat' })
|
||||
end
|
||||
|
||||
it_configures 'glance::api::db'
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -32,8 +32,6 @@ describe 'glance::api' do
|
|||
:keystone_tenant => 'services',
|
||||
:keystone_user => 'glance',
|
||||
:keystone_password => 'ChangeMe',
|
||||
:database_idle_timeout => '3600',
|
||||
:database_connection => 'sqlite:///var/lib/glance/glance.sqlite',
|
||||
:show_image_direct_url => false,
|
||||
:purge_config => false,
|
||||
:known_stores => false,
|
||||
|
@ -62,8 +60,6 @@ describe 'glance::api' do
|
|||
:keystone_tenant => 'admin2',
|
||||
:keystone_user => 'admin2',
|
||||
:keystone_password => 'ChangeMe2',
|
||||
:database_idle_timeout => '36002',
|
||||
:database_connection => 'mysql:///var:lib@glance/glance',
|
||||
:show_image_direct_url => true,
|
||||
:image_cache_dir => '/tmp/glance',
|
||||
:os_region_name => 'RegionOne2',
|
||||
|
@ -84,6 +80,7 @@ describe 'glance::api' do
|
|||
it { is_expected.to contain_class 'glance' }
|
||||
it { is_expected.to contain_class 'glance::policy' }
|
||||
it { is_expected.to contain_class 'glance::api::logging' }
|
||||
it { is_expected.to contain_class 'glance::api::db' }
|
||||
|
||||
it { is_expected.to contain_service('glance-api').with(
|
||||
'ensure' => (param_hash[:manage_service] && param_hash[:enabled]) ? 'running': 'stopped',
|
||||
|
@ -128,12 +125,6 @@ describe 'glance::api' do
|
|||
end
|
||||
end
|
||||
|
||||
it 'is_expected.to config db' do
|
||||
is_expected.to contain_glance_api_config('database/connection').with_value(param_hash[:database_connection])
|
||||
is_expected.to contain_glance_api_config('database/connection').with_value(param_hash[:database_connection]).with_secret(true)
|
||||
is_expected.to contain_glance_api_config('database/idle_timeout').with_value(param_hash[:database_idle_timeout])
|
||||
end
|
||||
|
||||
it 'is_expected.to have no ssl options' do
|
||||
is_expected.to contain_glance_api_config('DEFAULT/ca_file').with_ensure('absent')
|
||||
is_expected.to contain_glance_api_config('DEFAULT/cert_file').with_ensure('absent')
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'glance::registry::db' do
|
||||
|
||||
shared_examples 'glance::registry::db' do
|
||||
context 'with default parameters' do
|
||||
it { is_expected.to contain_glance_registry_config('database/connection').with_value('sqlite:///var/lib/glance/glance.sqlite').with_secret(true) }
|
||||
it { is_expected.to contain_glance_registry_config('database/idle_timeout').with_value('<SERVICE DEFAULT>') }
|
||||
it { is_expected.to contain_glance_registry_config('database/min_pool_size').with_value('<SERVICE DEFAULT>') }
|
||||
it { is_expected.to contain_glance_registry_config('database/max_retries').with_value('<SERVICE DEFAULT>') }
|
||||
it { is_expected.to contain_glance_registry_config('database/retry_interval').with_value('<SERVICE DEFAULT>') }
|
||||
it { is_expected.to contain_glance_registry_config('database/max_pool_size').with_value('<SERVICE DEFAULT>') }
|
||||
it { is_expected.to contain_glance_registry_config('database/max_overflow').with_value('<SERVICE DEFAULT>') }
|
||||
end
|
||||
|
||||
context 'with specific parameters' do
|
||||
let :params do
|
||||
{ :database_connection => 'mysql://glance_registry:glance@localhost/glance',
|
||||
:database_idle_timeout => '3601',
|
||||
:database_min_pool_size => '2',
|
||||
:database_max_retries => '11',
|
||||
:database_retry_interval => '11',
|
||||
:database_max_pool_size => '11',
|
||||
:database_max_overflow => '21',
|
||||
}
|
||||
end
|
||||
|
||||
it { is_expected.to contain_glance_registry_config('database/connection').with_value('mysql://glance_registry:glance@localhost/glance').with_secret(true) }
|
||||
it { is_expected.to contain_glance_registry_config('database/idle_timeout').with_value('3601') }
|
||||
it { is_expected.to contain_glance_registry_config('database/min_pool_size').with_value('2') }
|
||||
it { is_expected.to contain_glance_registry_config('database/max_retries').with_value('11') }
|
||||
it { is_expected.to contain_glance_registry_config('database/retry_interval').with_value('11') }
|
||||
it { is_expected.to contain_glance_registry_config('database/max_pool_size').with_value('11') }
|
||||
it { is_expected.to contain_glance_registry_config('database/max_overflow').with_value('21') }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
@default_facts.merge({ :osfamily => 'Debian' })
|
||||
end
|
||||
|
||||
it_configures 'glance::registry::db'
|
||||
end
|
||||
|
||||
context 'on Redhat platforms' do
|
||||
let :facts do
|
||||
@default_facts.merge({ :osfamily => 'RedHat' })
|
||||
end
|
||||
|
||||
it_configures 'glance::registry::db'
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -18,8 +18,6 @@ describe 'glance::registry' do
|
|||
:workers => facts[:processorcount],
|
||||
:log_file => '/var/log/glance/registry.log',
|
||||
:log_dir => '/var/log/glance',
|
||||
:database_connection => 'sqlite:///var/lib/glance/glance.sqlite',
|
||||
:database_idle_timeout => '3600',
|
||||
:enabled => true,
|
||||
:manage_service => true,
|
||||
:auth_type => 'keystone',
|
||||
|
@ -41,8 +39,6 @@ describe 'glance::registry' do
|
|||
:bind_host => '127.0.0.1',
|
||||
:bind_port => '9111',
|
||||
:workers => '5',
|
||||
:database_connection => 'sqlite:///var/lib/glance.sqlite',
|
||||
:database_idle_timeout => '360',
|
||||
:enabled => false,
|
||||
:auth_type => 'keystone',
|
||||
:auth_host => '127.0.0.1',
|
||||
|
@ -66,6 +62,7 @@ describe 'glance::registry' do
|
|||
end
|
||||
|
||||
it { is_expected.to contain_class 'glance::registry' }
|
||||
it { is_expected.to contain_class 'glance::registry::db' }
|
||||
it { is_expected.to contain_class 'glance::registry::logging' }
|
||||
|
||||
it { is_expected.to contain_service('glance-registry').with(
|
||||
|
@ -92,12 +89,6 @@ describe 'glance::registry' do
|
|||
].each do |config|
|
||||
is_expected.to contain_glance_registry_config("DEFAULT/#{config}").with_value(param_hash[config.intern])
|
||||
end
|
||||
[
|
||||
'database_connection',
|
||||
'database_idle_timeout',
|
||||
].each do |config|
|
||||
is_expected.to contain_glance_registry_config("database/#{config.gsub(/database_/,'')}").with_value(param_hash[config.intern])
|
||||
end
|
||||
[
|
||||
'auth_host',
|
||||
'auth_port',
|
||||
|
|
Loading…
Reference in New Issue