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>
This commit is contained in:
@@ -97,13 +97,20 @@
|
|||||||
# Defaults to true.
|
# Defaults to true.
|
||||||
#
|
#
|
||||||
# [*sql_idle_timeout*]
|
# [*sql_idle_timeout*]
|
||||||
# (optional) Period in seconds after which SQLAlchemy should reestablish its connection
|
# (optional) Deprecated. Use database_idle_timeout instead
|
||||||
# to the database.
|
# Defaults to false
|
||||||
# Defaults to '3600'.
|
|
||||||
#
|
#
|
||||||
# [*sql_connection*]
|
# [*sql_connection*]
|
||||||
# (optional) Database connection.
|
# (optional) Deprecated. Use database_connection instead.
|
||||||
# Defaults to 'sqlite:///var/lib/glance/glance.sqlite'.
|
# 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*]
|
# [*use_syslog*]
|
||||||
# (optional) Use syslog for logging.
|
# (optional) Use syslog for logging.
|
||||||
@@ -172,8 +179,6 @@ class glance::api(
|
|||||||
$keystone_tenant = 'services',
|
$keystone_tenant = 'services',
|
||||||
$keystone_user = 'glance',
|
$keystone_user = 'glance',
|
||||||
$enabled = true,
|
$enabled = true,
|
||||||
$sql_idle_timeout = '3600',
|
|
||||||
$sql_connection = 'sqlite:///var/lib/glance/glance.sqlite',
|
|
||||||
$use_syslog = false,
|
$use_syslog = false,
|
||||||
$log_facility = 'LOG_USER',
|
$log_facility = 'LOG_USER',
|
||||||
$show_image_direct_url = false,
|
$show_image_direct_url = false,
|
||||||
@@ -183,13 +188,16 @@ class glance::api(
|
|||||||
$ca_file = false,
|
$ca_file = false,
|
||||||
$mysql_module = '0.9',
|
$mysql_module = '0.9',
|
||||||
$known_stores = false,
|
$known_stores = false,
|
||||||
|
$database_connection = 'sqlite:///var/lib/glance/glance.sqlite',
|
||||||
|
$database_idle_timeout = 3600,
|
||||||
$image_cache_dir = '/var/lib/glance/image-cache',
|
$image_cache_dir = '/var/lib/glance/image-cache',
|
||||||
|
# DEPRECATED PARAMETERS
|
||||||
|
$sql_idle_timeout = false,
|
||||||
|
$sql_connection = false,
|
||||||
) inherits glance {
|
) inherits glance {
|
||||||
|
|
||||||
require keystone::python
|
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 ) {
|
if ( $glance::params::api_package_name != $glance::params::registry_package_name ) {
|
||||||
ensure_packages([$glance::params::api_package_name])
|
ensure_packages([$glance::params::api_package_name])
|
||||||
}
|
}
|
||||||
@@ -214,19 +222,39 @@ class glance::api(
|
|||||||
require => Class['glance'],
|
require => Class['glance'],
|
||||||
}
|
}
|
||||||
|
|
||||||
if($sql_connection =~ /mysql:\/\/\S+:\S+@\S+\/\S+/) {
|
if $sql_connection {
|
||||||
|
warning('The sql_connection parameter is deprecated, use database_connection instead.')
|
||||||
|
$database_connection_real = $sql_connection
|
||||||
|
} else {
|
||||||
|
$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) {
|
if ($mysql_module >= 2.2) {
|
||||||
require 'mysql::bindings'
|
require 'mysql::bindings'
|
||||||
require 'mysql::bindings::python'
|
require 'mysql::bindings::python'
|
||||||
} else {
|
} else {
|
||||||
require 'mysql::python'
|
require 'mysql::python'
|
||||||
}
|
}
|
||||||
} elsif($sql_connection =~ /postgresql:\/\/\S+:\S+@\S+\/\S+/) {
|
} elsif($database_connection_real =~ /postgresql:\/\/\S+:\S+@\S+\/\S+/) {
|
||||||
|
|
||||||
} elsif($sql_connection =~ /sqlite:\/\//) {
|
} elsif($database_connection_real =~ /sqlite:\/\//) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
fail("Invalid db connection ${sql_connection}")
|
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
|
# basic service config
|
||||||
@@ -268,15 +296,6 @@ class glance::api(
|
|||||||
'DEFAULT/registry_port': value => $registry_port;
|
'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 {
|
if $auth_uri {
|
||||||
glance_api_config { 'keystone_authtoken/auth_uri': value => $auth_uri; }
|
glance_api_config { 'keystone_authtoken/auth_uri': value => $auth_uri; }
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -29,12 +29,21 @@
|
|||||||
# If set to boolean false, it will not log to any directory.
|
# If set to boolean false, it will not log to any directory.
|
||||||
# Defaults to '/var/log/glance'
|
# Defaults to '/var/log/glance'
|
||||||
#
|
#
|
||||||
# [*sql_connection*]
|
|
||||||
# (optional) SQL connection string.
|
|
||||||
# Defaults to 'sqlite:///var/lib/glance/glance.sqlite'.
|
|
||||||
#
|
|
||||||
# [*sql_idle_timeout*]
|
# [*sql_idle_timeout*]
|
||||||
# (optional) SQL connections idle timeout. Defaults to '3600'.
|
# (optional) Deprecated. Use database_idle_timeout instead
|
||||||
|
# Defaults to false
|
||||||
|
#
|
||||||
|
# [*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*]
|
# [*auth_type*]
|
||||||
# (optional) Authentication type. Defaults to 'keystone'.
|
# (optional) Authentication type. Defaults to 'keystone'.
|
||||||
@@ -108,8 +117,8 @@ class glance::registry(
|
|||||||
$bind_port = '9191',
|
$bind_port = '9191',
|
||||||
$log_file = '/var/log/glance/registry.log',
|
$log_file = '/var/log/glance/registry.log',
|
||||||
$log_dir = '/var/log/glance',
|
$log_dir = '/var/log/glance',
|
||||||
$sql_connection = 'sqlite:///var/lib/glance/glance.sqlite',
|
$database_connection = 'sqlite:///var/lib/glance/glance.sqlite',
|
||||||
$sql_idle_timeout = '3600',
|
$database_idle_timeout = 3600,
|
||||||
$auth_type = 'keystone',
|
$auth_type = 'keystone',
|
||||||
$auth_host = '127.0.0.1',
|
$auth_host = '127.0.0.1',
|
||||||
$auth_port = '35357',
|
$auth_port = '35357',
|
||||||
@@ -127,12 +136,13 @@ class glance::registry(
|
|||||||
$key_file = false,
|
$key_file = false,
|
||||||
$ca_file = false,
|
$ca_file = false,
|
||||||
$mysql_module = '0.9',
|
$mysql_module = '0.9',
|
||||||
|
# DEPRECATED PARAMETERS
|
||||||
|
$sql_idle_timeout = false,
|
||||||
|
$sql_connection = false,
|
||||||
) inherits glance {
|
) inherits glance {
|
||||||
|
|
||||||
require keystone::python
|
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 ) {
|
if ( $glance::params::api_package_name != $glance::params::registry_package_name ) {
|
||||||
ensure_packages([$glance::params::registry_package_name])
|
ensure_packages([$glance::params::registry_package_name])
|
||||||
}
|
}
|
||||||
@@ -151,18 +161,39 @@ class glance::registry(
|
|||||||
require => Class['glance']
|
require => Class['glance']
|
||||||
}
|
}
|
||||||
|
|
||||||
if($sql_connection =~ /mysql:\/\/\S+:\S+@\S+\/\S+/) {
|
if $sql_connection {
|
||||||
if ($mysql_module >= 2.2) {
|
warning('The sql_connection parameter is deprecated, use database_connection instead.')
|
||||||
require mysql::bindings::python
|
$database_connection_real = $sql_connection
|
||||||
} else {
|
} else {
|
||||||
require mysql::python
|
$database_connection_real = $database_connection
|
||||||
}
|
}
|
||||||
} elsif($sql_connection =~ /postgresql:\/\/\S+:\S+@\S+\/\S+/) {
|
|
||||||
|
|
||||||
} elsif($sql_connection =~ /sqlite:\/\//) {
|
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 {
|
} else {
|
||||||
fail("Invalid db connection ${sql_connection}")
|
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 {
|
glance_registry_config {
|
||||||
@@ -172,11 +203,6 @@ class glance::registry(
|
|||||||
'DEFAULT/bind_port': value => $bind_port;
|
'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 {
|
if $auth_uri {
|
||||||
glance_registry_config { 'keystone_authtoken/auth_uri': value => $auth_uri; }
|
glance_registry_config { 'keystone_authtoken/auth_uri': value => $auth_uri; }
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ describe 'glance::api' do
|
|||||||
:keystone_tenant => 'services',
|
:keystone_tenant => 'services',
|
||||||
:keystone_user => 'glance',
|
:keystone_user => 'glance',
|
||||||
:keystone_password => 'ChangeMe',
|
:keystone_password => 'ChangeMe',
|
||||||
:sql_idle_timeout => '3600',
|
:database_idle_timeout => '3600',
|
||||||
:sql_connection => 'sqlite:///var/lib/glance/glance.sqlite',
|
:database_connection => 'sqlite:///var/lib/glance/glance.sqlite',
|
||||||
:show_image_direct_url => false,
|
:show_image_direct_url => false,
|
||||||
:purge_config => false,
|
:purge_config => false,
|
||||||
:mysql_module => '0.9',
|
:mysql_module => '0.9',
|
||||||
@@ -59,8 +59,8 @@ describe 'glance::api' do
|
|||||||
:keystone_tenant => 'admin2',
|
:keystone_tenant => 'admin2',
|
||||||
:keystone_user => 'admin2',
|
:keystone_user => 'admin2',
|
||||||
:keystone_password => 'ChangeMe2',
|
:keystone_password => 'ChangeMe2',
|
||||||
:sql_idle_timeout => '36002',
|
:database_idle_timeout => '36002',
|
||||||
:sql_connection => 'mysql:///var:lib@glance/glance',
|
:database_connection => 'mysql:///var:lib@glance/glance',
|
||||||
:show_image_direct_url => true,
|
:show_image_direct_url => true,
|
||||||
:image_cache_dir => '/tmp/glance'
|
:image_cache_dir => '/tmp/glance'
|
||||||
}
|
}
|
||||||
@@ -111,8 +111,8 @@ describe 'glance::api' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'should config db' do
|
it 'should config db' do
|
||||||
should contain_glance_api_config('DEFAULT/sql_connection').with_value(param_hash[:sql_connection])
|
should contain_glance_api_config('database/connection').with_value(param_hash[:database_connection])
|
||||||
should contain_glance_api_config('DEFAULT/sql_idle_timeout').with_value(param_hash[:sql_idle_timeout])
|
should contain_glance_api_config('database/idle_timeout').with_value(param_hash[:database_idle_timeout])
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should have no ssl options' do
|
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") }
|
it { should contain_glance_api_config('DEFAULT/known_stores').with_value("glance.store.filesystem.Store,glance.store.http.Store") }
|
||||||
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_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
|
describe 'on Debian platforms' do
|
||||||
let :facts do
|
let :facts do
|
||||||
{ :osfamily => 'Debian' }
|
{ :osfamily => 'Debian' }
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ describe 'glance::registry' do
|
|||||||
:bind_port => '9191',
|
:bind_port => '9191',
|
||||||
:log_file => '/var/log/glance/registry.log',
|
:log_file => '/var/log/glance/registry.log',
|
||||||
:log_dir => '/var/log/glance',
|
:log_dir => '/var/log/glance',
|
||||||
:sql_connection => 'sqlite:///var/lib/glance/glance.sqlite',
|
:database_connection => 'sqlite:///var/lib/glance/glance.sqlite',
|
||||||
:sql_idle_timeout => '3600',
|
:database_idle_timeout => '3600',
|
||||||
:enabled => true,
|
:enabled => true,
|
||||||
:auth_type => 'keystone',
|
:auth_type => 'keystone',
|
||||||
:auth_host => '127.0.0.1',
|
:auth_host => '127.0.0.1',
|
||||||
@@ -38,8 +38,8 @@ describe 'glance::registry' do
|
|||||||
:debug => true,
|
:debug => true,
|
||||||
:bind_host => '127.0.0.1',
|
:bind_host => '127.0.0.1',
|
||||||
:bind_port => '9111',
|
:bind_port => '9111',
|
||||||
:sql_connection => 'sqlite:///var/lib/glance.sqlite',
|
:database_connection => 'sqlite:///var/lib/glance.sqlite',
|
||||||
:sql_idle_timeout => '360',
|
:database_idle_timeout => '360',
|
||||||
:enabled => false,
|
:enabled => false,
|
||||||
:auth_type => 'keystone',
|
:auth_type => 'keystone',
|
||||||
:auth_host => '127.0.0.1',
|
:auth_host => '127.0.0.1',
|
||||||
@@ -90,11 +90,16 @@ describe 'glance::registry' do
|
|||||||
'debug',
|
'debug',
|
||||||
'bind_port',
|
'bind_port',
|
||||||
'bind_host',
|
'bind_host',
|
||||||
'sql_connection',
|
|
||||||
'sql_idle_timeout'
|
|
||||||
].each do |config|
|
].each do |config|
|
||||||
should contain_glance_registry_config("DEFAULT/#{config}").with_value(param_hash[config.intern])
|
should contain_glance_registry_config("DEFAULT/#{config}").with_value(param_hash[config.intern])
|
||||||
end
|
end
|
||||||
|
[
|
||||||
|
'database_connection',
|
||||||
|
'database_idle_timeout',
|
||||||
|
].each do |config|
|
||||||
|
should contain_glance_registry_config("database/connection").with_value(param_hash[:database_connection])
|
||||||
|
should contain_glance_registry_config("database/idle_timeout").with_value(param_hash[:database_idle_timeout])
|
||||||
|
end
|
||||||
[
|
[
|
||||||
'auth_host',
|
'auth_host',
|
||||||
'auth_port',
|
'auth_port',
|
||||||
@@ -268,6 +273,20 @@ describe 'glance::registry' do
|
|||||||
end
|
end
|
||||||
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
|
describe 'on Debian platforms' do
|
||||||
let :facts do
|
let :facts do
|
||||||
{ :osfamily => 'Debian' }
|
{ :osfamily => 'Debian' }
|
||||||
|
|||||||
Reference in New Issue
Block a user