Deprecate old SQL parameters
SQL configuration has changed in Havana.
This patch aims to deprecate old parameters and configure using the
right way.
Change-Id: I6a800d51294ae23636636a8d1c6ccad192f45d4e
Signed-off-by: Emilien Macchi <emilien.macchi@enovance.com>
(cherry picked from commit 8156a87cd0
)
This commit is contained in:
parent
6e19b58e38
commit
a9c745ea77
|
@ -97,13 +97,20 @@
|
|||
# Defaults to true.
|
||||
#
|
||||
# [*sql_idle_timeout*]
|
||||
# (optional) Period in seconds after which SQLAlchemy should reestablish its connection
|
||||
# to the database.
|
||||
# Defaults to '3600'.
|
||||
# (optional) Deprecated. Use database_idle_timeout instead
|
||||
# Defaults to false
|
||||
#
|
||||
# [*sql_connection*]
|
||||
# (optional) Database connection.
|
||||
# Defaults to 'sqlite:///var/lib/glance/glance.sqlite'.
|
||||
# (optional) Deprecated. Use database_connection instead.
|
||||
# Defaults to false
|
||||
#
|
||||
# [*database_connection*]
|
||||
# (optional) Connection url to connect to nova database.
|
||||
# Defaults to 'sqlite:///var/lib/glance/glance.sqlite'
|
||||
#
|
||||
# [*database_idle_timeout*]
|
||||
# (optional) Timeout before idle db connections are reaped.
|
||||
# Defaults to 3600
|
||||
#
|
||||
# [*use_syslog*]
|
||||
# (optional) Use syslog for logging.
|
||||
|
@ -172,8 +179,6 @@ class glance::api(
|
|||
$keystone_tenant = 'services',
|
||||
$keystone_user = 'glance',
|
||||
$enabled = true,
|
||||
$sql_idle_timeout = '3600',
|
||||
$sql_connection = 'sqlite:///var/lib/glance/glance.sqlite',
|
||||
$use_syslog = false,
|
||||
$log_facility = 'LOG_USER',
|
||||
$show_image_direct_url = false,
|
||||
|
@ -183,13 +188,16 @@ class glance::api(
|
|||
$ca_file = false,
|
||||
$mysql_module = '0.9',
|
||||
$known_stores = false,
|
||||
$database_connection = 'sqlite:///var/lib/glance/glance.sqlite',
|
||||
$database_idle_timeout = 3600,
|
||||
$image_cache_dir = '/var/lib/glance/image-cache',
|
||||
# DEPRECATED PARAMETERS
|
||||
$sql_idle_timeout = false,
|
||||
$sql_connection = false,
|
||||
) inherits glance {
|
||||
|
||||
require keystone::python
|
||||
|
||||
validate_re($sql_connection, '(sqlite|mysql|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
|
||||
|
||||
if ( $glance::params::api_package_name != $glance::params::registry_package_name ) {
|
||||
ensure_packages([$glance::params::api_package_name])
|
||||
}
|
||||
|
@ -214,19 +222,39 @@ class glance::api(
|
|||
require => Class['glance'],
|
||||
}
|
||||
|
||||
if($sql_connection =~ /mysql:\/\/\S+:\S+@\S+\/\S+/) {
|
||||
if ($mysql_module >= 2.2) {
|
||||
require 'mysql::bindings'
|
||||
require 'mysql::bindings::python'
|
||||
} else {
|
||||
require 'mysql::python'
|
||||
}
|
||||
} elsif($sql_connection =~ /postgresql:\/\/\S+:\S+@\S+\/\S+/) {
|
||||
|
||||
} elsif($sql_connection =~ /sqlite:\/\//) {
|
||||
|
||||
if $sql_connection {
|
||||
warning('The sql_connection parameter is deprecated, use database_connection instead.')
|
||||
$database_connection_real = $sql_connection
|
||||
} else {
|
||||
fail("Invalid db connection ${sql_connection}")
|
||||
$database_connection_real = $database_connection
|
||||
}
|
||||
|
||||
if $sql_idle_timeout {
|
||||
warning('The sql_idle_timeout parameter is deprecated, use database_idle_timeout instead.')
|
||||
$database_idle_timeout_real = $sql_idle_timeout
|
||||
} else {
|
||||
$database_idle_timeout_real = $database_idle_timeout
|
||||
}
|
||||
|
||||
if $database_connection_real {
|
||||
if($database_connection_real =~ /mysql:\/\/\S+:\S+@\S+\/\S+/) {
|
||||
if ($mysql_module >= 2.2) {
|
||||
require 'mysql::bindings'
|
||||
require 'mysql::bindings::python'
|
||||
} else {
|
||||
require 'mysql::python'
|
||||
}
|
||||
} elsif($database_connection_real =~ /postgresql:\/\/\S+:\S+@\S+\/\S+/) {
|
||||
|
||||
} elsif($database_connection_real =~ /sqlite:\/\//) {
|
||||
|
||||
} else {
|
||||
fail("Invalid db connection ${database_connection_real}")
|
||||
}
|
||||
glance_api_config {
|
||||
'database/connection': value => $database_connection_real;
|
||||
'database/idle_timeout': value => $database_idle_timeout_real;
|
||||
}
|
||||
}
|
||||
|
||||
# basic service config
|
||||
|
@ -268,15 +296,6 @@ class glance::api(
|
|||
'DEFAULT/registry_port': value => $registry_port;
|
||||
}
|
||||
|
||||
# db connection config
|
||||
# I do not believe this was required in Essex.
|
||||
# Does the API server now need to connect to the DB?
|
||||
# TODO figure out if I need this...
|
||||
glance_api_config {
|
||||
'DEFAULT/sql_connection': value => $sql_connection;
|
||||
'DEFAULT/sql_idle_timeout': value => $sql_idle_timeout;
|
||||
}
|
||||
|
||||
if $auth_uri {
|
||||
glance_api_config { 'keystone_authtoken/auth_uri': value => $auth_uri; }
|
||||
} else {
|
||||
|
|
|
@ -29,12 +29,21 @@
|
|||
# If set to boolean false, it will not log to any directory.
|
||||
# Defaults to '/var/log/glance'
|
||||
#
|
||||
# [*sql_connection*]
|
||||
# (optional) SQL connection string.
|
||||
# Defaults to 'sqlite:///var/lib/glance/glance.sqlite'.
|
||||
# [*sql_idle_timeout*]
|
||||
# (optional) Deprecated. Use database_idle_timeout instead
|
||||
# Defaults to false
|
||||
#
|
||||
# [*sql_idle_timeout*]
|
||||
# (optional) SQL connections idle timeout. Defaults to '3600'.
|
||||
# [*sql_connection*]
|
||||
# (optional) Deprecated. Use database_connection instead.
|
||||
# Defaults to false
|
||||
#
|
||||
# [*database_connection*]
|
||||
# (optional) Connection url to connect to nova database.
|
||||
# Defaults to 'sqlite:///var/lib/glance/glance.sqlite'
|
||||
#
|
||||
# [*database_idle_timeout*]
|
||||
# (optional) Timeout before idle db connections are reaped.
|
||||
# Defaults to 3600
|
||||
#
|
||||
# [*auth_type*]
|
||||
# (optional) Authentication type. Defaults to 'keystone'.
|
||||
|
@ -102,37 +111,38 @@
|
|||
#
|
||||
class glance::registry(
|
||||
$keystone_password,
|
||||
$verbose = false,
|
||||
$debug = false,
|
||||
$bind_host = '0.0.0.0',
|
||||
$bind_port = '9191',
|
||||
$log_file = '/var/log/glance/registry.log',
|
||||
$log_dir = '/var/log/glance',
|
||||
$sql_connection = 'sqlite:///var/lib/glance/glance.sqlite',
|
||||
$sql_idle_timeout = '3600',
|
||||
$auth_type = 'keystone',
|
||||
$auth_host = '127.0.0.1',
|
||||
$auth_port = '35357',
|
||||
$auth_admin_prefix = false,
|
||||
$auth_uri = false,
|
||||
$auth_protocol = 'http',
|
||||
$keystone_tenant = 'services',
|
||||
$keystone_user = 'glance',
|
||||
$pipeline = 'keystone',
|
||||
$use_syslog = false,
|
||||
$log_facility = 'LOG_USER',
|
||||
$enabled = true,
|
||||
$purge_config = false,
|
||||
$cert_file = false,
|
||||
$key_file = false,
|
||||
$ca_file = false,
|
||||
$mysql_module = '0.9',
|
||||
$verbose = false,
|
||||
$debug = false,
|
||||
$bind_host = '0.0.0.0',
|
||||
$bind_port = '9191',
|
||||
$log_file = '/var/log/glance/registry.log',
|
||||
$log_dir = '/var/log/glance',
|
||||
$database_connection = 'sqlite:///var/lib/glance/glance.sqlite',
|
||||
$database_idle_timeout = 3600,
|
||||
$auth_type = 'keystone',
|
||||
$auth_host = '127.0.0.1',
|
||||
$auth_port = '35357',
|
||||
$auth_admin_prefix = false,
|
||||
$auth_uri = false,
|
||||
$auth_protocol = 'http',
|
||||
$keystone_tenant = 'services',
|
||||
$keystone_user = 'glance',
|
||||
$pipeline = 'keystone',
|
||||
$use_syslog = false,
|
||||
$log_facility = 'LOG_USER',
|
||||
$enabled = true,
|
||||
$purge_config = false,
|
||||
$cert_file = false,
|
||||
$key_file = false,
|
||||
$ca_file = false,
|
||||
$mysql_module = '0.9',
|
||||
# DEPRECATED PARAMETERS
|
||||
$sql_idle_timeout = false,
|
||||
$sql_connection = false,
|
||||
) inherits glance {
|
||||
|
||||
require keystone::python
|
||||
|
||||
validate_re($sql_connection, '(sqlite|mysql|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
|
||||
|
||||
if ( $glance::params::api_package_name != $glance::params::registry_package_name ) {
|
||||
ensure_packages([$glance::params::registry_package_name])
|
||||
}
|
||||
|
@ -151,18 +161,39 @@ class glance::registry(
|
|||
require => Class['glance']
|
||||
}
|
||||
|
||||
if($sql_connection =~ /mysql:\/\/\S+:\S+@\S+\/\S+/) {
|
||||
if ($mysql_module >= 2.2) {
|
||||
require mysql::bindings::python
|
||||
} else {
|
||||
require mysql::python
|
||||
}
|
||||
} elsif($sql_connection =~ /postgresql:\/\/\S+:\S+@\S+\/\S+/) {
|
||||
|
||||
} elsif($sql_connection =~ /sqlite:\/\//) {
|
||||
|
||||
if $sql_connection {
|
||||
warning('The sql_connection parameter is deprecated, use database_connection instead.')
|
||||
$database_connection_real = $sql_connection
|
||||
} else {
|
||||
fail("Invalid db connection ${sql_connection}")
|
||||
$database_connection_real = $database_connection
|
||||
}
|
||||
|
||||
if $sql_idle_timeout {
|
||||
warning('The sql_idle_timeout parameter is deprecated, use database_idle_timeout instead.')
|
||||
$database_idle_timeout_real = $sql_idle_timeout
|
||||
} else {
|
||||
$database_idle_timeout_real = $database_idle_timeout
|
||||
}
|
||||
|
||||
if $database_connection_real {
|
||||
if($database_connection_real =~ /mysql:\/\/\S+:\S+@\S+\/\S+/) {
|
||||
if ($mysql_module >= 2.2) {
|
||||
require 'mysql::bindings'
|
||||
require 'mysql::bindings::python'
|
||||
} else {
|
||||
require 'mysql::python'
|
||||
}
|
||||
} elsif($database_connection_real =~ /postgresql:\/\/\S+:\S+@\S+\/\S+/) {
|
||||
|
||||
} elsif($database_connection_real =~ /sqlite:\/\//) {
|
||||
|
||||
} else {
|
||||
fail("Invalid db connection ${database_connection_real}")
|
||||
}
|
||||
glance_registry_config {
|
||||
'database/connection': value => $database_connection_real;
|
||||
'database/idle_timeout': value => $database_idle_timeout_real;
|
||||
}
|
||||
}
|
||||
|
||||
glance_registry_config {
|
||||
|
@ -172,11 +203,6 @@ class glance::registry(
|
|||
'DEFAULT/bind_port': value => $bind_port;
|
||||
}
|
||||
|
||||
glance_registry_config {
|
||||
'DEFAULT/sql_connection': value => $sql_connection;
|
||||
'DEFAULT/sql_idle_timeout': value => $sql_idle_timeout;
|
||||
}
|
||||
|
||||
if $auth_uri {
|
||||
glance_registry_config { 'keystone_authtoken/auth_uri': value => $auth_uri; }
|
||||
} else {
|
||||
|
|
|
@ -30,8 +30,8 @@ describe 'glance::api' do
|
|||
:keystone_tenant => 'services',
|
||||
:keystone_user => 'glance',
|
||||
:keystone_password => 'ChangeMe',
|
||||
:sql_idle_timeout => '3600',
|
||||
:sql_connection => 'sqlite:///var/lib/glance/glance.sqlite',
|
||||
:database_idle_timeout => '3600',
|
||||
:database_connection => 'sqlite:///var/lib/glance/glance.sqlite',
|
||||
:show_image_direct_url => false,
|
||||
:purge_config => false,
|
||||
:mysql_module => '0.9',
|
||||
|
@ -59,8 +59,8 @@ describe 'glance::api' do
|
|||
:keystone_tenant => 'admin2',
|
||||
:keystone_user => 'admin2',
|
||||
:keystone_password => 'ChangeMe2',
|
||||
:sql_idle_timeout => '36002',
|
||||
:sql_connection => 'mysql:///var:lib@glance/glance',
|
||||
:database_idle_timeout => '36002',
|
||||
:database_connection => 'mysql:///var:lib@glance/glance',
|
||||
:show_image_direct_url => true,
|
||||
:image_cache_dir => '/tmp/glance'
|
||||
}
|
||||
|
@ -111,8 +111,8 @@ describe 'glance::api' do
|
|||
end
|
||||
|
||||
it 'should config db' do
|
||||
should contain_glance_api_config('DEFAULT/sql_connection').with_value(param_hash[:sql_connection])
|
||||
should contain_glance_api_config('DEFAULT/sql_idle_timeout').with_value(param_hash[:sql_idle_timeout])
|
||||
should contain_glance_api_config('database/connection').with_value(param_hash[:database_connection])
|
||||
should contain_glance_api_config('database/idle_timeout').with_value(param_hash[:database_idle_timeout])
|
||||
end
|
||||
|
||||
it 'should have no ssl options' do
|
||||
|
@ -307,6 +307,20 @@ describe 'glance::api' do
|
|||
it { should contain_glance_api_config('DEFAULT/known_stores').with_value("glance.store.filesystem.Store,glance.store.http.Store") }
|
||||
end
|
||||
|
||||
describe 'with deprecated sql parameters' do
|
||||
let :params do
|
||||
default_params.merge({
|
||||
:sql_connection => 'mysql://user:pass@db/db',
|
||||
:sql_idle_timeout => '30'
|
||||
})
|
||||
end
|
||||
|
||||
it 'configures database' do
|
||||
should contain_glance_api_config('database/connection').with_value('mysql://user:pass@db/db')
|
||||
should contain_glance_api_config('database/idle_timeout').with_value('30')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
|
|
|
@ -9,46 +9,46 @@ describe 'glance::registry' do
|
|||
|
||||
let :default_params do
|
||||
{
|
||||
:verbose => false,
|
||||
:debug => false,
|
||||
:bind_host => '0.0.0.0',
|
||||
:bind_port => '9191',
|
||||
:log_file => '/var/log/glance/registry.log',
|
||||
:log_dir => '/var/log/glance',
|
||||
:sql_connection => 'sqlite:///var/lib/glance/glance.sqlite',
|
||||
:sql_idle_timeout => '3600',
|
||||
:enabled => true,
|
||||
:auth_type => 'keystone',
|
||||
:auth_host => '127.0.0.1',
|
||||
:auth_port => '35357',
|
||||
:auth_protocol => 'http',
|
||||
:auth_uri => 'http://127.0.0.1:5000/',
|
||||
:keystone_tenant => 'services',
|
||||
:keystone_user => 'glance',
|
||||
:keystone_password => 'ChangeMe',
|
||||
:purge_config => false,
|
||||
:mysql_module => '0.9'
|
||||
:verbose => false,
|
||||
:debug => false,
|
||||
:bind_host => '0.0.0.0',
|
||||
:bind_port => '9191',
|
||||
: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,
|
||||
:auth_type => 'keystone',
|
||||
:auth_host => '127.0.0.1',
|
||||
:auth_port => '35357',
|
||||
:auth_protocol => 'http',
|
||||
:auth_uri => 'http://127.0.0.1:5000/',
|
||||
:keystone_tenant => 'services',
|
||||
:keystone_user => 'glance',
|
||||
:keystone_password => 'ChangeMe',
|
||||
:purge_config => false,
|
||||
:mysql_module => '0.9'
|
||||
}
|
||||
end
|
||||
|
||||
[
|
||||
{:keystone_password => 'ChangeMe'},
|
||||
{
|
||||
:verbose => true,
|
||||
:debug => true,
|
||||
:bind_host => '127.0.0.1',
|
||||
:bind_port => '9111',
|
||||
:sql_connection => 'sqlite:///var/lib/glance.sqlite',
|
||||
:sql_idle_timeout => '360',
|
||||
:enabled => false,
|
||||
:auth_type => 'keystone',
|
||||
:auth_host => '127.0.0.1',
|
||||
:auth_port => '35357',
|
||||
:auth_protocol => 'http',
|
||||
:auth_uri => 'http://127.0.0.1:5000/',
|
||||
:keystone_tenant => 'admin',
|
||||
:keystone_user => 'admin',
|
||||
:keystone_password => 'ChangeMe',
|
||||
:verbose => true,
|
||||
:debug => true,
|
||||
:bind_host => '127.0.0.1',
|
||||
:bind_port => '9111',
|
||||
:database_connection => 'sqlite:///var/lib/glance.sqlite',
|
||||
:database_idle_timeout => '360',
|
||||
:enabled => false,
|
||||
:auth_type => 'keystone',
|
||||
:auth_host => '127.0.0.1',
|
||||
:auth_port => '35357',
|
||||
:auth_protocol => 'http',
|
||||
:auth_uri => 'http://127.0.0.1:5000/',
|
||||
:keystone_tenant => 'admin',
|
||||
:keystone_user => 'admin',
|
||||
:keystone_password => 'ChangeMe',
|
||||
}
|
||||
].each do |param_set|
|
||||
|
||||
|
@ -90,11 +90,15 @@ describe 'glance::registry' do
|
|||
'debug',
|
||||
'bind_port',
|
||||
'bind_host',
|
||||
'sql_connection',
|
||||
'sql_idle_timeout'
|
||||
].each do |config|
|
||||
should contain_glance_registry_config("DEFAULT/#{config}").with_value(param_hash[config.intern])
|
||||
end
|
||||
[
|
||||
'database_connection',
|
||||
'database_idle_timeout',
|
||||
].each do |config|
|
||||
should contain_glance_registry_config("database/#{config.gsub(/database_/,'')}").with_value(param_hash[config.intern])
|
||||
end
|
||||
[
|
||||
'auth_host',
|
||||
'auth_port',
|
||||
|
@ -268,6 +272,20 @@ describe 'glance::registry' do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'with deprecated sql parameters' do
|
||||
let :params do
|
||||
default_params.merge({
|
||||
:sql_connection => 'mysql://user:pass@db/db',
|
||||
:sql_idle_timeout => '30'
|
||||
})
|
||||
end
|
||||
|
||||
it 'configures database' do
|
||||
should contain_glance_registry_config('database/connection').with_value('mysql://user:pass@db/db')
|
||||
should contain_glance_registry_config('database/idle_timeout').with_value('30')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
|
|
Loading…
Reference in New Issue