Several bundled updates
- The latest envoy docker containter was broken, made changes to request
  a sepcific commit version of the container known to work.
- A minor change to the proxy configuration file where the same name was
  used for 2 virtual_hosts.
- An update to CreateInstaller.sh for use in multi-user mode which tries
  to guess a the cord_home rather than having the user set it.
- A change to the swarm start script to wait for consul to establish the
  master before starting the remainder of the dependent containers.

Change-Id: I475dc4bc86189d784a21dc676e07b8b6b87f1bc3
diff --git a/Makefile b/Makefile
index b6eba53..ef77149 100644
--- a/Makefile
+++ b/Makefile
@@ -215,9 +215,9 @@
 	docker pull zookeeper:latest
 	docker pull nginx:latest
 	docker pull portainer/portainer:latest
-	docker pull lyft/envoy:latest
+	docker pull lyft/envoy:092f01381467dfc3324e5e9528c67ee5d65744fd
 	docker pull registry:2
-        docker pull kamon/grafana_graphite:latest
+	docker pull kamon/grafana_graphite:latest
 
 purge-venv:
 	rm -fr ${VENVDIR}
diff --git a/docker/Dockerfile.envoy b/docker/Dockerfile.envoy
index a802c4c..7049fc9 100644
--- a/docker/Dockerfile.envoy
+++ b/docker/Dockerfile.envoy
@@ -1,4 +1,4 @@
-FROM lyft/envoy:latest
+FROM lyft/envoy:092f01381467dfc3324e5e9528c67ee5d65744fd
 
 RUN apt-get update && apt-get -q install -y \
     curl
diff --git a/envoy/front-proxy/voltha-grpc-proxy.template.json b/envoy/front-proxy/voltha-grpc-proxy.template.json
index 3ade94f..dffebc2 100644
--- a/envoy/front-proxy/voltha-grpc-proxy.template.json
+++ b/envoy/front-proxy/voltha-grpc-proxy.template.json
@@ -97,7 +97,7 @@
             "route_config": {
               "virtual_hosts": [
                 {
-                  "name": "backend2",
+                  "name": "backend3",
                   "domains": ["*"],
                   "routes": [
                     {
diff --git a/install/CreateInstaller.sh b/install/CreateInstaller.sh
index 9ca37d7..c438f23 100755
--- a/install/CreateInstaller.sh
+++ b/install/CreateInstaller.sh
@@ -294,6 +294,8 @@
 	echo "voltha_containers:" >> ansible/group_vars/all
 	cat image-list.cfg >> ansible/group_vars/all
 	rm -f image-list.cfg
+	echo -e "${lBlue}Gussing at the cord home directory for ${yellow}`whoami`${NC}"
+	sed -i -e "/cord_home:/s#.*#cord_home: `pwd | sed -e 's~/incubator/voltha/install~~'`#" ansible/group_vars/all
 else
 	echo -e "${lBlue}Set up the docker image list from ${lCyan}containers.cfg${NC}"
 	sed -i -e '/voltha_containers:/,$d' ansible/group_vars/all
diff --git a/install/voltha-swarm-start.sh b/install/voltha-swarm-start.sh
index d43bb26..ad5bdd0 100755
--- a/install/voltha-swarm-start.sh
+++ b/install/voltha-swarm-start.sh
@@ -1,6 +1,7 @@
 #!/bin/bash
 
 voltha_base_dir="/cord/incubator/voltha"
+hostName=`hostname`
 
 docker network create --driver overlay --subnet=172.29.19.0/24 --opt encrypted=true voltha_net
 docker stack deploy -c ${voltha_base_dir}/compose/docker-compose-kafka-cluster.yml kafka
@@ -13,7 +14,26 @@
 		break
 	fi
 done
-sleep 10
+
+echo "Waiting for consul leader election"
+patience=10
+while true
+do
+	leader=`curl -v http://${hostName}:8500/v1/status/leader 2>/dev/null | sed -e 's/"//g'`
+	if [ ! -z "$leader" ] ; then
+		echo "Leader elected is on ${leader}"
+		break
+	fi
+	sleep 10
+	patience=`expr $patience - 1`
+	if [ $patience -eq 0 ]; then
+		echo "Consul leader election taking too long... aborting"
+		./voltha-swarm-stop.sh
+		exit 1
+	fi
+done
+
+
 docker stack deploy -c ${voltha_base_dir}/compose/docker-compose-voltha-swarm.yml vcore
 docker stack deploy -c ${voltha_base_dir}/compose/docker-compose-envoy-swarm.yml voltha
 docker stack deploy -c ${voltha_base_dir}/compose/docker-compose-vcli.yml cli