Merge "Make sure kitchen test dependencies formulas are always fetched from correct branch"
diff --git a/README.rst b/README.rst
index 0bc8d4b..ae4d984 100644
--- a/README.rst
+++ b/README.rst
@@ -369,7 +369,24 @@
         cert_file: (certificate path)
         key_file: (key path)
 
+Setup redis coordination_backend url:
+---------------------------
+.. code-block:: yaml
 
+    ceilometer:
+      server:
+        coordination_backend:
+          engine: redis
+          redis:
+            password: pswd
+            user: openstack
+            db: '0'
+            sentinel:
+              host: 127.0.0.1
+              master_name: master_1
+              fallback:
+                - host: 127.0.1.1
+                - host: 127.0.2.1
 
 More Information
 ================
diff --git a/ceilometer/files/mitaka/ceilometer-server.conf.Debian b/ceilometer/files/mitaka/ceilometer-server.conf.Debian
index 79cb291..61ac78f 100644
--- a/ceilometer/files/mitaka/ceilometer-server.conf.Debian
+++ b/ceilometer/files/mitaka/ceilometer-server.conf.Debian
@@ -140,8 +140,19 @@
 # partitioning and will only function correctly if a single instance of that
 # service is running. (string value)
 {%- if server.coordination_backend is defined %}
+{%- if server.coordination_backend.redis is defined and server.coordination_backend.get('engine', redis) == 'redis' %}
+  {%- set conn = server.coordination_backend.redis %}
+  {%- if conn.sentinel is defined %}
+backend_url = {{ conn.get('scheme', 'redis') }}://{{ conn.user }}:{{ conn.password }}@{{ conn.sentinel.host }}:{{ conn.sentinel.get('port', '26379') }}?sentinel={{ conn.sentinel.master_name }}{%
+    if conn.db is defined -%}&db={{ conn.db }}{% endif -%}{%
+    if conn.sentinel.fallback is defined %}{% for member in conn.sentinel.fallback -%}&sentinel_fallback={{ member.host }}:{{ member.get('port', '26379') }}{%- endfor -%}{% endif -%}
+  {%- else %}
+backend_url = {{ conn.get('scheme', 'redis') }}://{{ conn.user }}:{{ conn.password }}@{{ conn.host }}:{{ conn.get('port', '6379') }}{% if conn.db is defined -%}?db={{ conn.db }}{% endif -%}
+  {%- endif %}
+{%- elif server.coordination_backend.url is defined %}
 backend_url = {{ server.coordination_backend.url }}
-{%-  endif %}
+{%- endif %}
+{%- endif %}
 
 # Number of seconds between heartbeats for distributed coordination. (floating
 # point value)
@@ -526,4 +537,4 @@
 #allow_headers = X-Auth-Token,X-Openstack-Request-Id,X-Subject-Token,X-Project-Id,X-Project-Name,X-Project-Domain-Id,X-Project-Domain-Name,X-Domain-Id,X-Domain-Name
 {% if server.get('cors', {}).allow_headers is defined %}
 allow_headers = {{ server.cors.allow_headers }}
-{% endif %}
\ No newline at end of file
+{% endif %}
diff --git a/ceilometer/files/ocata/ceilometer-server.conf.Debian b/ceilometer/files/ocata/ceilometer-server.conf.Debian
index 8619648..c726424 100644
--- a/ceilometer/files/ocata/ceilometer-server.conf.Debian
+++ b/ceilometer/files/ocata/ceilometer-server.conf.Debian
@@ -608,6 +608,20 @@
 # partitioning and will only function correctly if a single instance of that
 # service is running. (string value)
 #backend_url = <None>
+{%- if server.coordination_backend is defined %}
+{%- if server.coordination_backend.redis is defined and server.coordination_backend.get('engine', redis) == 'redis' %}
+  {%- set conn = server.coordination_backend.redis %}
+  {%- if conn.sentinel is defined %}
+backend_url = {{ conn.get('scheme', 'redis') }}://{{ conn.user }}:{{ conn.password }}@{{ conn.sentinel.host }}:{{ conn.sentinel.get('port', '26379') }}?sentinel={{ conn.sentinel.master_name }}{%
+    if conn.db is defined -%}&db={{ conn.db }}{% endif -%}{%
+    if conn.sentinel.fallback is defined %}{% for member in conn.sentinel.fallback -%}&sentinel_fallback={{ member.host }}:{{ member.get('port', '26379') }}{%- endfor -%}{% endif -%}
+  {%- else %}
+backend_url = {{ conn.get('scheme', 'redis') }}://{{ conn.user }}:{{ conn.password }}@{{ conn.host }}:{{ conn.get('port', '6379') }}{% if conn.db is defined -%}?db={{ conn.db }}{% endif -%}
+  {%- endif %}
+{%- elif server.coordination_backend.url is defined %}
+backend_url = {{ server.coordination_backend.url }}
+{%- endif %}
+{%- endif %}
 
 # Number of seconds between heartbeats for distributed coordination. (floating
 # point value)
diff --git a/ceilometer/files/pike/ceilometer-server.conf.Debian b/ceilometer/files/pike/ceilometer-server.conf.Debian
index a88721e..3ab3626 100644
--- a/ceilometer/files/pike/ceilometer-server.conf.Debian
+++ b/ceilometer/files/pike/ceilometer-server.conf.Debian
@@ -33,8 +33,19 @@
 
 
 {%- if server.coordination_backend is defined %}
+{%- if server.coordination_backend.redis is defined and server.coordination_backend.get('engine', redis) == 'redis' %}
+  {%- set conn = server.coordination_backend.redis %}
+  {%- if conn.sentinel is defined %}
+backend_url = {{ conn.get('scheme', 'redis') }}://{{ conn.user }}:{{ conn.password }}@{{ conn.sentinel.host }}:{{ conn.sentinel.get('port', '26379') }}?sentinel={{ conn.sentinel.master_name }}{%
+    if conn.db is defined -%}&db={{ conn.db }}{% endif -%}{%
+    if conn.sentinel.fallback is defined %}{% for member in conn.sentinel.fallback -%}&sentinel_fallback={{ member.host }}:{{ member.get('port', '26379') }}{%- endfor -%}{% endif -%}
+  {%- else %}
+backend_url = {{ conn.get('scheme', 'redis') }}://{{ conn.user }}:{{ conn.password }}@{{ conn.host }}:{{ conn.get('port', '6379') }}{% if conn.db is defined -%}?db={{ conn.db }}{% endif -%}
+  {%- endif %}
+{%- elif server.coordination_backend.url is defined %}
 backend_url = {{ server.coordination_backend.url }}
-{%-  endif %}
+{%- endif %}
+{%- endif %}
 
 {%- if server.get('coordination_backend', {}).heartbeat is defined %}
 heartbeat = {{ server.coordination_backend.heartbeat }}
diff --git a/ceilometer/files/queens/ceilometer-server.conf.Debian b/ceilometer/files/queens/ceilometer-server.conf.Debian
index 8b6e033..5054c06 100644
--- a/ceilometer/files/queens/ceilometer-server.conf.Debian
+++ b/ceilometer/files/queens/ceilometer-server.conf.Debian
@@ -91,8 +91,19 @@
 # service is running. (string value)
 #backend_url = <None>
 {%- if server.coordination_backend is defined %}
+{%- if server.coordination_backend.redis is defined and server.coordination_backend.get('engine', redis) == 'redis' %}
+  {%- set conn = server.coordination_backend.redis %}
+  {%- if conn.sentinel is defined %}
+backend_url = {{ conn.get('scheme', 'redis') }}://{{ conn.user }}:{{ conn.password }}@{{ conn.sentinel.host }}:{{ conn.sentinel.get('port', '26379') }}?sentinel={{ conn.sentinel.master_name }}{%
+    if conn.db is defined -%}&db={{ conn.db }}{% endif -%}{%
+    if conn.sentinel.fallback is defined %}{% for member in conn.sentinel.fallback -%}&sentinel_fallback={{ member.host }}:{{ member.get('port', '26379') }}{%- endfor -%}{% endif -%}
+  {%- else %}
+backend_url = {{ conn.get('scheme', 'redis') }}://{{ conn.user }}:{{ conn.password }}@{{ conn.host }}:{{ conn.get('port', '6379') }}{% if conn.db is defined -%}?db={{ conn.db }}{% endif -%}
+  {%- endif %}
+{%- elif server.coordination_backend.url is defined %}
 backend_url = {{ server.coordination_backend.url }}
-{%-  endif %}
+{%- endif %}
+{%- endif %}
 
 # Number of seconds between checks to see if group membership has changed
 # (floating point value)
diff --git a/ceilometer/files/rocky/ceilometer-server.conf.Debian b/ceilometer/files/rocky/ceilometer-server.conf.Debian
index 011f3c7..0805189 100644
--- a/ceilometer/files/rocky/ceilometer-server.conf.Debian
+++ b/ceilometer/files/rocky/ceilometer-server.conf.Debian
@@ -131,8 +131,19 @@
 # service is running. (string value)
 #backend_url = <None>
 {%- if server.coordination_backend is defined %}
+{%- if server.coordination_backend.redis is defined and server.coordination_backend.get('engine', redis) == 'redis' %}
+  {%- set conn = server.coordination_backend.redis %}
+  {%- if conn.sentinel is defined %}
+backend_url = {{ conn.get('scheme', 'redis') }}://{{ conn.user }}:{{ conn.password }}@{{ conn.sentinel.host }}:{{ conn.sentinel.get('port', '26379') }}?sentinel={{ conn.sentinel.master_name }}{%
+    if conn.db is defined -%}&db={{ conn.db }}{% endif -%}{%
+    if conn.sentinel.fallback is defined %}{% for member in conn.sentinel.fallback -%}&sentinel_fallback={{ member.host }}:{{ member.get('port', '26379') }}{%- endfor -%}{% endif -%}
+  {%- else %}
+backend_url = {{ conn.get('scheme', 'redis') }}://{{ conn.user }}:{{ conn.password }}@{{ conn.host }}:{{ conn.get('port', '6379') }}{% if conn.db is defined -%}?db={{ conn.db }}{% endif -%}
+  {%- endif %}
+{%- elif server.coordination_backend.url is defined %}
 backend_url = {{ server.coordination_backend.url }}
-{%-  endif %}
+{%- endif %}
+{%- endif %}
 
 # Number of seconds between checks to see if group membership has changed
 # (floating point value)
diff --git a/tests/pillar/server_cluster.sls b/tests/pillar/server_cluster.sls
index be5f1bb..db6ce31 100644
--- a/tests/pillar/server_cluster.sls
+++ b/tests/pillar/server_cluster.sls
@@ -59,6 +59,19 @@
         enabled: true
         host: 127.0.0.4
         port: 8086
+    coordination_backend:
+      url: 'redis://127.0.0.1/test'
+      engine: redis
+      redis:
+        password: pswd
+        user: openstack
+        db: '0'
+        sentinel:
+          host: 127.0.0.1
+          master_name: master_1
+          fallback:
+            - host: 127.0.1.1
+            - host: 127.0.2.1
     notification:
       workers: 8
       batch_timeout: 10