Merge "Check message queue is type of mapping"
diff --git a/_modules/neutronv2/common.py b/_modules/neutronv2/common.py
index 0dd4b8e..92d227e 100644
--- a/_modules/neutronv2/common.py
+++ b/_modules/neutronv2/common.py
@@ -1,6 +1,7 @@
 import functools
 import logging
 import os_client_config
+import time
 
 log = logging.getLogger(__name__)
 
@@ -66,6 +67,8 @@
         @functools.wraps(func)
         def wrapped_f(*args, **kwargs):
             cloud_name = kwargs.pop('cloud_name')
+            connect_retries =  15
+            connect_retry_delay = 1
             if not cloud_name:
                 e = NoCredentials()
                 log.error('%s' % e)
@@ -80,7 +83,21 @@
             if 'microversion' in kwargs:
                 request_kwargs['headers'][
                     NEUTRON_VERSION_HEADER] = kwargs['microversion']
-            response = getattr(adapter, method)(url, **request_kwargs)
+            for i in range(connect_retries):
+                try:
+                  response = getattr(adapter, method)(
+                      url, connect_retries=connect_retries,
+                      **request_kwargs)
+                except Exception as e:
+                    if hasattr(e, 'http_status') and (e.http_status >= 500
+                        or e.http_status == 0):
+                        msg = ("Got retriable exception when contacting "
+                               "Neutron API. Sleeping for %ss. Attepmpts "
+                               "%s of %s")
+                        log.error(msg % (connect_retry_delay, i, connect_retries))
+                        time.sleep(connect_retry_delay)
+                        continue
+                break
             if not response.content:
                 return {}
             try:
diff --git a/neutron/files/queens/neutron-generic.conf b/neutron/files/queens/neutron-generic.conf
index 096cb69..4eef1a4 100644
--- a/neutron/files/queens/neutron-generic.conf
+++ b/neutron/files/queens/neutron-generic.conf
@@ -439,6 +439,7 @@
     {%- set messaging_engine = _data.engine %}
 {%- endif %}
 [oslo_messaging_{{ messaging_engine }}]
+{%- if _data.ssl is defined and 'cacert_file' not in _data.get('ssl', {}).keys() %}{% do _data['ssl'].update({'cacert_file': neutron.cacert_file}) %}{% endif %}
 {%- include "oslo_templates/files/queens/oslo/messaging/_" + messaging_engine + ".conf" %}
 {%- endif %}
 
diff --git a/neutron/files/queens/neutron-server.conf b/neutron/files/queens/neutron-server.conf
index 4f35a5b..f20ac88 100644
--- a/neutron/files/queens/neutron-server.conf
+++ b/neutron/files/queens/neutron-server.conf
@@ -483,6 +483,7 @@
     {%- set messaging_engine = _data.engine %}
 {%- endif %}
 [oslo_messaging_{{ messaging_engine }}]
+{%- if _data.ssl is defined and 'cacert_file' not in _data.get('ssl', {}).keys() %}{% do _data['ssl'].update({'cacert_file': server.cacert_file}) %}{% endif %}
 {%- include "oslo_templates/files/queens/oslo/messaging/_" + messaging_engine + ".conf" %}
 {%- endif %}
 
diff --git a/neutron/gateway.sls b/neutron/gateway.sls
index 0927654..6c5da92 100644
--- a/neutron/gateway.sls
+++ b/neutron/gateway.sls
@@ -82,6 +82,7 @@
         values: {{ gateway }}
     - require:
       - pkg: neutron_gateway_packages
+      - sls: neutron._ssl.rabbitmq
     - watch_in:
       - service: neutron_gateway_services
 {% endfor %}
diff --git a/neutron/ml2_ovs/init.sls b/neutron/ml2_ovs/init.sls
index 87e7e6f..19b5379 100644
--- a/neutron/ml2_ovs/init.sls
+++ b/neutron/ml2_ovs/init.sls
@@ -48,9 +48,6 @@
     - file: /etc/neutron/neutron.conf
     - file: /etc/neutron/plugins/ml2/openvswitch_agent.ini
     - file: /etc/neutron/plugins/ml2/sriov_agent.ini
-      {%- if compute.message_queue.get('ssl',{}).get('enabled', False) %}
-    - file: rabbitmq_ca_neutron_compute
-      {%- endif %}
 
     {% endif %}
 
@@ -125,9 +122,6 @@
   - watch:
     - file: /etc/neutron/neutron.conf
     - file: /etc/neutron/plugins/ml2/openvswitch_agent.ini
-    {%- if compute.message_queue.get('ssl',{}).get('enabled', False) %}
-    - file: rabbitmq_ca_neutron_compute
-    {%- endif %}
 
     {%- set neutron_compute_services_list = compute.services %}
     {%- if compute.backend.sriov is defined %}