Remove heat::db class
heat::db is different to every other project's puppet modules. All of nova, glance, keystone and cinder take a "sql_connection" parameter to the "main" (project name) class. This removes heat::db and adds it into init.pp to maintain parity with those projects. This seems more logical than adding it to engine.pp; since heat-engine is only using the DEFAULT section of heat.conf. Change-Id: I4584cdb12d1f9e624228e6ee34b4bcfbf649a12e
This commit is contained in:
parent
84dbad08b7
commit
c6fb1f0e82
|
@ -5,27 +5,24 @@ node default {
|
|||
|
||||
# First, install a mysql server
|
||||
class { 'mysql::server': }
|
||||
|
||||
# And create the database
|
||||
class { 'heat::db::mysql':
|
||||
password => 'heat',
|
||||
}
|
||||
|
||||
# Configure the heat database
|
||||
# Only needed if heat::engine is declared
|
||||
class { 'heat::db':
|
||||
}
|
||||
# Common class
|
||||
class { 'heat':
|
||||
# The keystone_password parameter is mandatory
|
||||
keystone_password => 'password'
|
||||
keystone_password => 'password',
|
||||
sql_connection => 'mysql://heat:heat@localhost/heat'
|
||||
}
|
||||
# class { 'heat::params': }
|
||||
|
||||
# Install the heat-api service
|
||||
class { 'heat::api': }
|
||||
|
||||
# Install heat-engine
|
||||
class { 'heat::engine':
|
||||
}
|
||||
|
||||
# Install the heat-api service
|
||||
class { 'heat::api': }
|
||||
|
||||
}
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
# Configures the heat database
|
||||
# This class will install the required libraries depending on the driver
|
||||
# specified in the connection_string parameter
|
||||
#
|
||||
# == Parameters
|
||||
# [*database_connection*]
|
||||
# the connection string. format: [driver]://[user]:[password]@[host]/[database]
|
||||
#
|
||||
class heat::db (
|
||||
$sql_connection = 'mysql://heat:heat@localhost/heat'
|
||||
) {
|
||||
|
||||
include heat::params
|
||||
|
||||
Package<| title == 'heat-common' |> -> Class['heat::db']
|
||||
|
||||
validate_re($sql_connection,
|
||||
'(sqlite|mysql|posgres):\/\/(\S+:\S+@\S+\/\S+)?')
|
||||
|
||||
case $sql_connection {
|
||||
/^mysql:\/\//: {
|
||||
$backend_package = false
|
||||
include mysql::python
|
||||
}
|
||||
/^postgres:\/\//: {
|
||||
$backend_package = 'python-psycopg2'
|
||||
}
|
||||
/^sqlite:\/\//: {
|
||||
$backend_package = 'python-pysqlite2'
|
||||
}
|
||||
default: {
|
||||
fail('Unsupported backend configured')
|
||||
}
|
||||
}
|
||||
|
||||
if $backend_package and !defined(Package[$backend_package]) {
|
||||
package {'heat-backend-package':
|
||||
ensure => present,
|
||||
name => $backend_package,
|
||||
}
|
||||
}
|
||||
|
||||
heat_config {
|
||||
'DEFAULT/sql_connection': value => $sql_connection;
|
||||
}
|
||||
}
|
|
@ -83,6 +83,7 @@ class heat(
|
|||
$qpid_reconnect_interval_min = 0,
|
||||
$qpid_reconnect_interval_max = 0,
|
||||
$qpid_reconnect_interval = 0,
|
||||
$sql_connection = false,
|
||||
) {
|
||||
|
||||
include heat::params
|
||||
|
@ -189,4 +190,37 @@ class heat(
|
|||
'keystone_authtoken/admin_password' : value => $keystone_password;
|
||||
}
|
||||
|
||||
if $sql_connection {
|
||||
|
||||
validate_re($sql_connection,
|
||||
'(sqlite|mysql|posgres):\/\/(\S+:\S+@\S+\/\S+)?')
|
||||
|
||||
case $sql_connection {
|
||||
/^mysql:\/\//: {
|
||||
$backend_package = false
|
||||
include mysql::python
|
||||
}
|
||||
/^postgres:\/\//: {
|
||||
$backend_package = 'python-psycopg2'
|
||||
}
|
||||
/^sqlite:\/\//: {
|
||||
$backend_package = 'python-pysqlite2'
|
||||
}
|
||||
default: {
|
||||
fail('Unsupported backend configured')
|
||||
}
|
||||
}
|
||||
|
||||
if $backend_package and !defined(Package[$backend_package]) {
|
||||
package {'heat-backend-package':
|
||||
ensure => present,
|
||||
name => $backend_package,
|
||||
}
|
||||
}
|
||||
|
||||
heat_config {
|
||||
'DEFAULT/sql_connection': value => $sql_connection;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ describe 'heat' do
|
|||
:rabbit_userid => 'guest',
|
||||
:rabbit_password => '',
|
||||
:rabbit_virtualhost => '/',
|
||||
:sql_connection => 'mysql://user@host/database'
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -107,6 +108,15 @@ describe 'heat' do
|
|||
should contain_heat_config('DEFAULT/verbose').with_value( params[:verbose] )
|
||||
end
|
||||
|
||||
it 'configures sql_connection' do
|
||||
should contain_heat_config('DEFAULT/sql_connection').with_value( params[:sql_connection] )
|
||||
end
|
||||
|
||||
context("failing if sql_connection is invalid") do
|
||||
before { params[:sql_connection] = 'foo://foo:bar@baz/moo' }
|
||||
it { expect { should raise_error(Puppet::Error) } }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
shared_examples_for 'rabbit without HA support (with backward compatibility)' do
|
||||
|
|
Loading…
Reference in New Issue