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

Change-Id: Ie211ad42163833830fbfe8bbf6c2671632394566
This commit is contained in:
Sebastien Badia 2015-10-20 21:48:41 +02:00
parent a930b68904
commit efab638752
4 changed files with 29 additions and 6 deletions

View File

@ -43,6 +43,8 @@ class cinder::db (
$database_max_overflow = $::os_service_default,
) {
include ::cinder::params
# NOTE(spredzy): In order to keep backward compatibility we rely on the pick function
# to use cinder::<myparam> if cinder::db::<myparam> isn't specified.
$database_connection_real = pick($::cinder::database_connection,$database_connection)
@ -63,7 +65,8 @@ class cinder::db (
require 'mysql::bindings::python'
}
/^postgresql:\/\//: {
$backend_package = $::cinder::params::psycopg_package_name
$backend_package = false
require 'postgresql::lib::python'
}
/^sqlite:\/\//: {
$backend_package = $::cinder::params::sqlite_package_name

View File

@ -20,7 +20,6 @@ class cinder::params {
$iscsi_helper = 'tgtadm'
$lio_package_name = 'targetcli'
$lock_path = '/var/lock/cinder'
$psycopg_package_name = 'python-psycopg2'
$sqlite_package_name = 'python-pysqlite2'
} elsif($::osfamily == 'RedHat') {
@ -41,7 +40,6 @@ class cinder::params {
$ceph_init_override = '/etc/sysconfig/openstack-cinder-volume'
$lio_package_name = 'targetcli'
$lock_path = '/var/lib/cinder/tmp'
$psycopg_package_name = 'python-psycopg2'
$sqlite_package_name = undef
case $::operatingsystem {

View File

@ -31,6 +31,17 @@ describe 'cinder::db' do
end
context 'with postgresql backend' do
let :params do
{ :database_connection => 'postgresql://cinder:cinder@localhost/cinder', }
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://cinder:cinder@localhost/cinder', }
@ -43,7 +54,11 @@ describe 'cinder::db' do
context 'on Debian platforms' do
let :facts do
@default_facts.merge!({ :osfamily => 'Debian' })
@default_facts.merge!({
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => 'jessie',
})
end
it_configures 'cinder::db'
@ -51,7 +66,10 @@ describe 'cinder::db' do
context 'on Redhat platforms' do
let :facts do
@default_facts.merge!({ :osfamily => 'RedHat' })
@default_facts.merge!({
:osfamily => 'RedHat',
:operatingsystemrelease => '7.1',
})
end
it_configures 'cinder::db'

View File

@ -9,7 +9,11 @@ describe 'cinder' do
end
let :facts do
@default_facts.merge!({:osfamily => 'Debian'})
@default_facts.merge!({
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => 'jessie',
})
end
describe 'with only required params' do