7340a067bb2981cadfc432ef02ab6c1b80ac507d
[pti/rtp.git] / meta-starlingx / meta-stx-cloud / recipes-support / puppet / files / puppet-oslo / 0002-add-psycopg2-drivername-to-postgresql-settings.patch
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
5
6 ---
7  manifests/db.pp | 13 ++++++++-----
8  1 file changed, 8 insertions(+), 5 deletions(-)
9
10 diff --git a/manifests/db.pp b/manifests/db.pp
11 index 172c8ae..4b918bc 100644
12 --- a/manifests/db.pp
13 +++ b/manifests/db.pp
14 @@ -132,10 +132,13 @@ define oslo::db(
15  
16    if !is_service_default($connection) {
17  
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':}
22 +    }
23 +    # add psycopg2 drivername to postgresql if using driverless postgres setting
24 +    $real_connection = regsubst($connection,'^postgresql:','postgresql+psycopg2:')
25  
26 -    case $connection {
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
33          }
34        }
35 -      /^postgresql:\/\//: {
36 +      /^postgresql(\+psycopg2)?:\/\//: {
37          $backend_package = false
38          require '::postgresql::lib::python'
39        }
40 @@ -178,7 +181,7 @@ to connect to the database.")
41    $database_options = {
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 },
49 -- 
50 1.8.3.1
51