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 sahara module.

Change-Id: I1c9378fb9aba2b4261ab25f4057cccf71560d1a8
This commit is contained in:
Sebastien Badia
2015-10-20 18:20:17 +02:00
parent 1efb8f2273
commit 504d207d34
3 changed files with 19 additions and 5 deletions

View File

@@ -62,7 +62,7 @@ class sahara::db (
require mysql::bindings::python
}
/^postgresql:\/\//: {
$backend_package = $::sahara::params::psycopg_package_name
$backend_package = false
require postgresql::lib::python
}
default: {

View File

@@ -15,7 +15,6 @@ class sahara::params {
$all_service_name = 'openstack-sahara-all'
$api_service_name = 'openstack-sahara-api'
$engine_service_name = 'openstack-sahara-engine'
$psycopg_package_name = 'python-psycopg2'
}
'Debian': {
$common_package_name = 'sahara-common'
@@ -25,7 +24,6 @@ class sahara::params {
$all_service_name = 'sahara'
$api_service_name = 'sahara-api'
$engine_service_name = 'sahara-engine'
$psycopg_package_name = 'python-psycopg2'
}
default: {
fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}")

View File

@@ -34,6 +34,17 @@ describe 'sahara::db' do
it { is_expected.to contain_sahara_config('database/max_overflow').with_value('21') }
end
context 'with postgresql backend' do
let :params do
{ :database_connection => 'postgresql://sahara:sahara@localhost/sahara', }
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 => 'sqlite://sahara:sahara@localhost/sahara', }
@@ -45,7 +56,10 @@ describe 'sahara::db' do
context 'on Debian platforms' do
let :facts do
{ :osfamily => 'Debian' }
{ :osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => 'jessie',
}
end
it_configures 'sahara::db'
@@ -53,7 +67,9 @@ describe 'sahara::db' do
context 'on Redhat platforms' do
let :facts do
{ :osfamily => 'RedHat' }
{ :osfamily => 'RedHat',
:operatingsystemrelease => '7.1',
}
end
it_configures 'sahara::db'