1 From 1823423c329675a72ea5b3497c31f8c407dcdf27 Mon Sep 17 00:00:00 2001
2 From: Al Bailey <Al.Bailey@windriver.com>
3 Date: Thu, 14 Dec 2017 11:08:30 -0600
4 Subject: [PATCH] add psycopg2 drivername to postgresql settings
7 manifests/db.pp | 13 ++++++++-----
8 1 file changed, 8 insertions(+), 5 deletions(-)
10 diff --git a/manifests/db.pp b/manifests/db.pp
11 index 172c8ae..4b918bc 100644
14 @@ -132,10 +132,13 @@ define oslo::db(
16 if !is_service_default($connection) {
18 - validate_re($connection,
19 - '^(sqlite|mysql(\+pymysql)?|postgresql|mongodb):\/\/(\S+:\S+@\S+\/\S+)?')
20 + if $connection !~ '^(sqlite|mysql(\+pymysql)?|postgresql(\+psycopg2)?|mongodb):\/\/(\S+:\S+@\S+\/\S+)?' {
21 + err{'invalid database connection parameter: $connection':}
23 + # add psycopg2 drivername to postgresql if using driverless postgres setting
24 + $real_connection = regsubst($connection,'^postgresql:','postgresql+psycopg2:')
27 + case $real_connection {
28 /^mysql(\+pymysql)?:\/\//: {
29 require '::mysql::bindings'
30 require '::mysql::bindings::python'
31 @@ -145,7 +148,7 @@ define oslo::db(
32 $backend_package = false
35 - /^postgresql:\/\//: {
36 + /^postgresql(\+psycopg2)?:\/\//: {
37 $backend_package = false
38 require '::postgresql::lib::python'
40 @@ -178,7 +181,7 @@ to connect to the database.")
42 'database/sqlite_synchronous' => { value => $sqlite_synchronous },
43 'database/backend' => { value => $backend },
44 - 'database/connection' => { value => $connection, secret => true },
45 + 'database/connection' => { value => $real_connection, secret => true },
46 'database/slave_connection' => { value => $slave_connection, secret => true },
47 'database/mysql_sql_mode' => { value => $mysql_sql_mode },
48 'database/idle_timeout' => { value => $idle_timeout },