Merge "Replace deprecated docker Salt modules"
diff --git a/opencontrail/collector.sls b/opencontrail/collector.sls
index 4534ea8..8930565 100644
--- a/opencontrail/collector.sls
+++ b/opencontrail/collector.sls
@@ -139,7 +139,12 @@
 
 {%- else %}
 {%- if collector.container_name is defined %}
-{%- if salt['dockerng.exists'](collector.container_name) %}
+{%- if grains['saltversioninfo'] < [2017, 7] %}
+  {% set docker_module = 'dockerng' %}
+{%- else %}
+  {% set docker_module = 'docker' %}
+{%- endif %}
+{%- if salt['{{ docker_module }}.exists'](collector.container_name) %}
 opencontrail_collector_dockerng_services:
   dockerng_service.running:
   - services: {{ collector.services }}
@@ -153,8 +158,8 @@
     - file: /etc/contrail/contrail-snmp-collector.conf
     - file: /etc/contrail/contrail-analytics-nodemgr.conf
     - file: /etc/contrail/contrail-alarm-gen.conf
-{%- endif%}
-{%- endif%}
+{%- endif %}
+{%- endif %}
 {%- endif %}
 
 {%- endif %}
diff --git a/opencontrail/config.sls b/opencontrail/config.sls
index 3aa7378..53ad48e 100644
--- a/opencontrail/config.sls
+++ b/opencontrail/config.sls
@@ -253,7 +253,12 @@
 
 {%- else %}
 {%- if config.container_name is defined %}
-{%- if salt['dockerng.exists'](config.container_name) %}
+{%- if grains['saltversioninfo'] < [2017, 7] %}
+  {% set docker_module = 'dockerng' %}
+{%- else %}
+  {% set docker_module = 'docker' %}
+{%- endif %}
+{%- if salt['{{ docker_module }}.exists'](config.container_name) %}
 opencontrail_config_dockerng_services:
   dockerng_service.running:
     - services: {{ config.services }}
@@ -268,8 +273,8 @@
       {%- if config.identity.engine == "keystone" %}
       - file: /etc/contrail/contrail-keystone-auth.conf
       {%- endif %}
-{%- endif%}
-{%- endif%}
+{%- endif %}
+{%- endif %}
 
 {%- endif %}
 
diff --git a/opencontrail/control.sls b/opencontrail/control.sls
index 48f3fa4..266ab5b 100644
--- a/opencontrail/control.sls
+++ b/opencontrail/control.sls
@@ -135,7 +135,12 @@
 
 {%- else %}
 {%- if control.container_name is defined %}
-{%- if salt['dockerng.exists'](control.container_name) %}
+{%- if grains['saltversioninfo'] < [2017, 7] %}
+  {% set docker_module = 'dockerng' %}
+{%- else %}
+  {% set docker_module = 'docker' %}
+{%- endif %}
+{%- if salt['{{ docker_module }}.exists'](control.container_name) %}
 opencontrail_control_dockerng_services:
   dockerng_service.running:
     - services: {{ control.services }}
diff --git a/opencontrail/database.sls b/opencontrail/database.sls
index ccd27a0..9b2e06b 100644
--- a/opencontrail/database.sls
+++ b/opencontrail/database.sls
@@ -285,7 +285,12 @@
 
 {%- else %}
 {%- if database.container_name is defined %}
-{%- if salt['dockerng.exists'](database.container_name) %}
+{%- if grains['saltversioninfo'] < [2017, 7] %}
+  {% set docker_module = 'dockerng' %}
+{%- else %}
+  {% set docker_module = 'docker' %}
+{%- endif %}
+{%- if salt['{{ docker_module }}.exists'](database.container_name) %}
 opencontrail_database_dockerng_services:
   dockerng_service.running:
     - services:
diff --git a/opencontrail/web.sls b/opencontrail/web.sls
index 9422efa..fd99375 100644
--- a/opencontrail/web.sls
+++ b/opencontrail/web.sls
@@ -59,7 +59,12 @@
   - template: jinja
 
 {%- if web.container_name is defined %}
-{%- if salt['dockerng.exists'](web.container_name) %}
+{%- if grains['saltversioninfo'] < [2017, 7] %}
+  {% set docker_module = 'dockerng' %}
+{%- else %}
+  {% set docker_module = 'docker' %}
+{%- endif %}
+{%- if salt['{{ docker_module }}.exists'](web.container_name) %}
 opencontrail_web_dockerng_services:
   dockerng_service.running:
     - services:
@@ -69,8 +74,8 @@
     - watch:
       - file: /etc/contrail/config.global.js
       - file: /etc/contrail/contrail-webui-userauth.js
-{%- endif%}
-{%- endif%}
+{%- endif %}
+{%- endif %}
 
 {%- endif %}