Migrate postgresql backend to use openstacklib::db::postgresql

Let migrate to the new openstacklib::db::postgresql helper for
postgresql backend. This commit also unpin postgresql fixture
(openstacklib support now the latest version of postgre module).

Implements: blueprint commmon-openstack-database-resource
Change-Id: I45b034b9495ea02a143dad895c116077772c6b73
This commit is contained in:
Sebastien Badia 2014-12-30 18:00:58 +01:00
parent 62823628ca
commit 6c792b9b64
3 changed files with 67 additions and 26 deletions

View File

@ -1,15 +1,14 @@
fixtures:
repositories:
'apt': 'git://github.com/puppetlabs/puppetlabs-apt.git'
'concat': 'git://github.com/puppetlabs/puppetlabs-concat.git'
'inifile': 'git://github.com/puppetlabs/puppetlabs-inifile'
'keystone': 'git://github.com/stackforge/puppet-keystone.git'
'mysql':
repo: 'git://github.com/puppetlabs/puppetlabs-mysql.git'
ref: 'origin/2.2.x'
'openstacklib': 'git://github.com/stackforge/puppet-openstacklib.git'
'postgresql':
repo: 'git://github.com/puppetlabs/puppet-postgresql.git'
ref: '2.5.0'
'postgresql': 'git://github.com/puppetlabs/puppet-postgresql.git'
'qpid': 'git://github.com/dprince/puppet-qpid.git'
'rabbitmq':
repo: 'git://github.com/puppetlabs/puppetlabs-rabbitmq'

View File

@ -16,20 +16,30 @@
# (Optional) User to connect to the database.
# Defaults to 'cinder'.
#
# [*encoding*]
# (Optional) The charset to use for the database.
# Default to undef.
#
# [*privileges*]
# (Optional) Privileges given to the database user.
# Default to 'ALL'
#
class cinder::db::postgresql(
$password,
$dbname = 'cinder',
$user = 'cinder'
$dbname = 'cinder',
$user = 'cinder',
$encoding = undef,
$privileges = 'ALL',
) {
require postgresql::python
Postgresql::Db[$dbname] ~> Exec<| title == 'cinder-manage db_sync' |>
Package['python-psycopg2'] -> Exec<| title == 'cinder-manage db_sync' |>
postgresql::db { $dbname:
user => $user,
password => $password,
::openstacklib::db::postgresql { 'cinder':
password_hash => postgresql_password($user, $password),
dbname => $dbname,
user => $user,
encoding => $encoding,
privileges => $privileges,
}
::Openstacklib::Db::Postgresql['cinder'] ~> Exec<| title == 'cinder-manage db_sync' |>
}

View File

@ -3,24 +3,56 @@ require 'spec_helper'
describe 'cinder::db::postgresql' do
let :req_params do
{:password => 'pw'}
{ :password => 'pw' }
end
let :facts do
{
:postgres_default_version => '8.4',
:osfamily => 'RedHat',
}
let :pre_condition do
'include postgresql::server'
end
describe 'with only required params' do
let :params do
req_params
context 'on a RedHat osfamily' do
let :facts do
{
:osfamily => 'RedHat',
:operatingsystemrelease => '7.0',
:concat_basedir => '/var/lib/puppet/concat'
}
end
it { should contain_postgresql__db('cinder').with(
:user => 'cinder',
:password => 'pw'
) }
context 'with only required parameters' do
let :params do
req_params
end
it { should contain_postgresql__server__db('cinder').with(
:user => 'cinder',
:password => 'md506736c3030793e09882cc536063d433f'
)}
end
end
context 'on a Debian osfamily' do
let :facts do
{
:operatingsystemrelease => '7.8',
:operatingsystem => 'Debian',
:osfamily => 'Debian',
:concat_basedir => '/var/lib/puppet/concat'
}
end
context 'with only required parameters' do
let :params do
req_params
end
it { should contain_postgresql__server__db('cinder').with(
:user => 'cinder',
:password => 'md506736c3030793e09882cc536063d433f'
)}
end
end
end