From a3c0b49a512d5f0902a1e3372f04c72599d63cfd Mon Sep 17 00:00:00 2001 From: Sebastien Badia Date: Tue, 20 Oct 2015 16:37:09 +0200 Subject: [PATCH] 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 --- manifests/db.pp | 3 ++- manifests/params.pp | 2 -- spec/classes/manila_db_spec.rb | 20 ++++++++++++++++++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/manifests/db.pp b/manifests/db.pp index 302902af..823a98ac 100644 --- a/manifests/db.pp +++ b/manifests/db.pp @@ -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 diff --git a/manifests/params.pp b/manifests/params.pp index 9cbde333..d92d8307 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -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) { diff --git a/spec/classes/manila_db_spec.rb b/spec/classes/manila_db_spec.rb index acc7846a..7f75fac1 100644 --- a/spec/classes/manila_db_spec.rb +++ b/spec/classes/manila_db_spec.rb @@ -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'