[RabbitMQ] Parametrized message queue hosts to enable client-side HA.

Change-Id: Ie092a7e53d0ae4efcd2b6b56c0854723fd27863f
diff --git a/README.rst b/README.rst
index ee64e32..87f1d75 100644
--- a/README.rst
+++ b/README.rst
@@ -63,6 +63,7 @@
         metadata:
           password: password
 
+
 Nova services from custom package repository
 
 .. code-block:: yaml
@@ -75,6 +76,26 @@
           address: http://...
       ....
 
+
+Client-side RabbitMQ HA setup
+
+.. code-block:: yaml
+
+   nova:
+     controller:
+       ....
+       message_queue:
+         engine: rabbitmq
+         members:
+           - host: 10.0.16.1
+           - host: 10.0.16.2
+           - host: 10.0.16.3
+         user: openstack
+         password: pwd
+         virtual_host: '/openstack'
+      ....
+
+
 Compute nodes
 -------------
 
@@ -133,6 +154,7 @@
           max_files: 4096
           max_processes: 4096
 
+
 Nova services on compute node with OpenContrail
 
 .. code-block:: yaml
@@ -143,6 +165,7 @@
         ...
         networking: contrail
 
+
 Nova services on compute node with memcached caching
 
 .. code-block:: yaml
@@ -159,6 +182,27 @@
           - host: 127.0.0.1
             port: 11211
 
+
+Client-side RabbitMQ HA setup
+
+.. code-block:: yaml
+
+   nova:
+     controller:
+       ....
+       message_queue:
+         engine: rabbitmq
+         members:
+           - host: 10.0.16.1
+           - host: 10.0.16.2
+           - host: 10.0.16.3
+         user: openstack
+         password: pwd
+         virtual_host: '/openstack'
+      ....
+
+
+
 Read more
 =========
 
diff --git a/nova/files/kilo/nova-compute.conf.Debian b/nova/files/kilo/nova-compute.conf.Debian
index a17f282..9c4a352 100644
--- a/nova/files/kilo/nova-compute.conf.Debian
+++ b/nova/files/kilo/nova-compute.conf.Debian
@@ -141,10 +141,16 @@
 {%- endif %}
 
 [oslo_messaging_rabbit]
-
+{%- if compute.message_queue.members is defined %}
+rabbit_hosts = {% for member in compute.message_queue.members -%}
+                   {{ member.host }}:{{ member.get('port', 5672) }}
+                   {%- if not loop.last -%},{%- endif -%}
+               {%- endfor -%}
+{%- else %}
 rabbit_host = {{ compute.message_queue.host }}
 rabbit_port = {{ compute.message_queue.port }}
-rabbit_hosts={{ compute.message_queue.host }}:{{ compute.message_queue.port }}
+{%- endif %}
+
 rabbit_userid = {{ compute.message_queue.user }}
 rabbit_password = {{ compute.message_queue.password }}
 rabbit_virtual_host = {{ compute.message_queue.virtual_host }}
diff --git a/nova/files/kilo/nova-controller.conf.Debian b/nova/files/kilo/nova-controller.conf.Debian
index 864056c..fe39363 100644
--- a/nova/files/kilo/nova-controller.conf.Debian
+++ b/nova/files/kilo/nova-controller.conf.Debian
@@ -118,9 +118,16 @@
 lock_path = /var/lib/nova/tmp
 
 [oslo_messaging_rabbit]
+{%- if controller.message_queue.members is defined %}
+rabbit_hosts = {% for member in controller.message_queue.members -%}
+                   {{ member.host }}:{{ member.get('port', 5672) }}
+                   {%- if not loop.last -%},{%- endif -%}
+               {%- endfor -%}
+{%- else %}
 rabbit_host = {{ controller.message_queue.host }}
 rabbit_port = {{ controller.message_queue.port }}
-rabbit_hosts={{ controller.message_queue.host }}:{{ controller.message_queue.port }}
+{%- endif %}
+
 rabbit_userid = {{ controller.message_queue.user }}
 rabbit_password = {{ controller.message_queue.password }}
 rabbit_virtual_host = {{ controller.message_queue.virtual_host }}
diff --git a/nova/files/liberty/nova-compute.conf.Debian b/nova/files/liberty/nova-compute.conf.Debian
index 0da4ace..85ed88b 100644
--- a/nova/files/liberty/nova-compute.conf.Debian
+++ b/nova/files/liberty/nova-compute.conf.Debian
@@ -141,10 +141,16 @@
 {%- endif %}
 
 [oslo_messaging_rabbit]
-
+{%- if compute.message_queue.members is defined %}
+rabbit_hosts = {% for member in compute.message_queue.members -%}
+                   {{ member.host }}:{{ member.get('port', 5672) }}
+                   {%- if not loop.last -%},{%- endif -%}
+               {%- endfor -%}
+{%- else %}
 rabbit_host = {{ compute.message_queue.host }}
 rabbit_port = {{ compute.message_queue.port }}
-rabbit_hosts={{ compute.message_queue.host }}:{{ compute.message_queue.port }}
+{%- endif %}
+
 rabbit_userid = {{ compute.message_queue.user }}
 rabbit_password = {{ compute.message_queue.password }}
 rabbit_virtual_host = {{ compute.message_queue.virtual_host }}
diff --git a/nova/files/liberty/nova-controller.conf.Debian b/nova/files/liberty/nova-controller.conf.Debian
index d74330c..d0b970b 100644
--- a/nova/files/liberty/nova-controller.conf.Debian
+++ b/nova/files/liberty/nova-controller.conf.Debian
@@ -117,9 +117,16 @@
 lock_path = /var/lib/nova/tmp
 
 [oslo_messaging_rabbit]
+{%- if controller.message_queue.members is defined %}
+rabbit_hosts = {% for member in controller.message_queue.members -%}
+                   {{ member.host }}:{{ member.get('port', 5672) }}
+                   {%- if not loop.last -%},{%- endif -%}
+               {%- endfor -%}
+{%- else %}
 rabbit_host = {{ controller.message_queue.host }}
 rabbit_port = {{ controller.message_queue.port }}
-rabbit_hosts={{ controller.message_queue.host }}:{{ controller.message_queue.port }}
+{%- endif %}
+
 rabbit_userid = {{ controller.message_queue.user }}
 rabbit_password = {{ controller.message_queue.password }}
 rabbit_virtual_host = {{ controller.message_queue.virtual_host }}
diff --git a/nova/files/mitaka/nova-compute.conf.Debian b/nova/files/mitaka/nova-compute.conf.Debian
index 230f890..ef8c184 100644
--- a/nova/files/mitaka/nova-compute.conf.Debian
+++ b/nova/files/mitaka/nova-compute.conf.Debian
@@ -111,10 +111,16 @@
 {%- endif %}
 
 [oslo_messaging_rabbit]
-
+{%- if compute.message_queue.members is defined %}
+rabbit_hosts = {% for member in compute.message_queue.members -%}
+                   {{ member.host }}:{{ member.get('port', 5672) }}
+                   {%- if not loop.last -%},{%- endif -%}
+               {%- endfor -%}
+{%- else %}
 rabbit_host = {{ compute.message_queue.host }}
 rabbit_port = {{ compute.message_queue.port }}
-rabbit_hosts={{ compute.message_queue.host }}:{{ compute.message_queue.port }}
+{%- endif %}
+
 rabbit_userid = {{ compute.message_queue.user }}
 rabbit_password = {{ compute.message_queue.password }}
 rabbit_virtual_host = {{ compute.message_queue.virtual_host }}
diff --git a/nova/files/mitaka/nova-controller.conf.Debian b/nova/files/mitaka/nova-controller.conf.Debian
index b6f5f78..37a72a3 100644
--- a/nova/files/mitaka/nova-controller.conf.Debian
+++ b/nova/files/mitaka/nova-controller.conf.Debian
@@ -93,9 +93,16 @@
 lock_path = /var/lib/nova/tmp
 
 [oslo_messaging_rabbit]
+{%- if controller.message_queue.members is defined %}
+rabbit_hosts = {% for member in controller.message_queue.members -%}
+                   {{ member.host }}:{{ member.get('port', 5672) }}
+                   {%- if not loop.last -%},{%- endif -%}
+               {%- endfor -%}
+{%- else %}
 rabbit_host = {{ controller.message_queue.host }}
 rabbit_port = {{ controller.message_queue.port }}
-rabbit_hosts={{ controller.message_queue.host }}:{{ controller.message_queue.port }}
+{%- endif %}
+
 rabbit_userid = {{ controller.message_queue.user }}
 rabbit_password = {{ controller.message_queue.password }}
 rabbit_virtual_host = {{ controller.message_queue.virtual_host }}
diff --git a/tests/pillar/compute_cluster.sls b/tests/pillar/compute_cluster.sls
index ea8289e..bbfb87c 100644
--- a/tests/pillar/compute_cluster.sls
+++ b/tests/pillar/compute_cluster.sls
@@ -26,8 +26,10 @@
       tenant: service
     message_queue:
       engine: rabbitmq
-      host: 127.0.0.1
-      port: 5672
+      members:
+      - host: 127.0.0.1
+      - host: 127.0.1.1
+      - host: 127.0.2.1
       user: openstack
       password: password
       virtual_host: '/openstack'
diff --git a/tests/pillar/control_cluster.sls b/tests/pillar/control_cluster.sls
index 5e33712..018f222 100644
--- a/tests/pillar/control_cluster.sls
+++ b/tests/pillar/control_cluster.sls
@@ -33,8 +33,10 @@
       tenant: service
     message_queue:
       engine: rabbitmq
-      host: 127.0.0.1
-      port: 5672
+      members:
+      - host: 127.0.0.1
+      - host: 127.0.1.1
+      - host: 127.0.2.1
       user: openstack
       password: password
       virtual_host: '/openstack'