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

Change-Id: I672be41e4149f92c4debe4d75492b0cf852eb8d1
diff --git a/README.rst b/README.rst
index 6d6eeb0..15c19cd 100644
--- a/README.rst
+++ b/README.rst
@@ -88,6 +88,43 @@
             multihost: true
             multipath: true
             pool: SAS7K2
+            w
+
+Client-side RabbitMQ HA setup for controller
+
+.. code-block:: yaml
+
+    cinder:
+      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'
+        ....
+
+Client-side RabbitMQ HA setup for volume component
+
+.. code-block:: yaml
+
+    cinder:
+      volume:
+        ....
+        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'
+        ....
 
 Cinder setup with zeroing deleted volumes
 
diff --git a/cinder/files/kilo/cinder.conf.controller.Debian b/cinder/files/kilo/cinder.conf.controller.Debian
index 5f723fe..27a32e4 100644
--- a/cinder/files/kilo/cinder.conf.controller.Debian
+++ b/cinder/files/kilo/cinder.conf.controller.Debian
@@ -54,7 +54,6 @@
 rpc_backend=cinder.openstack.common.rpc.impl_kombu
 control_exchange=cinder
 
-
 volume_clear={{ controller.wipe_method }}
 
 {%- if controller.notification %}
@@ -62,7 +61,6 @@
 notification_driver = messagingv2
 {%- endif %}
 
-
 volume_name_template = volume-%s
 
 #volume_group = vg_cinder_volume
@@ -82,8 +80,16 @@
 lock_path=/var/lock/cinder
 
 [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 }}
+{%- endif %}
+
 rabbit_userid = {{ controller.message_queue.user }}
 rabbit_password = {{ controller.message_queue.password }}
 rabbit_virtual_host = {{ controller.message_queue.virtual_host }}
@@ -314,7 +320,6 @@
 
 {%- endif %}
 
-
 {%- if controller.storage.engine == "hp3par" %}
 
 {%- for type in controller.get('types', []) %}
diff --git a/cinder/files/kilo/cinder.conf.volume.Debian b/cinder/files/kilo/cinder.conf.volume.Debian
index 5ec2e6b..940fc96 100644
--- a/cinder/files/kilo/cinder.conf.volume.Debian
+++ b/cinder/files/kilo/cinder.conf.volume.Debian
@@ -90,9 +90,16 @@
 lock_path=/var/lock/cinder
 
 [oslo_messaging_rabbit]
-
+{%- if volume.message_queue.members is defined %}
+rabbit_hosts = {% for member in volume.message_queue.members -%}
+                   {{ member.host }}:{{ member.get('port', 5672) }}
+                   {%- if not loop.last -%},{%- endif -%}
+               {%- endfor -%}
+{%- else %}
 rabbit_host = {{ volume.message_queue.host }}
 rabbit_port = {{ volume.message_queue.port }}
+{%- endif %}
+
 rabbit_userid = {{ volume.message_queue.user }}
 rabbit_password = {{ volume.message_queue.password }}
 rabbit_virtual_host = {{ volume.message_queue.virtual_host }}
diff --git a/cinder/files/liberty/cinder.conf.controller.Debian b/cinder/files/liberty/cinder.conf.controller.Debian
index 4625b38..2c7b889 100644
--- a/cinder/files/liberty/cinder.conf.controller.Debian
+++ b/cinder/files/liberty/cinder.conf.controller.Debian
@@ -82,8 +82,16 @@
 lock_path=/var/lock/cinder
 
 [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 }}
+{%- endif %}
+
 rabbit_userid = {{ controller.message_queue.user }}
 rabbit_password = {{ controller.message_queue.password }}
 rabbit_virtual_host = {{ controller.message_queue.virtual_host }}
diff --git a/cinder/files/liberty/cinder.conf.volume.Debian b/cinder/files/liberty/cinder.conf.volume.Debian
index 5ec2e6b..940fc96 100644
--- a/cinder/files/liberty/cinder.conf.volume.Debian
+++ b/cinder/files/liberty/cinder.conf.volume.Debian
@@ -90,9 +90,16 @@
 lock_path=/var/lock/cinder
 
 [oslo_messaging_rabbit]
-
+{%- if volume.message_queue.members is defined %}
+rabbit_hosts = {% for member in volume.message_queue.members -%}
+                   {{ member.host }}:{{ member.get('port', 5672) }}
+                   {%- if not loop.last -%},{%- endif -%}
+               {%- endfor -%}
+{%- else %}
 rabbit_host = {{ volume.message_queue.host }}
 rabbit_port = {{ volume.message_queue.port }}
+{%- endif %}
+
 rabbit_userid = {{ volume.message_queue.user }}
 rabbit_password = {{ volume.message_queue.password }}
 rabbit_virtual_host = {{ volume.message_queue.virtual_host }}
diff --git a/cinder/files/mitaka/cinder.conf.controller.Debian b/cinder/files/mitaka/cinder.conf.controller.Debian
index 7f508fe..ffc662b 100644
--- a/cinder/files/mitaka/cinder.conf.controller.Debian
+++ b/cinder/files/mitaka/cinder.conf.controller.Debian
@@ -76,8 +76,16 @@
 lock_path=/var/lock/cinder
 
 [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 }}
+{%- endif %}
+
 rabbit_userid = {{ controller.message_queue.user }}
 rabbit_password = {{ controller.message_queue.password }}
 rabbit_virtual_host = {{ controller.message_queue.virtual_host }}
diff --git a/cinder/files/mitaka/cinder.conf.volume.Debian b/cinder/files/mitaka/cinder.conf.volume.Debian
index 91faf84..1365f19 100644
--- a/cinder/files/mitaka/cinder.conf.volume.Debian
+++ b/cinder/files/mitaka/cinder.conf.volume.Debian
@@ -74,9 +74,16 @@
 lock_path=/var/lock/cinder
 
 [oslo_messaging_rabbit]
-
+{%- if volume.message_queue.members is defined %}
+rabbit_hosts = {% for member in volume.message_queue.members -%}
+                   {{ member.host }}:{{ member.get('port', 5672) }}
+                   {%- if not loop.last -%},{%- endif -%}
+               {%- endfor -%}
+{%- else %}
 rabbit_host = {{ volume.message_queue.host }}
 rabbit_port = {{ volume.message_queue.port }}
+{%- endif %}
+
 rabbit_userid = {{ volume.message_queue.user }}
 rabbit_password = {{ volume.message_queue.password }}
 rabbit_virtual_host = {{ volume.message_queue.virtual_host }}
@@ -114,4 +121,4 @@
 
 {%- endfor %}
 
-{%- endif %}
\ No newline at end of file
+{%- endif %}
diff --git a/metadata/service/control/cluster.yml b/metadata/service/control/cluster.yml
index 91a814a..c0c9682 100644
--- a/metadata/service/control/cluster.yml
+++ b/metadata/service/control/cluster.yml
@@ -34,7 +34,6 @@
         user: openstack
         password: ${_param:rabbitmq_openstack_password}
         virtual_host: '/openstack'
-        ha_queues: true
       cache:
         engine: memcached
         members:
@@ -43,4 +42,4 @@
         - host: ${_param:cluster_node02_address}
           port: 11211
         - host: ${_param:cluster_node03_address}
-          port: 11211
\ No newline at end of file
+          port: 11211
diff --git a/metadata/service/control/cluster_control.yml b/metadata/service/control/cluster_control.yml
index 91a814a..c0c9682 100644
--- a/metadata/service/control/cluster_control.yml
+++ b/metadata/service/control/cluster_control.yml
@@ -34,7 +34,6 @@
         user: openstack
         password: ${_param:rabbitmq_openstack_password}
         virtual_host: '/openstack'
-        ha_queues: true
       cache:
         engine: memcached
         members:
@@ -43,4 +42,4 @@
         - host: ${_param:cluster_node02_address}
           port: 11211
         - host: ${_param:cluster_node03_address}
-          port: 11211
\ No newline at end of file
+          port: 11211
diff --git a/tests/pillar/control_cluster.sls b/tests/pillar/control_cluster.sls
index b8c1dfb..b736446 100644
--- a/tests/pillar/control_cluster.sls
+++ b/tests/pillar/control_cluster.sls
@@ -24,12 +24,13 @@
       port: 9292
     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'
-      ha_queues: true
     cache:
       engine: memcached
       members:
@@ -38,4 +39,4 @@
       - host: 127.0.0.1
         port: 11211
       - host: 127.0.0.1
-        port: 11211
\ No newline at end of file
+        port: 11211