db: Use postgresql lib class for psycopg package

This patch introduce the same design than mysql for postgresql
by requiring dedicated lib::python class instead of declaring
a new resource package within heat module.

Change-Id: I386e61054e84b14d25afebb4aa415ab2b6161a57
This commit is contained in:
Sebastien Badia 2015-10-20 16:27:14 +02:00
parent 905185c66b
commit 0be4a41486
3 changed files with 20 additions and 5 deletions

View File

@ -70,7 +70,8 @@ class heat::db (
require 'mysql::bindings::python'
}
/^postgresql:\/\//: {
$backend_package = $::heat::params::psycopg_package_name
$backend_package = false
require 'postgresql::lib::python'
}
/^sqlite:\/\//: {
$backend_package = $::heat::params::sqlite_package_name

View File

@ -16,7 +16,6 @@ class heat::params {
$engine_package_name = 'openstack-heat-engine'
$client_package_name = 'python-heatclient'
$common_package_name = 'openstack-heat-common'
$psycopg_package_name = 'python-psycopg2'
$sqlite_package_name = undef
# service names
$api_service_name = 'openstack-heat-api'
@ -32,7 +31,6 @@ class heat::params {
$engine_package_name = 'heat-engine'
$client_package_name = 'python-heatclient'
$common_package_name = 'heat-common'
$psycopg_package_name = 'python-psycopg2'
$sqlite_package_name = 'python-pysqlite2'
# service names
$api_service_name = 'heat-api'

View File

@ -34,6 +34,17 @@ describe 'heat::db' do
end
context 'with postgresql backend' do
let :params do
{ :database_connection => 'postgresql://heat:heat@localhost/heat', }
end
it 'install the proper backend package' do
is_expected.to contain_package('python-psycopg2').with(:ensure => 'present')
end
end
context 'with incorrect database_connection string' do
let :params do
{ :database_connection => 'redis://heat:heat@localhost/heat', }
@ -46,7 +57,10 @@ describe 'heat::db' do
context 'on Debian platforms' do
let :facts do
{ :osfamily => 'Debian' }
{ :osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => 'jessie',
}
end
it_configures 'heat::db'
@ -54,7 +68,9 @@ describe 'heat::db' do
context 'on Redhat platforms' do
let :facts do
{ :osfamily => 'RedHat' }
{ :osfamily => 'RedHat',
:operatingsystemrelease => '7.1',
}
end
it_configures 'heat::db'