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 tuskar module. Change-Id: I374ee4ae7b3f6affc17f440e471d147414f4605a
This commit is contained in:
parent
b897eca5c2
commit
12fe6f37ec
@ -43,6 +43,8 @@ class tuskar::db (
|
||||
$database_max_overflow = 20,
|
||||
) {
|
||||
|
||||
include ::tuskar::params
|
||||
|
||||
# NOTE(spredzy): In order to keep backward compatibility we rely on the pick function
|
||||
# to use tuskar::<myparam> if tuskar::db::<myparam> isn't specified.
|
||||
$database_connection_real = pick($::tuskar::database_connection, $database_connection)
|
||||
@ -64,7 +66,8 @@ class tuskar::db (
|
||||
require 'mysql::bindings::python'
|
||||
}
|
||||
/^postgresql:\/\//: {
|
||||
$backend_package = $::tuskar::params::psycopg_package_name
|
||||
$backend_package = false
|
||||
require 'postgresql::lib::python'
|
||||
}
|
||||
/^sqlite:\/\//: {
|
||||
$backend_package = $::tuskar::params::sqlite_package_name
|
||||
|
@ -9,7 +9,6 @@ class tuskar::params {
|
||||
$api_service_name = 'openstack-tuskar-api'
|
||||
$ui_package_name = 'openstack-tuskar-ui'
|
||||
$ui_extras_package_name = 'openstack-tuskar-ui-extras'
|
||||
$psycopg_package_name = 'python-psycopg2'
|
||||
$sqlite_package_name = undef
|
||||
}
|
||||
'Debian': {
|
||||
@ -18,7 +17,6 @@ class tuskar::params {
|
||||
$api_service_name = 'tuskar-api'
|
||||
$ui_package_name = 'tuskar-ui'
|
||||
$ui_extras_package_name = 'tuskar-ui-extras'
|
||||
$psycopg_package_name = 'python-psycopg2'
|
||||
$sqlite_package_name = 'python-pysqlite2'
|
||||
}
|
||||
default: {
|
||||
|
@ -31,6 +31,17 @@ describe 'tuskar::db' do
|
||||
|
||||
end
|
||||
|
||||
context 'with postgresql backend' do
|
||||
let :params do
|
||||
{ :database_connection => 'postgresql://tuskar:tuskar@localhost/tuskar', }
|
||||
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://tuskar:tuskar@localhost/tuskar', }
|
||||
@ -43,15 +54,35 @@ describe 'tuskar::db' do
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
{ :osfamily => 'Debian',
|
||||
:operatingsystem => 'Debian',
|
||||
:operatingsystemrelease => 'jessie',
|
||||
}
|
||||
end
|
||||
|
||||
it_configures 'tuskar::db'
|
||||
|
||||
context 'with sqlite backend' do
|
||||
let :params do
|
||||
{ :database_connection => 'sqlite:///var/lib/tuskar/tuskar.sqlite', }
|
||||
end
|
||||
|
||||
it 'install the proper backend package' do
|
||||
is_expected.to contain_package('tuskar-backend-package').with(
|
||||
:ensure => 'present',
|
||||
:name => 'python-pysqlite2',
|
||||
:tag => 'openstack'
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Redhat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
{ :osfamily => 'RedHat',
|
||||
:operatingsystemrelease => '7.1',
|
||||
}
|
||||
end
|
||||
|
||||
it_configures 'tuskar::db'
|
||||
|
Loading…
Reference in New Issue
Block a user