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

Change-Id: I441f5ca6f9d5cbaa7705f5b72e48528dcff67f8d
This commit is contained in:
Sebastien Badia 2015-10-20 16:37:09 +02:00
parent 6d52d91754
commit a3c0b49a51
3 changed files with 20 additions and 5 deletions

View File

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

View File

@ -21,7 +21,6 @@ class manila::params {
$lio_package_name = 'targetcli'
$gluster_client_package_name = 'glusterfs-client'
$gluster_package_name = 'glusterfs-common'
$psycopg_package_name = 'python-psycopg2'
$sqlite_package_name = 'python-pysqlite2'
} elsif($::osfamily == 'RedHat') {
@ -41,7 +40,6 @@ class manila::params {
$lio_package_name = 'targetcli'
$gluster_client_package_name = 'glusterfs-fuse'
$gluster_package_name = 'glusterfs'
$psycopg_package_name = 'python-psycopg2'
$sqlite_package_name = undef
if $::operatingsystem == 'RedHat' and (versioncmp($::operatingsystemmajrelease, '7') >= 0) {

View File

@ -37,6 +37,17 @@ describe 'manila::db' do
end
context 'with postgresql backend' do
let :params do
{ :database_connection => 'postgresql://manila:manila@localhost/manila', }
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://manila:manila@localhost/manila', }
@ -49,7 +60,10 @@ describe 'manila::db' do
context 'on Debian platforms' do
let :facts do
{ :osfamily => 'Debian' }
{ :osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => 'jessie',
}
end
it_configures 'manila::db'
@ -57,7 +71,9 @@ describe 'manila::db' do
context 'on Redhat platforms' do
let :facts do
{ :osfamily => 'RedHat' }
{ :osfamily => 'RedHat',
:operatingsystemrelease => '7.1',
}
end
it_configures 'manila::db'