Handle the hardcoded configuration values
This patch allows to customize the hardcoded configuration values,
as well as introduce new configuration options for horizon services
by configmap template with the specified section:
horizon:
server:
configmap:
API_RESULT_LIMIT: 1000
API_RESULT_PAGE_SIZE: 20
Change-Id: Ia3fa051f3fad4a05c80dc126f608a8bfc5089f63
Related-Prod: PROD-29626
diff --git a/README.rst b/README.rst
index bd06ba5..7e52bf4 100644
--- a/README.rst
+++ b/README.rst
@@ -623,6 +623,16 @@
enabled: true
value: 'value'
+hange default options using configmap template settings
+========================================================
+
+.. code-block:: yaml
+
+ horizon:
+ server:
+ configmap:
+ API_RESULT_LIMIT: 1000
+ API_RESULT_PAGE_SIZE: 20
Upgrades
========
diff --git a/horizon/files/local_settings/ocata_settings.py b/horizon/files/local_settings/ocata_settings.py
index 79597d8..e878934 100644
--- a/horizon/files/local_settings/ocata_settings.py
+++ b/horizon/files/local_settings/ocata_settings.py
@@ -66,3 +66,20 @@
{% include "horizon/files/horizon_settings/_websso_settings.py" %}
{% include "horizon/files/horizon_settings/_ssl_settings.py" %}
{% include "horizon/files/horizon_settings/_django_settings.py"%}
+
+{%- if server.configmap is defined %}
+{%- set _data = server.configmap %}
+{%- for item_name, item in _data.iteritems() %}
+ {%- if item.type is defined and item.type == 'MultiOpt' %}
+ {%- for value in item.get('values').values() %}
+ {%- if value != '<None>' %}
+{{ item_name }} = {{ value }}
+ {%- endif %}
+ {%- endfor %}
+ {%- else %}
+ {%- if item != '<None>' %}
+{{ item_name }} = {{ item }}
+ {%- endif %}
+ {%- endif %}
+{%- endfor %}
+{%- endif %}
diff --git a/horizon/files/local_settings/queens_settings.py b/horizon/files/local_settings/queens_settings.py
index 79597d8..e878934 100644
--- a/horizon/files/local_settings/queens_settings.py
+++ b/horizon/files/local_settings/queens_settings.py
@@ -66,3 +66,20 @@
{% include "horizon/files/horizon_settings/_websso_settings.py" %}
{% include "horizon/files/horizon_settings/_ssl_settings.py" %}
{% include "horizon/files/horizon_settings/_django_settings.py"%}
+
+{%- if server.configmap is defined %}
+{%- set _data = server.configmap %}
+{%- for item_name, item in _data.iteritems() %}
+ {%- if item.type is defined and item.type == 'MultiOpt' %}
+ {%- for value in item.get('values').values() %}
+ {%- if value != '<None>' %}
+{{ item_name }} = {{ value }}
+ {%- endif %}
+ {%- endfor %}
+ {%- else %}
+ {%- if item != '<None>' %}
+{{ item_name }} = {{ item }}
+ {%- endif %}
+ {%- endif %}
+{%- endfor %}
+{%- endif %}
diff --git a/horizon/files/local_settings/rocky_settings.py b/horizon/files/local_settings/rocky_settings.py
index 79597d8..e878934 100644
--- a/horizon/files/local_settings/rocky_settings.py
+++ b/horizon/files/local_settings/rocky_settings.py
@@ -66,3 +66,20 @@
{% include "horizon/files/horizon_settings/_websso_settings.py" %}
{% include "horizon/files/horizon_settings/_ssl_settings.py" %}
{% include "horizon/files/horizon_settings/_django_settings.py"%}
+
+{%- if server.configmap is defined %}
+{%- set _data = server.configmap %}
+{%- for item_name, item in _data.iteritems() %}
+ {%- if item.type is defined and item.type == 'MultiOpt' %}
+ {%- for value in item.get('values').values() %}
+ {%- if value != '<None>' %}
+{{ item_name }} = {{ value }}
+ {%- endif %}
+ {%- endfor %}
+ {%- else %}
+ {%- if item != '<None>' %}
+{{ item_name }} = {{ item }}
+ {%- endif %}
+ {%- endif %}
+{%- endfor %}
+{%- endif %}
diff --git a/tests/pillar/cluster.sls b/tests/pillar/cluster.sls
index ea3822e..bc4230b 100644
--- a/tests/pillar/cluster.sls
+++ b/tests/pillar/cluster.sls
@@ -14,7 +14,7 @@
cache:
engine: memcached
prefix: 'CACHE_HORIZON'
- members:
+ members:
- host: 127.0.0.1
port: 11211
- host: 127.0.0.1
@@ -66,6 +66,9 @@
path: "themes/material"
images_upload_mode: 'direct'
images_allow_location: True
+ configmap:
+ API_RESULT_LIMIT: 1000
+ API_RESULT_PAGE_SIZE: 20
haproxy:
proxy:
diff --git a/tests/pillar/single.sls b/tests/pillar/single.sls
index 34ca7a6..07a42d2 100644
--- a/tests/pillar/single.sls
+++ b/tests/pillar/single.sls
@@ -76,6 +76,9 @@
name: "Material"
description: "Google's Material Design style theme"
path: "themes/material"
+ configmap:
+ API_RESULT_LIMIT: 1000
+ API_RESULT_PAGE_SIZE: 20
apache:
server: