Handle the hardcoded configuration values

This patch allows to customize the hardcoded configuration values,
as well as introduce new configuration options for cinder services
by configmap template with the specified section:

  cinder:
    controller:
      configmap:
        DEFAULT:
          quota_volumes: 15
          quota_snapshots: 15
          quota_consistencygroups: 15
          quota_groups: 15
          quota_gigabytes: 1500
          quota_backups: 15
          quota_backup_gigabytes: 1500
          reservation_expire: 86400
          reservation_clean_interval: 86400
          until_refresh: 0
          max_age: 0
          quota_driver: cinder.quota.DbQuotaDriver
          use_default_quota_class: true
          per_volume_size_limit: 100

Change-Id: Ia8d5e33ea9532c8b670bc7ba5ffd36bb527cd104
Related-Prod: PROD-29040
diff --git a/README.rst b/README.rst
index 35a5188..5b55e69 100644
--- a/README.rst
+++ b/README.rst
@@ -933,6 +933,30 @@
          username: cinder
          password: pswd
 
+Change default resource quotas using configmap template settings
+========
+
+.. code-block:: yaml
+
+    cinder:
+      controller:
+        configmap:
+          DEFAULT:
+            quota_volumes: 15
+            quota_snapshots: 15
+            quota_consistencygroups: 15
+            quota_groups: 15
+            quota_gigabytes: 1500
+            quota_backups: 15
+            quota_backup_gigabytes: 1500
+            reservation_expire: 86400
+            reservation_clean_interval: 86400
+            until_refresh: 0
+            max_age: 0
+            quota_driver: cinder.quota.DbQuotaDriver
+            use_default_quota_class: true
+            per_volume_size_limit: 100
+
 Upgrades
 ========
 
diff --git a/cinder/files/ocata/cinder.conf.controller.Debian b/cinder/files/ocata/cinder.conf.controller.Debian
index 0de1b9c..fd636bc 100644
--- a/cinder/files/ocata/cinder.conf.controller.Debian
+++ b/cinder/files/ocata/cinder.conf.controller.Debian
@@ -270,3 +270,8 @@
 {%- if controller.cors.allow_headers is defined %}
 allow_headers = {{ controller.cors.allow_headers }}
 {%- endif %}
+
+{%- if controller.configmap is defined %}
+{%- set _data = controller.configmap %}
+{%- include "oslo_templates/files/configmap/configmap.conf" %}
+{%- endif %}
diff --git a/cinder/files/ocata/cinder.conf.volume.Debian b/cinder/files/ocata/cinder.conf.volume.Debian
index ac36bf6..395078c 100644
--- a/cinder/files/ocata/cinder.conf.volume.Debian
+++ b/cinder/files/ocata/cinder.conf.volume.Debian
@@ -206,3 +206,8 @@
 {%- endfor %}
 
 {%- endif %}
+
+{%- if volume.configmap is defined %}
+{%- set _data = volume.configmap %}
+{%- include "oslo_templates/files/configmap/configmap.conf" %}
+{%- endif %}
diff --git a/cinder/files/pike/cinder.conf.controller.Debian b/cinder/files/pike/cinder.conf.controller.Debian
index 15e1c44..247109a 100644
--- a/cinder/files/pike/cinder.conf.controller.Debian
+++ b/cinder/files/pike/cinder.conf.controller.Debian
@@ -296,3 +296,8 @@
 {%- if controller.cors.allow_headers is defined %}
 allow_headers = {{ controller.cors.allow_headers }}
 {%- endif %}
+
+{%- if controller.configmap is defined %}
+{%- set _data = controller.configmap %}
+{%- include "oslo_templates/files/configmap/configmap.conf" %}
+{%- endif %}
diff --git a/cinder/files/pike/cinder.conf.volume.Debian b/cinder/files/pike/cinder.conf.volume.Debian
index 6b05671..499cc77 100644
--- a/cinder/files/pike/cinder.conf.volume.Debian
+++ b/cinder/files/pike/cinder.conf.volume.Debian
@@ -231,3 +231,8 @@
 {%- endfor %}
 
 {%- endif %}
+
+{%- if volume.configmap is defined %}
+{%- set _data = volume.configmap %}
+{%- include "oslo_templates/files/configmap/configmap.conf" %}
+{%- endif %}
diff --git a/cinder/files/queens/cinder.conf.controller.Debian b/cinder/files/queens/cinder.conf.controller.Debian
index ccc7e05..53b02d4 100644
--- a/cinder/files/queens/cinder.conf.controller.Debian
+++ b/cinder/files/queens/cinder.conf.controller.Debian
@@ -3356,3 +3356,8 @@
 {%- set _data = controller.cache %}
 {%- include "oslo_templates/files/queens/oslo/_cache.conf" %}
 {%- endif %}
+
+{%- if controller.configmap is defined %}
+{%- set _data = controller.configmap %}
+{%- include "oslo_templates/files/configmap/configmap.conf" %}
+{%- endif %}
diff --git a/cinder/files/queens/cinder.conf.volume.Debian b/cinder/files/queens/cinder.conf.volume.Debian
index dfa02e3..0d4cf18 100644
--- a/cinder/files/queens/cinder.conf.volume.Debian
+++ b/cinder/files/queens/cinder.conf.volume.Debian
@@ -3359,3 +3359,8 @@
 {%- set _data = volume.cache %}
 {%- include "oslo_templates/files/queens/oslo/_cache.conf" %}
 {%- endif %}
+
+{%- if volume.configmap is defined %}
+{%- set _data = volume.configmap %}
+{%- include "oslo_templates/files/configmap/configmap.conf" %}
+{%- endif %}
diff --git a/cinder/files/rocky/cinder.conf.controller.Debian b/cinder/files/rocky/cinder.conf.controller.Debian
index 8388c10..2c5bbaa 100644
--- a/cinder/files/rocky/cinder.conf.controller.Debian
+++ b/cinder/files/rocky/cinder.conf.controller.Debian
@@ -4098,3 +4098,8 @@
 
 # SSL Enabled/Disabled (boolean value)
 #use_ssl = false
+
+{%- if controller.configmap is defined %}
+{%- set _data = controller.configmap %}
+{%- include "oslo_templates/files/configmap/configmap.conf" %}
+{%- endif %}
diff --git a/cinder/files/rocky/cinder.conf.volume.Debian b/cinder/files/rocky/cinder.conf.volume.Debian
index a60923d..65d3ff5 100644
--- a/cinder/files/rocky/cinder.conf.volume.Debian
+++ b/cinder/files/rocky/cinder.conf.volume.Debian
@@ -4101,3 +4101,8 @@
 
 # SSL Enabled/Disabled (boolean value)
 #use_ssl = false
+
+{%- if volume.configmap is defined %}
+{%- set _data = volume.configmap %}
+{%- include "oslo_templates/files/configmap/configmap.conf" %}
+{%- endif %}
diff --git a/tests/pillar/control_cluster.sls b/tests/pillar/control_cluster.sls
index d17c6eb..bb8315e 100644
--- a/tests/pillar/control_cluster.sls
+++ b/tests/pillar/control_cluster.sls
@@ -77,7 +77,22 @@
       port: 22
       user: username
       password: pass
-
+    configmap:
+      DEFAULT:
+        quota_volumes: 15
+        quota_snapshots: 15
+        quota_consistencygroups: 15
+        quota_groups: 15
+        quota_gigabytes: 1500
+        quota_backups: 15
+        quota_backup_gigabytes: 1500
+        reservation_expire: 86400
+        reservation_clean_interval: 86400
+        until_refresh: 0
+        max_age: 0
+        quota_driver: cinder.quota.DbQuotaDriver
+        use_default_quota_class: true
+        per_volume_size_limit: 100
     audit:
       filter_factory: 'keystonemiddleware.audit:filter_factory'
       map_file: '/etc/pycadf/cinder_api_audit_map.conf'