Skip to content

Commit

Permalink
Deprecate sql_connection in favor of database_connection
Browse files Browse the repository at this point in the history
Change-Id: I2ca6118448c93b5b5779e815169c5198fbdafdcd
Signed-off-by: Gael Chamoulaud <[email protected]>
  • Loading branch information
strider committed Oct 28, 2014
1 parent 599b613 commit 27f39cd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
28 changes: 23 additions & 5 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@
# [*qpid_reconnect_interval_min*]
# [*qpid_reconnect_interval_max*]
#
# [*database_connection*]
# Url used to connect to database.
# (Optional) Defaults to
# 'sqlite:////var/lib/heat/heat.sqlite'
#
# [*database_idle_timeout*]
# (optional) Timeout before idle db connections are reaped.
# Defaults to 3600
Expand All @@ -91,6 +96,9 @@
# [*mysql_module*]
# (optional) Deprecated. Does nothing.
#
# [*sql_connection*]
# (optional) Deprecated. Use database_connection instead.
#
class heat(
$auth_uri = false,
$package_ensure = 'present',
Expand Down Expand Up @@ -130,12 +138,13 @@
$qpid_reconnect_interval_min = 0,
$qpid_reconnect_interval_max = 0,
$qpid_reconnect_interval = 0,
$sql_connection = false,
$database_connection = 'sqlite:////var/lib/heat/heat.sqlite',
$database_idle_timeout = 3600,
$use_syslog = false,
$log_facility = 'LOG_USER',
#Deprecated parameters
$mysql_module = undef,
$sql_connection = undef,
) {

include heat::params
Expand Down Expand Up @@ -312,11 +321,17 @@
}

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
}

validate_re($sql_connection,
if $database_connection_real {
validate_re($database_connection_real,
'(sqlite|mysql|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')

case $sql_connection {
case $database_connection_real {
/^mysql:\/\//: {
$backend_package = false
require mysql::bindings
Expand All @@ -341,8 +356,11 @@
}

heat_config {
'database/connection': value => $sql_connection, secret => true;
'database/idle_timeout': value => $database_idle_timeout;
'database/connection':
value => $database_connection_real,
secret => true;
'database/idle_timeout':
value => $database_idle_timeout;
}

Heat_config['database/connection'] ~> Exec['heat-dbsync']
Expand Down
15 changes: 10 additions & 5 deletions spec/classes/heat_init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
:rabbit_userid => 'guest',
:rabbit_password => '',
:rabbit_virtual_host => '/',
:sql_connection => 'mysql://user@host/database',
:database_connection => 'mysql://user@host/database',
:database_idle_timeout => 3600,
:auth_uri => 'http://127.0.0.1:5000/v2.0',
:keystone_ec2_uri => 'http://127.0.0.1:5000/v2.0/ec2tokens',
Expand Down Expand Up @@ -136,19 +136,24 @@
it { should contain_heat_config('DEFAULT/log_dir').with_ensure('absent') }
end

it 'configures sql_connection' do
should contain_heat_config('database/connection').with_value( params[:sql_connection] )
it 'configures database_connection' do
should contain_heat_config('database/connection').with_value( params[:database_connection] )
end

it 'configures database_idle_timeout' do
should contain_heat_config('database/idle_timeout').with_value( params[:database_idle_timeout] )
end

context("failing if sql_connection is invalid") do
before { params[:sql_connection] = 'foo://foo:bar@baz/moo' }
context("failing if database_connection is invalid") do
before { params[:database_connection] = 'foo://foo:bar@baz/moo' }
it { expect { should raise_error(Puppet::Error) } }
end

context("with deprecated sql_connection parameter") do
before { params[:sql_connection] = 'mysql://a:b@c/d' }
it { should contain_heat_config('database/connection').with_value( params[:sql_connection] )}
end

it 'configures keystone_ec2_uri' do
should contain_heat_config('ec2authtoken/auth_uri').with_value( params[:keystone_ec2_uri] )
end
Expand Down

0 comments on commit 27f39cd

Please sign in to comment.