Merge "Docker support for web"
diff --git a/metadata/service/control/cluster.yml b/metadata/service/control/cluster.yml
index d76fb59..858f181 100644
--- a/metadata/service/control/cluster.yml
+++ b/metadata/service/control/cluster.yml
@@ -153,3 +153,6 @@
         password: '${_param:keystone_admin_password}'
         token: '${_param:keystone_service_token}'
         tenant: admin
+      network:
+        engine: neutron
+        host: ${_param:cluster_vip_address}
diff --git a/metadata/service/control/control.yml b/metadata/service/control/control.yml
index 97ebdaa..df3e021 100644
--- a/metadata/service/control/control.yml
+++ b/metadata/service/control/control.yml
@@ -134,3 +134,6 @@
         password: '${_param:keystone_admin_password}'
         token: '${_param:keystone_service_token}'
         tenant: admin
+      network:
+        engine: neutron
+        host: ${_param:cluster_vip_address}
\ No newline at end of file
diff --git a/metadata/service/control/single.yml b/metadata/service/control/single.yml
index 16a8452..3741c3f 100644
--- a/metadata/service/control/single.yml
+++ b/metadata/service/control/single.yml
@@ -129,3 +129,6 @@
         password: '${_param:keystone_admin_password}'
         token: '${_param:keystone_service_token}'
         tenant: admin
+      network:
+        engine: neutron
+        host: ${_param:single_address}
\ No newline at end of file
diff --git a/opencontrail/config.sls b/opencontrail/config.sls
index 97c4003..9b2006f 100644
--- a/opencontrail/config.sls
+++ b/opencontrail/config.sls
@@ -150,6 +150,8 @@
     - service: opencontrail_config_services
 {%- endif %}
 
+{%- if not grains.get('virtual_subtype', None) == "Docker" %}
+
 /etc/contrail/supervisord_config_files/ifmap.ini:
   file.absent:
   - require:
@@ -159,6 +161,8 @@
     - service: opencontrail_config_services
 {%- endif %}
 
+{%- endif %}
+
 /etc/contrail/supervisord_config.conf:
   file.managed:
   - source: salt://opencontrail/files/{{ config.version }}/config/supervisord_config.conf
diff --git a/opencontrail/files/3.0/config.global.js b/opencontrail/files/3.0/config.global.js
index a6a252b..c511ca1 100644
--- a/opencontrail/files/3.0/config.global.js
+++ b/opencontrail/files/3.0/config.global.js
@@ -85,7 +85,7 @@
 *****************************************************************************/
 {%- if web.identity.engine == "keystone" %}
 config.networkManager = {};
-config.networkManager.ip = '{{ web.master.host }}';
+config.networkManager.ip = '{{ web.network.host }}';
 config.networkManager.port = '9696'
 config.networkManager.authProtocol = 'http';
 config.networkManager.apiVersion = [];
@@ -143,7 +143,7 @@
 // Analytics API server and port.
 config.analytics = {};
 config.analytics.server_ip = '{{ web.analytics.host }}';
-config.analytics.server_port = '9081';
+config.analytics.server_port = '8081';
 config.analytics.authProtocol = 'http';
 config.analytics.strictSSL = false;
 config.analytics.ca = '';
@@ -165,7 +165,7 @@
 /* Specifiy true if subscription to discovery server should be enabled, else
  * specify false. Other than true/false value here is treated as true
  */
-config.discoveryService.enable = true;
+config.discoveryService.enable = {{ web.get('enable_discovery', 'true')|lower }};
 
 /* Job Server */
 config.jobServer = {};
@@ -178,7 +178,7 @@
 
 /* WebUI Redis Server */
 config.redis_server_port = '6379';
-config.redis_server_ip = '127.0.0.1';
+config.redis_server_ip = '{{ web.cache.host }}';
 config.redis_dump_file = '/var/lib/redis/dump-webui.rdb';
 config.redis_password = '';
 
diff --git a/opencontrail/files/entrypoint.sh.web b/opencontrail/files/entrypoint.sh.web
new file mode 100644
index 0000000..0ac05fe
--- /dev/null
+++ b/opencontrail/files/entrypoint.sh.web
@@ -0,0 +1,25 @@
+{%- from "opencontrail/map.jinja" import web with context -%}
+#!/bin/bash -e
+
+cat /srv/salt/pillar/opencontrail-web.sls | envsubst > /tmp/opencontrail-web.sls
+mv /tmp/opencontrail-web.sls /srv/salt/pillar/opencontrail-web.sls
+
+salt-call --local --retcode-passthrough state.highstate
+
+{% for service in web.services %}
+service {{ service }} stop || true
+{% endfor %}
+
+if [ "$1" == "webserver" ]; then
+    echo "starting webserver"
+    su contrail --shell=/bin/sh -c '/usr/bin/nodejs /var/lib/contrail-webui/contrail-web-core/webServerStart.js'
+elif [ "$1" == "jobserver" ]; then
+    echo "starting jobserver"
+    su contrail --shell=/bin/sh -c '/usr/bin/node jobServerStart.js'
+else
+    echo "No parameter submitted, don't know what to start" 1>&2
+fi
+
+{#-
+vim: syntax=jinja
+-#}
\ No newline at end of file
diff --git a/opencontrail/map.jinja b/opencontrail/map.jinja
index a3be5a5..4c6c52d 100644
--- a/opencontrail/map.jinja
+++ b/opencontrail/map.jinja
@@ -71,7 +71,7 @@
 
 {% set web = salt['grains.filter_by']({
     'Debian': {
-        'pkgs': ['contrail-web-controller', 'nodejs-legacy'],
+        'pkgs': ['contrail-web-controller', 'nodejs-legacy', 'gettext-base'],
         'services': ['contrail-webui-webserver','contrail-webui-jobserver']
     },
     'RedHat': {
diff --git a/opencontrail/web.sls b/opencontrail/web.sls
index aad2251..0a5f2da 100644
--- a/opencontrail/web.sls
+++ b/opencontrail/web.sls
@@ -1,9 +1,6 @@
 {%- from "opencontrail/map.jinja" import web with context %}
 {%- if web.enabled %}
 
-include:
-- opencontrail.common
-
 opencontrail_web_packages:
   pkg.installed:
   - names: {{ web.pkgs }}
@@ -21,6 +18,7 @@
   - template: jinja
   - require:
     - pkg: opencontrail_web_packages
+{%- if not grains.get('noservices', False) %}
   - watch_in:
     - service: opencontrail_web_services
 
@@ -32,3 +30,16 @@
     - file: /etc/contrail/config.global.js
 
 {%- endif %}
+
+{%- if grains.get('virtual_subtype', None) == "Docker" %}
+
+opencontrail_web_entrypoint:
+  file.managed:
+  - name: /entrypoint.sh
+  - template: jinja
+  - source: salt://opencontrail/files/entrypoint.sh.web
+  - mode: 755
+
+{%- endif %}
+
+{%- endif %}
\ No newline at end of file