Unhardcode nova database connection parameters

[database]/[api_database]
idle_timeout = 180
min_pool_size = 100
max_pool_size = 700
max_overflow = 100
retry_interval = 5
max_retries = -1
db_max_retries = 3
db_retry_interval = 1
connection_debug = 10
pool_timeout = 120

Change-Id: I4bfa9ea7fdd1b91c0b43300df49ba79897bc7392
Related-Prod: PROD-26294
(cherry picked from commit f795791263b56462ca29235cf4d18c75d5f4c0fa)
diff --git a/README.rst b/README.rst
index eec572b..f15f41e 100644
--- a/README.rst
+++ b/README.rst
@@ -1236,6 +1236,24 @@
          password: pswd
 
 
+Nova database connection setup:
+========
+
+.. code-block:: yaml
+
+   nova:
+     controller:
+     enabled: True
+     ...
+       min_pool_size: 100
+       max_pool_size: 700
+       max_overflow: 100
+       retry_interval: 5
+       max_retries: '-1'
+       db_max_retries: 3
+       db_retry_interval: 1
+       connection_debug: 10
+       pool_timeout: 120
 
 Upgrades
 ========
diff --git a/nova/files/ocata/nova-controller.conf.Debian b/nova/files/ocata/nova-controller.conf.Debian
index b7c38ff..a2ba02a 100644
--- a/nova/files/ocata/nova-controller.conf.Debian
+++ b/nova/files/ocata/nova-controller.conf.Debian
@@ -3436,16 +3436,16 @@
 #
 # From nova.conf
 #
-idle_timeout = 180
-min_pool_size = 100
-max_pool_size = 700
-max_overflow = 100
-retry_interval = 5
-max_retries = -1
-db_max_retries = 3
-db_retry_interval = 1
-connection_debug = 10
-pool_timeout = 120
+idle_timeout = {{ controller.database.get('idle_timeout', 180) }}
+min_pool_size = {{ controller.database.get('min_pool_size', 100) }}
+max_pool_size = {{ controller.database.get('max_pool_size', 700) }}
+max_overflow = {{ controller.database.get('max_overflow', 100) }}
+retry_interval = {{ controller.database.get('retry_interval', 5) }}
+max_retries = {{ controller.database.get('max_retries', '-1') }}
+db_max_retries = {{ controller.database.get('db_max_retries', 3) }}
+db_retry_interval = {{ controller.database.get('db_retry_interval', 1) }}
+connection_debug = {{ controller.database.get('connection_debug', 10) }}
+pool_timeout = {{ controller.database.get('pool_timeout', 120) }}
 connection = {{ controller.database.engine }}+pymysql://{{ controller.database.user }}:{{ controller.database.password }}@{{ controller.database.host }}/{{ controller.database.name }}_api?charset=utf8{%- if controller.database.get('ssl',{}).get('enabled',False) %}&ssl_ca={{ controller.database.ssl.get('cacert_file', controller.cacert_file) }}{% endif %}
 
 # The SQLAlchemy connection string to use to connect to the database. (string
@@ -4491,16 +4491,16 @@
 # Reason: Should use config option connection or slave_connection to connect the
 # database.
 #sqlite_db=oslo.sqlite
-idle_timeout = 180
-min_pool_size = 100
-max_pool_size = 700
-max_overflow = 100
-retry_interval = 5
-max_retries = -1
-db_max_retries = 3
-db_retry_interval = 1
-connection_debug = 10
-pool_timeout = 120
+idle_timeout = {{ controller.database.get('idle_timeout', 180) }}
+min_pool_size = {{ controller.database.get('min_pool_size', 100) }}
+max_pool_size = {{ controller.database.get('max_pool_size', 700) }}
+max_overflow = {{ controller.database.get('max_overflow', 100) }}
+retry_interval = {{ controller.database.get('retry_interval', 5) }}
+max_retries = {{ controller.database.get('max_retries', '-1') }}
+db_max_retries = {{ controller.database.get('db_max_retries', 3) }}
+db_retry_interval = {{ controller.database.get('db_retry_interval', 1) }}
+connection_debug = {{ controller.database.get('connection_debug', 10) }}
+pool_timeout = {{ controller.database.get('pool_timeout', 120) }}
 connection = {{ controller.database.engine }}+pymysql://{{ controller.database.user }}:{{ controller.database.password }}@{{ controller.database.host }}/{{ controller.database.name }}?charset=utf8{%- if controller.database.get('ssl',{}).get('enabled',False) %}&ssl_ca={{ controller.database.ssl.get('cacert_file', controller.cacert_file) }}{% endif %}
 
 # If True, SQLite uses synchronous mode. (boolean value)
diff --git a/nova/files/pike/nova-controller.conf.Debian b/nova/files/pike/nova-controller.conf.Debian
index 3bdcfd6..afa2f4b 100644
--- a/nova/files/pike/nova-controller.conf.Debian
+++ b/nova/files/pike/nova-controller.conf.Debian
@@ -3486,16 +3486,16 @@
 #
 # From nova.conf
 #
-idle_timeout = 180
-min_pool_size = 100
-max_pool_size = 700
-max_overflow = 100
-retry_interval = 5
-max_retries = -1
-db_max_retries = 3
-db_retry_interval = 1
-connection_debug = 10
-pool_timeout = 120
+idle_timeout = {{ controller.database.get('idle_timeout', 180) }}
+min_pool_size = {{ controller.database.get('min_pool_size', 100) }}
+max_pool_size = {{ controller.database.get('max_pool_size', 700) }}
+max_overflow = {{ controller.database.get('max_overflow', 100) }}
+retry_interval = {{ controller.database.get('retry_interval', 5) }}
+max_retries = {{ controller.database.get('max_retries', '-1') }}
+db_max_retries = {{ controller.database.get('db_max_retries', 3) }}
+db_retry_interval = {{ controller.database.get('db_retry_interval', 1) }}
+connection_debug = {{ controller.database.get('connection_debug', 10) }}
+pool_timeout = {{ controller.database.get('pool_timeout', 120) }}
 connection = {{ controller.database.engine }}+pymysql://{{ controller.database.user }}:{{ controller.database.password }}@{{ controller.database.host }}/{{ controller.database.name }}_api?charset=utf8{{ connection_x509_ssl_option|string }}
 
 # The SQLAlchemy connection string to use to connect to the database. (string
@@ -4540,16 +4540,16 @@
 # Reason: Should use config option connection or slave_connection to connect the
 # database.
 #sqlite_db=oslo.sqlite
-idle_timeout = 180
-min_pool_size = 100
-max_pool_size = 700
-max_overflow = 100
-retry_interval = 5
-max_retries = -1
-db_max_retries = 3
-db_retry_interval = 1
-connection_debug = 10
-pool_timeout = 120
+idle_timeout = {{ controller.database.get('idle_timeout', 180) }}
+min_pool_size = {{ controller.database.get('min_pool_size', 100) }}
+max_pool_size = {{ controller.database.get('max_pool_size', 700) }}
+max_overflow = {{ controller.database.get('max_overflow', 100) }}
+retry_interval = {{ controller.database.get('retry_interval', 5) }}
+max_retries = {{ controller.database.get('max_retries', '-1') }}
+db_max_retries = {{ controller.database.get('db_max_retries', 3) }}
+db_retry_interval = {{ controller.database.get('db_retry_interval', 1) }}
+connection_debug = {{ controller.database.get('connection_debug', 10) }}
+pool_timeout = {{ controller.database.get('pool_timeout', 120) }}
 connection = {{ controller.database.engine }}+pymysql://{{ controller.database.user }}:{{ controller.database.password }}@{{ controller.database.host }}/{{ controller.database.name }}?charset=utf8{{ connection_x509_ssl_option|string }}
 
 # If True, SQLite uses synchronous mode. (boolean value)
diff --git a/tests/pillar/control_cluster.sls b/tests/pillar/control_cluster.sls
index 97e8e43..fdfd590 100644
--- a/tests/pillar/control_cluster.sls
+++ b/tests/pillar/control_cluster.sls
@@ -24,6 +24,16 @@
       name: nova
       user: nova
       password: password
+      idle_timeout: 180
+      min_pool_size: 100
+      max_pool_size: 700
+      max_overflow: 100
+      retry_interval: 5
+      max_retries: '-1'
+      db_max_retries: 3
+      db_retry_interval: 1
+      connection_debug: 10
+      pool_timeout: 120
     identity:
       engine: keystone
       region: RegionOne
diff --git a/tests/pillar/control_single.sls b/tests/pillar/control_single.sls
index 443e821..9423b53 100644
--- a/tests/pillar/control_single.sls
+++ b/tests/pillar/control_single.sls
@@ -36,6 +36,16 @@
       name: nova
       user: nova
       password: password
+      idle_timeout: 180
+      min_pool_size: 100
+      max_pool_size: 700
+      max_overflow: 100
+      retry_interval: 5
+      max_retries: '-1'
+      db_max_retries: 3
+      db_retry_interval: 1
+      connection_debug: 10
+      pool_timeout: 120
     identity:
       engine: keystone
       region: RegionOne