Add initial meta-stx to support StarlingX build
[pti/rtp.git] / meta-stx / recipes-support / puppet / files / puppet-oslo / 0002-add-psycopg2-drivername-to-postgresql-settings.patch
diff --git a/meta-stx/recipes-support/puppet/files/puppet-oslo/0002-add-psycopg2-drivername-to-postgresql-settings.patch b/meta-stx/recipes-support/puppet/files/puppet-oslo/0002-add-psycopg2-drivername-to-postgresql-settings.patch
new file mode 100644 (file)
index 0000000..7340a06
--- /dev/null
@@ -0,0 +1,51 @@
+From 1823423c329675a72ea5b3497c31f8c407dcdf27 Mon Sep 17 00:00:00 2001
+From: Al Bailey <Al.Bailey@windriver.com>
+Date: Thu, 14 Dec 2017 11:08:30 -0600
+Subject: [PATCH] add psycopg2 drivername to postgresql settings
+
+---
+ manifests/db.pp | 13 ++++++++-----
+ 1 file changed, 8 insertions(+), 5 deletions(-)
+
+diff --git a/manifests/db.pp b/manifests/db.pp
+index 172c8ae..4b918bc 100644
+--- a/manifests/db.pp
++++ b/manifests/db.pp
+@@ -132,10 +132,13 @@ define oslo::db(
+   if !is_service_default($connection) {
+-    validate_re($connection,
+-      '^(sqlite|mysql(\+pymysql)?|postgresql|mongodb):\/\/(\S+:\S+@\S+\/\S+)?')
++    if $connection !~ '^(sqlite|mysql(\+pymysql)?|postgresql(\+psycopg2)?|mongodb):\/\/(\S+:\S+@\S+\/\S+)?' {
++      err{'invalid database connection parameter: $connection':}
++    }
++    # add psycopg2 drivername to postgresql if using driverless postgres setting
++    $real_connection = regsubst($connection,'^postgresql:','postgresql+psycopg2:')
+-    case $connection {
++    case $real_connection {
+       /^mysql(\+pymysql)?:\/\//: {
+         require '::mysql::bindings'
+         require '::mysql::bindings::python'
+@@ -145,7 +148,7 @@ define oslo::db(
+           $backend_package = false
+         }
+       }
+-      /^postgresql:\/\//: {
++      /^postgresql(\+psycopg2)?:\/\//: {
+         $backend_package = false
+         require '::postgresql::lib::python'
+       }
+@@ -178,7 +181,7 @@ to connect to the database.")
+   $database_options = {
+     'database/sqlite_synchronous'    => { value => $sqlite_synchronous },
+     'database/backend'               => { value => $backend },
+-    'database/connection'            => { value => $connection, secret => true },
++    'database/connection'            => { value => $real_connection, secret => true },
+     'database/slave_connection'      => { value => $slave_connection, secret => true },
+     'database/mysql_sql_mode'        => { value => $mysql_sql_mode },
+     'database/idle_timeout'          => { value => $idle_timeout },
+-- 
+1.8.3.1
+