Handle the hardcoded configuration values

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

    glance:
      server:
        configmap:
          glace_api:
            DEFAULT:
              image_member_quota = 128
              image_property_quota = 128
              image_tag_quota = 128
              image_location_quota = 10
              user_storage_quota = 0
          glace_registry:
            DEFAULT:
              image_member_quota = 128
              image_property_quota = 128
              image_tag_quota = 128
              image_location_quota = 10
              user_storage_quota = 0
          ...

Change-Id: Ie74a66321ec39d154cac95d3315381c395b5582c
Related-Prod: PROD-29040
diff --git a/README.rst b/README.rst
index 0c90281..8fde47d 100644
--- a/README.rst
+++ b/README.rst
@@ -354,7 +354,7 @@
           cache_cleaner:
             hour: '5'
             minute: '30'
-            daymonth: '*/2'
+            daymonth: '\*/2'
 
 
 Image cache settings
@@ -477,6 +477,29 @@
         ...
         show_multiple_locations: True
 
+Change default resource quotas using configmap template settings
+========
+
+.. code-block:: yaml
+
+    glance:
+      server:
+        configmap:
+          glace_api:
+            DEFAULT:
+              image_member_quota = 128
+              image_property_quota = 128
+              image_tag_quota = 128
+              image_location_quota = 10
+              user_storage_quota = 0
+          glace_registry:
+            DEFAULT:
+              image_member_quota = 128
+              image_property_quota = 128
+              image_tag_quota = 128
+              image_location_quota = 10
+              user_storage_quota = 0
+
 Usage
 =====
 
diff --git a/glance/files/ocata/glance-api.conf.Debian b/glance/files/ocata/glance-api.conf.Debian
index c5ad158..0944a04 100644
--- a/glance/files/ocata/glance-api.conf.Debian
+++ b/glance/files/ocata/glance-api.conf.Debian
@@ -4553,3 +4553,8 @@
 [barbican]
 auth_endpoint = {{ server.identity.get('protocol', 'http') }}://{{ server.identity.get('host', 'localhost') }}:{{ server.identity.get('port', '5000') }}/v3
 {%- endif %}
+
+{%- if server.get('configmap', {}).glance_api is defined %}
+{%- set _data = server.configmap.glance_api %}
+{%- include "oslo_templates/files/configmap/configmap.conf" %}
+{%- endif %}
diff --git a/glance/files/ocata/glance-cache.conf.Debian b/glance/files/ocata/glance-cache.conf.Debian
index ac13f7a..0112eae 100644
--- a/glance/files/ocata/glance-cache.conf.Debian
+++ b/glance/files/ocata/glance-cache.conf.Debian
@@ -2309,3 +2309,8 @@
 # valued)
 # Deprecated group/name - [DEFAULT]/policy_dirs
 #policy_dirs = policy.d
+
+{%- if server.get('configmap', {}).glance_cache is defined %}
+{%- set _data = server.configmap.glance_cache %}
+{%- include "oslo_templates/files/configmap/configmap.conf" %}
+{%- endif %}
diff --git a/glance/files/ocata/glance-glare.conf.Debian b/glance/files/ocata/glance-glare.conf.Debian
index e7c503d..a026113 100644
--- a/glance/files/ocata/glance-glare.conf.Debian
+++ b/glance/files/ocata/glance-glare.conf.Debian
@@ -2326,3 +2326,8 @@
 # * messaging://: use oslo_messaging driver for sending notifications.
 #  (string value)
 #connection_string = messaging://
+
+{%- if server.get('configmap', {}).glance_glare is defined %}
+{%- set _data = server.configmap.glance_glare %}
+{%- include "oslo_templates/files/configmap/configmap.conf" %}
+{%- endif %}
diff --git a/glance/files/ocata/glance-registry.conf.Debian b/glance/files/ocata/glance-registry.conf.Debian
index 889bb93..2ae2d98 100644
--- a/glance/files/ocata/glance-registry.conf.Debian
+++ b/glance/files/ocata/glance-registry.conf.Debian
@@ -2076,3 +2076,8 @@
 # * messaging://: use oslo_messaging driver for sending notifications.
 #  (string value)
 #connection_string = messaging://
+
+{%- if server.get('configmap', {}).glance_registry is defined %}
+{%- set _data = server.configmap.glance_registry %}
+{%- include "oslo_templates/files/configmap/configmap.conf" %}
+{%- endif %}
diff --git a/glance/files/ocata/glance-scrubber.conf.Debian b/glance/files/ocata/glance-scrubber.conf.Debian
index 8d4d5c1..a406bc5 100644
--- a/glance/files/ocata/glance-scrubber.conf.Debian
+++ b/glance/files/ocata/glance-scrubber.conf.Debian
@@ -2468,3 +2468,8 @@
 # valued)
 # Deprecated group/name - [DEFAULT]/policy_dirs
 #policy_dirs = policy.d
+
+{%- if server.get('configmap', {}).glance_scrubber is defined %}
+{%- set _data = server.configmap.glance_scrubber %}
+{%- include "oslo_templates/files/configmap/configmap.conf" %}
+{%- endif %}
diff --git a/glance/files/pike/glance-api.conf.Debian b/glance/files/pike/glance-api.conf.Debian
index f4a6b1c..6b5de03 100644
--- a/glance/files/pike/glance-api.conf.Debian
+++ b/glance/files/pike/glance-api.conf.Debian
@@ -4406,3 +4406,8 @@
 [barbican]
 auth_endpoint = {{ server.identity.get('protocol', 'http') }}://{{ server.identity.get('host', 'localhost') }}:{{ server.identity.get('port', '5000') }}/v3
 {%- endif %}
+
+{%- if server.get('configmap', {}).glance_api is defined %}
+{%- set _data = server.configmap.glance_api %}
+{%- include "oslo_templates/files/configmap/configmap.conf" %}
+{%- endif %}
diff --git a/glance/files/pike/glance-cache.conf.Debian b/glance/files/pike/glance-cache.conf.Debian
index 8aa0445..045fdaa 100644
--- a/glance/files/pike/glance-cache.conf.Debian
+++ b/glance/files/pike/glance-cache.conf.Debian
@@ -2139,3 +2139,8 @@
 # valued)
 # Deprecated group/name - [DEFAULT]/policy_dirs
 #policy_dirs = policy.d
+
+{%- if server.get('configmap', {}).glance_cache is defined %}
+{%- set _data = server.configmap.glance_cache %}
+{%- include "oslo_templates/files/configmap/configmap.conf" %}
+{%- endif %}
diff --git a/glance/files/pike/glance-registry.conf.Debian b/glance/files/pike/glance-registry.conf.Debian
index 6128221..34777d4 100644
--- a/glance/files/pike/glance-registry.conf.Debian
+++ b/glance/files/pike/glance-registry.conf.Debian
@@ -2099,3 +2099,8 @@
 # * messaging://: use oslo_messaging driver for sending notifications.
 #  (string value)
 #connection_string = messaging://
+
+{%- if server.get('configmap', {}).glance_registry is defined %}
+{%- set _data = server.configmap.glance_registry %}
+{%- include "oslo_templates/files/configmap/configmap.conf" %}
+{%- endif %}
diff --git a/glance/files/pike/glance-scrubber.conf.Debian b/glance/files/pike/glance-scrubber.conf.Debian
index 8d4d5c1..a406bc5 100644
--- a/glance/files/pike/glance-scrubber.conf.Debian
+++ b/glance/files/pike/glance-scrubber.conf.Debian
@@ -2468,3 +2468,8 @@
 # valued)
 # Deprecated group/name - [DEFAULT]/policy_dirs
 #policy_dirs = policy.d
+
+{%- if server.get('configmap', {}).glance_scrubber is defined %}
+{%- set _data = server.configmap.glance_scrubber %}
+{%- include "oslo_templates/files/configmap/configmap.conf" %}
+{%- endif %}
diff --git a/glance/files/queens/glance-api.conf.Debian b/glance/files/queens/glance-api.conf.Debian
index d092a42..57f76b1 100644
--- a/glance/files/queens/glance-api.conf.Debian
+++ b/glance/files/queens/glance-api.conf.Debian
@@ -3629,3 +3629,8 @@
 [cache]
 {%- include "oslo_templates/files/queens/oslo/_cache.conf" %}
 {%- endif %}
+
+{%- if server.get('configmap', {}).glance_api is defined %}
+{%- set _data = server.configmap.glance_api %}
+{%- include "oslo_templates/files/configmap/configmap.conf" %}
+{%- endif %}
diff --git a/glance/files/queens/glance-cache.conf.Debian b/glance/files/queens/glance-cache.conf.Debian
index 29f79f9..ffa0ed6 100644
--- a/glance/files/queens/glance-cache.conf.Debian
+++ b/glance/files/queens/glance-cache.conf.Debian
@@ -2438,3 +2438,7 @@
 {%- include "oslo_templates/files/queens/oslo/_policy.conf" %}
 {%- endif %}
 
+{%- if server.get('configmap', {}).glance_cache is defined %}
+{%- set _data = server.configmap.glance_cache %}
+{%- include "oslo_templates/files/configmap/configmap.conf" %}
+{%- endif %}
diff --git a/glance/files/queens/glance-registry.conf.Debian b/glance/files/queens/glance-registry.conf.Debian
index 7450a6d..ff0668a 100644
--- a/glance/files/queens/glance-registry.conf.Debian
+++ b/glance/files/queens/glance-registry.conf.Debian
@@ -1105,3 +1105,8 @@
 [cache]
 {%- include "oslo_templates/files/queens/oslo/_cache.conf" %}
 {%- endif %}
+
+{%- if server.get('configmap', {}).glance_registry is defined %}
+{%- set _data = server.configmap.glance_registry %}
+{%- include "oslo_templates/files/configmap/configmap.conf" %}
+{%- endif %}
diff --git a/glance/files/queens/glance-scrubber.conf.Debian b/glance/files/queens/glance-scrubber.conf.Debian
index 7bd8e6b..c91d385 100644
--- a/glance/files/queens/glance-scrubber.conf.Debian
+++ b/glance/files/queens/glance-scrubber.conf.Debian
@@ -2278,3 +2278,8 @@
 {%- set _data = server.oslo_policy %}
 {%- include "oslo_templates/files/queens/oslo/_policy.conf" %}
 {%- endif %}
+
+{%- if server.get('configmap', {}).glance_scrubber is defined %}
+{%- set _data = server.configmap.glance_scrubber %}
+{%- include "oslo_templates/files/configmap/configmap.conf" %}
+{%- endif %}
diff --git a/glance/files/rocky/glance-api.conf.Debian b/glance/files/rocky/glance-api.conf.Debian
index 88786ee..dc83a0d 100644
--- a/glance/files/rocky/glance-api.conf.Debian
+++ b/glance/files/rocky/glance-api.conf.Debian
@@ -3412,3 +3412,8 @@
 [cache]
 {%- include "oslo_templates/files/" ~ server.version ~ "/oslo/_cache.conf" %}
 {%- endif %}
+
+{%- if server.get('configmap', {}).glance_api is defined %}
+{%- set _data = server.configmap.glance_api %}
+{%- include "oslo_templates/files/configmap/configmap.conf" %}
+{%- endif %}
diff --git a/glance/files/rocky/glance-cache.conf.Debian b/glance/files/rocky/glance-cache.conf.Debian
index ba82250..d9aae37 100644
--- a/glance/files/rocky/glance-cache.conf.Debian
+++ b/glance/files/rocky/glance-cache.conf.Debian
@@ -2239,3 +2239,8 @@
 {%- set _data = server.oslo_policy %}
 {%- include "oslo_templates/files/" ~ server.version ~ "/oslo/_policy.conf" %}
 {%- endif %}
+
+{%- if server.get('configmap', {}).glance_cache is defined %}
+{%- set _data = server.configmap.glance_cache %}
+{%- include "oslo_templates/files/configmap/configmap.conf" %}
+{%- endif %}
diff --git a/glance/files/rocky/glance-registry.conf.Debian b/glance/files/rocky/glance-registry.conf.Debian
index 29122f9..e79696e 100644
--- a/glance/files/rocky/glance-registry.conf.Debian
+++ b/glance/files/rocky/glance-registry.conf.Debian
@@ -1691,3 +1691,8 @@
 [cache]
 {%- include "oslo_templates/files/" ~ server.version ~ "/oslo/_cache.conf" %}
 {%- endif %}
+
+{%- if server.get('configmap', {}).glance_registry is defined %}
+{%- set _data = server.configmap.glance_registry %}
+{%- include "oslo_templates/files/configmap/configmap.conf" %}
+{%- endif %}
diff --git a/glance/files/rocky/glance-scrubber.conf.Debian b/glance/files/rocky/glance-scrubber.conf.Debian
index 31af79d..103748c 100644
--- a/glance/files/rocky/glance-scrubber.conf.Debian
+++ b/glance/files/rocky/glance-scrubber.conf.Debian
@@ -2113,3 +2113,8 @@
 {%- set _data = server.oslo_policy %}
 {%- include "oslo_templates/files/" ~ server.version ~ "/oslo/_policy.conf" %}
 {%- endif %}
+
+{%- if server.get('configmap', {}).glance_scrubber is defined %}
+{%- set _data = server.configmap.glance_scrubber %}
+{%- include "oslo_templates/files/configmap/configmap.conf" %}
+{%- endif %}
diff --git a/tests/pillar/cluster.sls b/tests/pillar/cluster.sls
index 45adbdb..4a9b52b 100644
--- a/tests/pillar/cluster.sls
+++ b/tests/pillar/cluster.sls
@@ -76,3 +76,18 @@
         strategy: ENCRYPT
         secret_key: secret
     show_multiple_locations: True
+    configmap:
+      glace_api:
+        DEFAULT:
+          image_member_quota = 128
+          image_property_quota = 128
+          image_tag_quota = 128
+          image_location_quota = 10
+          user_storage_quota = 0
+      glace_registry:
+        DEFAULT:
+          image_member_quota = 128
+          image_property_quota = 128
+          image_tag_quota = 128
+          image_location_quota = 10
+          user_storage_quota = 0