Skip to content

Commit

Permalink
Deprecate sql_* for database_*
Browse files Browse the repository at this point in the history
Upstream change d5ae9ea70ed878e08e1d195f34c1989ecdd0b74f deprecated
default sql_* options for a new [database] section.

This deprecates the sql_ options and moves the new options into
the [database] sub-section of the config file.  If sql_* values are
given, they should be used but give a deprecation warning.

Change-Id: I05db83ace63399c0b2ebd63f74f5dc76ff5d3e9a
  • Loading branch information
ianw committed Sep 25, 2013
1 parent 75453a4 commit 1170d57
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 65 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ To utilize the nova module's functionality you will need to declare multiple res

```puppet
class { 'nova':
sql_connection => 'mysql://nova:a_big_secret@127.0.0.1/nova?charset=utf8",
database_connection => 'mysql://nova:a_big_secret@127.0.0.1/nova?charset=utf8",
rabbit_userid => 'nova',
rabbit_password => 'an_even_bigger_secret',
image_service => 'nova.image.glance.GlanceImageService',
Expand Down
38 changes: 27 additions & 11 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#
# ==Parameters
#
# [sql_connection] Connection url to use to connect to nova sql database.
# [sql_idle_timeout] Timeout before idle sql connections are reaped.
# [database_connection] Connection url to connect to nova database.
# [database_idle_timeout] Timeout before idle db connections are reaped.
# [image_service] Service used to search for and retrieve images. Optional.
# Defaults to 'nova.image.local.LocalImageService'
# [glance_api_servers] List of addresses for api servers. Optional.
Expand Down Expand Up @@ -36,8 +36,11 @@
$ensure_package = 'present',
# this is how to query all resources from our clutser
$nova_cluster_id='localcluster',
# note: sql_* deprecated for database_*
$sql_connection = false,
$sql_idle_timeout = '3600',
$sql_idle_timeout = false,
$database_connection = false,
$database_idle_timeout = 3600,
$rpc_backend = 'nova.openstack.common.rpc.impl_kombu',
$image_service = 'nova.image.glance.GlanceImageService',
# these glance params should be optional
Expand Down Expand Up @@ -147,22 +150,35 @@
refreshonly => true,
}

if $sql_connection {
warning('sql_connection deprecated for database_connection')
$database_connection_real = $sql_connection
} else {
$database_connection_real = $database_connection
}

# both the sql_connection and rabbit_host are things
if $sql_idle_timeout {
warning('sql_idle_timeout deprecated for database_idle_timeout')
$database_idle_timeout_real = $sql_idle_timeout
} else {
$database_idle_timeout_real = $database_idle_timeout
}

# both the database_connection and rabbit_host are things
# that may need to be collected from a remote host
if $sql_connection {
if($sql_connection =~ /mysql:\/\/\S+:\S+@\S+\/\S+/) {
if $database_connection_real {
if($database_connection_real =~ /mysql:\/\/\S+:\S+@\S+\/\S+/) {
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 {
fail("Invalid db connection ${sql_connection}")
fail("Invalid db connection ${database_connection_real}")
}
nova_config {
'DEFAULT/sql_connection': value => $sql_connection, secret => true;
'DEFAULT/sql_idle_timeout': value => $sql_idle_timeout;
'database/connection': value => $database_connection_real, secret => true;
'database/idle_timeout': value => $database_idle_timeout_real;
}
}

Expand Down
33 changes: 23 additions & 10 deletions spec/classes/nova_init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
'refreshonly' => true
)}

it { should_not contain_nova_config('DEFAULT/sql_connection') }
it { should_not contain_nova_config('DEFAULT/sql_idle_timeout').with_value('3600') }
it { should_not contain_nova_config('database/connection') }
it { should_not contain_nova_config('database/idle_timeout').with_value('3600') }

it { should contain_nova_config('DEFAULT/image_service').with_value('nova.image.glance.GlanceImageService') }
it { should contain_nova_config('DEFAULT/glance_api_servers').with_value('localhost:9292') }
Expand Down Expand Up @@ -84,8 +84,8 @@

let :params do
{
'sql_connection' => 'mysql://user:pass@db/db',
'sql_idle_timeout' => '30',
'database_connection' => 'mysql://user:pass@db/db',
'database_idle_timeout' => '30',
'verbose' => true,
'debug' => true,
'logdir' => '/var/log/nova2',
Expand All @@ -105,8 +105,8 @@

it { should contain_package('nova-common').with('ensure' => '2012.1.1-15.el6') }
it { should contain_package('python-nova').with('ensure' => '2012.1.1-15.el6') }
it { should contain_nova_config('DEFAULT/sql_connection').with_value('mysql://user:pass@db/db').with_secret(true) }
it { should contain_nova_config('DEFAULT/sql_idle_timeout').with_value('30') }
it { should contain_nova_config('database/connection').with_value('mysql://user:pass@db/db').with_secret(true) }
it { should contain_nova_config('database/idle_timeout').with_value('30') }

it { should contain_nova_config('DEFAULT/image_service').with_value('nova.image.local.LocalImageService') }
it { should_not contain_nova_config('DEFAULT/glance_api_servers') }
Expand All @@ -130,6 +130,19 @@

end

describe 'with deprecated sql parameters' do

let :params do
{
'sql_connection' => 'mysql://user:pass@db/db',
'sql_idle_timeout' => '30'
}
end
it { should contain_nova_config('database/connection').with_value('mysql://user:pass@db/db').with_secret(true) }
it { should contain_nova_config('database/idle_timeout').with_value('30') }
end


describe 'with some others parameters supplied' do

let :params do
Expand Down Expand Up @@ -177,8 +190,8 @@

let :params do
{
'sql_connection' => 'mysql://user:pass@db/db',
'sql_idle_timeout' => '30',
'database_connection' => 'mysql://user:pass@db/db',
'database_idle_timeout' => '30',
'verbose' => true,
'debug' => true,
'logdir' => '/var/log/nova2',
Expand All @@ -194,8 +207,8 @@

it { should contain_package('nova-common').with('ensure' => '2012.1.1-15.el6') }
it { should contain_package('python-nova').with('ensure' => '2012.1.1-15.el6') }
it { should contain_nova_config('DEFAULT/sql_connection').with_value('mysql://user:pass@db/db') }
it { should contain_nova_config('DEFAULT/sql_idle_timeout').with_value('30') }
it { should contain_nova_config('database/connection').with_value('mysql://user:pass@db/db') }
it { should contain_nova_config('database/idle_timeout').with_value('30') }

it { should contain_nova_config('DEFAULT/image_service').with_value('nova.image.local.LocalImageService') }
it { should_not contain_nova_config('DEFAULT/glance_api_servers') }
Expand Down
30 changes: 15 additions & 15 deletions tests/all.pp
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@
class { 'glance::backend::file': }

class { 'glance::registry':
verbose => true,
debug => true,
auth_type => 'keystone',
auth_host => '127.0.0.1',
auth_port => '35357',
keystone_tenant => 'services',
keystone_user => 'glance',
keystone_password => $glance_user_password,
sql_connection => "mysql://glance:${glance_db_password}@127.0.0.1/glance",
verbose => true,
debug => true,
auth_type => 'keystone',
auth_host => '127.0.0.1',
auth_port => '35357',
keystone_tenant => 'services',
keystone_user => 'glance',
keystone_password => $glance_user_password,
database_connection => "mysql://glance:${glance_db_password}@127.0.0.1/glance",
}


Expand All @@ -123,12 +123,12 @@
}

class { 'nova':
sql_connection => "mysql://nova:${nova_db_password}@localhost/nova",
rabbit_userid => $rabbit_user,
rabbit_password => $rabbit_password,
image_service => 'nova.image.glance.GlanceImageService',
glance_api_servers => '127.0.0.1:9292',
network_manager => 'nova.network.manager.FlatDHCPManager',
database_connection => "mysql://nova:${nova_db_password}@localhost/nova",
rabbit_userid => $rabbit_user,
rabbit_password => $rabbit_password,
image_service => 'nova.image.glance.GlanceImageService',
glance_api_servers => '127.0.0.1:9292',
network_manager => 'nova.network.manager.FlatDHCPManager',
}

class { 'nova::api':
Expand Down
54 changes: 27 additions & 27 deletions tests/multi.pp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
# export all of the things that will be needed by the clients
@@nova_config { 'rabbit_hosts': value => $controller_host }
Nova_config <| title == 'rabbit_hosts' |>
@@nova_config { 'sql_connection': value => $nova_db }
Nova_config <| title == 'sql_connection' |>
@@nova_config { 'database_connection': value => $nova_db }
Nova_config <| title == 'database_connection' |>
@@nova_config { 'glance_api_servers': value => $glance_api_servers }
Nova_config <| title == 'glance_api_servers' |>

Expand Down Expand Up @@ -112,15 +112,15 @@
class { 'glance::backend::file': }

class { 'glance::registry':
verbose => true,
debug => true,
auth_type => 'keystone',
auth_host => '127.0.0.1',
auth_port => '35357',
keystone_tenant => 'services',
keystone_user => 'glance',
keystone_password => $glance_user_password,
sql_connection => "mysql://glance:${glance_db_password}@127.0.0.1/glance",
verbose => true,
debug => true,
auth_type => 'keystone',
auth_host => '127.0.0.1',
auth_port => '35357',
keystone_tenant => 'services',
keystone_user => 'glance',
keystone_password => $glance_user_password,
database_connection => "mysql://glance:${glance_db_password}@127.0.0.1/glance",
}


Expand All @@ -144,14 +144,14 @@
}

class { 'nova':
sql_connection => false,
database_connection => false,
# this is false b/c we are exporting
rabbit_hosts => false,
rabbit_userid => $rabbit_user,
rabbit_password => $rabbit_password,
image_service => 'nova.image.glance.GlanceImageService',
glance_api_servers => false,
network_manager => 'nova.network.manager.FlatDHCPManager',
rabbit_hosts => false,
rabbit_userid => $rabbit_user,
rabbit_password => $rabbit_password,
image_service => 'nova.image.glance.GlanceImageService',
glance_api_servers => false,
network_manager => 'nova.network.manager.FlatDHCPManager',
}

class { 'nova::api':
Expand Down Expand Up @@ -210,15 +210,15 @@
node /compute/ {

class { 'nova':
# set sql and rabbit to false so that the resources will be collected
sql_connection => false,
rabbit_hosts => false,
image_service => 'nova.image.glance.GlanceImageService',
glance_api_servers => false,
rabbit_userid => $rabbit_user,
rabbit_password => $rabbit_password,
network_manager => 'nova.network.manager.FlatDHCPManager',
admin_password => $nova_user_password,
# set db and rabbit to false so that the resources will be collected
database_connection => false,
rabbit_hosts => false,
image_service => 'nova.image.glance.GlanceImageService',
glance_api_servers => false,
rabbit_userid => $rabbit_user,
rabbit_password => $rabbit_password,
network_manager => 'nova.network.manager.FlatDHCPManager',
admin_password => $nova_user_password,
}

class { 'nova::compute':
Expand Down
2 changes: 1 addition & 1 deletion tests/site.pp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
}
class { 'nova':
verbose => $verbose,
sql_connection => "mysql://${db_username}:${db_password}@${db_host}/${db_name}",
database_connection => "mysql://${db_username}:${db_password}@${db_host}/${db_name}",
image_service => 'nova.image.glance.GlanceImageService',
glance_api_servers => $glance_api_servers,
rabbit_hosts => $rabbit_hosts,
Expand Down

0 comments on commit 1170d57

Please sign in to comment.