Fix installation scripts for StackLight

The change ensures that log_collector and remote_collector are
installed. It also removes unnecessary steps and moves the installation
of StackLight at the end of the workflow to make sure that all the
monitored services are deployed.

It also uses the Docker images from the Mirantis internal registry.

Change-Id: Id53507856098d0282f8b90e5d9aca5a362e97de7
diff --git a/classes/cluster/sl_k8s_calico/stacklight/server.yml b/classes/cluster/sl_k8s_calico/stacklight/server.yml
index bef849f..2239712 100644
--- a/classes/cluster/sl_k8s_calico/stacklight/server.yml
+++ b/classes/cluster/sl_k8s_calico/stacklight/server.yml
@@ -27,10 +27,12 @@
   _param:
     cluster_vip_address: ${_param:stacklight_address}
     cluster_public_host: mon
-    docker_image_alertmanager: alertmanager:latest
-    docker_image_pushgateway: pushgateway:latest
-    docker_image_prometheus: prometheus:latest
-    docker_image_grafana: grafana/grafana:latest
+    docker_image_alertmanager: docker-prod-virtual.docker.mirantis.net/openstack-docker/alertmanager:latest
+    docker_image_pushgateway: docker-prod-virtual.docker.mirantis.net/openstack-docker/pushgateway:latest
+    docker_image_prometheus: docker-prod-virtual.docker.mirantis.net/openstack-docker/prometheus:latest
+    docker_image_remote_agent: docker-prod-virtual.docker.mirantis.net/openstack-docker/telegraf:latest
+    docker_image_remote_storage_adapter: docker-prod-virtual.docker.mirantis.net/openstack-docker/remote_storage_adapter:latest
+    docker_image_grafana: grafana/grafana:4.3.2
     grafana_admin_password: admin
     keepalived_prometheus_vip_address: ${_param:cluster_vip_address}
     keepalived_prometheus_vip_password: password
diff --git a/classes/cluster/sl_k8s_contrail/stacklight/server.yml b/classes/cluster/sl_k8s_contrail/stacklight/server.yml
index 9980f3c..bb43c6e 100644
--- a/classes/cluster/sl_k8s_contrail/stacklight/server.yml
+++ b/classes/cluster/sl_k8s_contrail/stacklight/server.yml
@@ -34,12 +34,12 @@
   _param:
     cluster_public_host: mon
     cluster_vip_address: ${_param:stacklight_monitor_address}
-    docker_image_alertmanager: mirantis/alertmanager:latest
-    docker_image_pushgateway: mirantis/pushgateway:latest
-    docker_image_prometheus: mirantis/prometheus:latest
-    docker_image_remote_agent: mirantis/telegraf:latest
-    docker_image_remote_storage_adapter: mirantis/remote_storage_adapter:latest
-    docker_image_grafana: grafana/grafana:latest
+    docker_image_alertmanager: docker-prod-virtual.docker.mirantis.net/openstack-docker/alertmanager:latest
+    docker_image_pushgateway: docker-prod-virtual.docker.mirantis.net/openstack-docker/pushgateway:latest
+    docker_image_prometheus: docker-prod-virtual.docker.mirantis.net/openstack-docker/prometheus:latest
+    docker_image_remote_agent: docker-prod-virtual.docker.mirantis.net/openstack-docker/telegraf:latest
+    docker_image_remote_storage_adapter: docker-prod-virtual.docker.mirantis.net/openstack-docker/remote_storage_adapter:latest
+    docker_image_grafana: grafana/grafana:4.3.2
     grafana_admin_password: admin
     keepalived_prometheus_vip_address: ${_param:cluster_vip_address}
     keepalived_prometheus_vip_password: password
diff --git a/classes/cluster/sl_os_contrail/stacklight/server.yml b/classes/cluster/sl_os_contrail/stacklight/server.yml
index 894dc0f..23acc64 100755
--- a/classes/cluster/sl_os_contrail/stacklight/server.yml
+++ b/classes/cluster/sl_os_contrail/stacklight/server.yml
@@ -46,12 +46,12 @@
     grafana_database_type: mysql
     grafana_database_host: ${_param:openstack_database_address}
     grafana_database_password: ${_param:mysql_grafana_password}
-    docker_image_alertmanager: mirantis/alertmanager:latest
-    docker_image_pushgateway: mirantis/pushgateway:latest
-    docker_image_prometheus: mirantis/prometheus:latest
-    docker_image_remote_agent: mirantis/telegraf:latest
-    docker_image_remote_storage_adapter: mirantis/remote_storage_adapter:latest
-    docker_image_grafana: grafana/grafana:latest
+    docker_image_alertmanager: docker-prod-virtual.docker.mirantis.net/openstack-docker/alertmanager:latest
+    docker_image_pushgateway: docker-prod-virtual.docker.mirantis.net/openstack-docker/pushgateway:latest
+    docker_image_prometheus: docker-prod-virtual.docker.mirantis.net/openstack-docker/prometheus:latest
+    docker_image_remote_agent: docker-prod-virtual.docker.mirantis.net/openstack-docker/telegraf:latest
+    docker_image_remote_storage_adapter: docker-prod-virtual.docker.mirantis.net/openstack-docker/remote_storage_adapter:latest
+    docker_image_grafana: grafana/grafana:4.3.2
     prometheus_glusterfs_service_host: ${_param:openstack_control_address}
     glusterfs_node01_address: ${_param:openstack_control_node01_address}
     glusterfs_node02_address: ${_param:openstack_control_node02_address}
diff --git a/classes/cluster/virtual-mcp11-contrail/stacklight/server.yml b/classes/cluster/virtual-mcp11-contrail/stacklight/server.yml
index 8517382..5f0bbf7 100755
--- a/classes/cluster/virtual-mcp11-contrail/stacklight/server.yml
+++ b/classes/cluster/virtual-mcp11-contrail/stacklight/server.yml
@@ -48,12 +48,12 @@
     grafana_database_type: mysql
     grafana_database_host: ${_param:openstack_database_address}
     grafana_database_password: ${_param:mysql_grafana_password}
-    docker_image_alertmanager: mirantis/alertmanager:latest
-    docker_image_pushgateway: mirantis/pushgateway:latest
-    docker_image_prometheus: mirantis/prometheus:latest
-    docker_image_remote_agent: mirantis/telegraf:latest
-    docker_image_remote_collector: mirantis/heka:latest
-    docker_image_remote_storage_adapter: mirantis/remote_storage_adapter:latest
+    docker_image_alertmanager: docker-prod-virtual.docker.mirantis.net/openstack-docker/alertmanager:latest
+    docker_image_pushgateway: docker-prod-virtual.docker.mirantis.net/openstack-docker/pushgateway:latest
+    docker_image_prometheus: docker-prod-virtual.docker.mirantis.net/openstack-docker/prometheus:latest
+    docker_image_remote_agent: docker-prod-virtual.docker.mirantis.net/openstack-docker/telegraf:latest
+    docker_image_remote_storage_adapter: docker-prod-virtual.docker.mirantis.net/openstack-docker/remote_storage_adapter:latest
+    docker_image_remote_collector: docker-prod-virtual.docker.mirantis.net/openstack-docker/heka:latest
     docker_image_grafana: grafana/grafana:4.3.2
     prometheus_glusterfs_service_host: ${_param:openstack_control_address}
     glusterfs_node01_address: ${_param:openstack_control_node01_address}
diff --git a/classes/cluster/virtual-mcp11-dvr/stacklight/server.yml b/classes/cluster/virtual-mcp11-dvr/stacklight/server.yml
index 4ccdb19..c455526 100644
--- a/classes/cluster/virtual-mcp11-dvr/stacklight/server.yml
+++ b/classes/cluster/virtual-mcp11-dvr/stacklight/server.yml
@@ -48,12 +48,12 @@
     grafana_database_type: mysql
     grafana_database_host: ${_param:openstack_database_address}
     grafana_database_password: ${_param:mysql_grafana_password}
-    docker_image_alertmanager: mirantis/alertmanager:latest
-    docker_image_pushgateway: mirantis/pushgateway:latest
-    docker_image_prometheus: mirantis/prometheus:latest
-    docker_image_remote_agent: mirantis/telegraf:latest
-    docker_image_remote_collector: mirantis/heka:latest
-    docker_image_remote_storage_adapter: mirantis/remote_storage_adapter:latest
+    docker_image_alertmanager: docker-prod-virtual.docker.mirantis.net/openstack-docker/alertmanager:latest
+    docker_image_pushgateway: docker-prod-virtual.docker.mirantis.net/openstack-docker/pushgateway:latest
+    docker_image_prometheus: docker-prod-virtual.docker.mirantis.net/openstack-docker/prometheus:latest
+    docker_image_remote_agent: docker-prod-virtual.docker.mirantis.net/openstack-docker/telegraf:latest
+    docker_image_remote_storage_adapter: docker-prod-virtual.docker.mirantis.net/openstack-docker/remote_storage_adapter:latest
+    docker_image_remote_collector: docker-prod-virtual.docker.mirantis.net/openstack-docker/heka:latest
     docker_image_grafana: grafana/grafana:4.3.2
     prometheus_glusterfs_service_host: ${_param:openstack_control_address}
     glusterfs_node01_address: ${_param:openstack_control_node01_address}
diff --git a/classes/cluster/virtual-mcp11-k8s-calico-dyn/stacklight/server.yml b/classes/cluster/virtual-mcp11-k8s-calico-dyn/stacklight/server.yml
index 6c49533..7720b8c 100644
--- a/classes/cluster/virtual-mcp11-k8s-calico-dyn/stacklight/server.yml
+++ b/classes/cluster/virtual-mcp11-k8s-calico-dyn/stacklight/server.yml
@@ -29,11 +29,11 @@
   _param:
     cluster_vip_address: ${_param:stacklight_address}
     cluster_public_host: mon
-    docker_image_alertmanager: mirantis/alertmanager:latest
-    docker_image_pushgateway: mirantis/pushgateway:latest
-    docker_image_prometheus: mirantis/prometheus:latest
-    docker_image_remote_agent: mirantis/telegraf:latest
-    docker_image_remote_storage_adapter: mirantis/remote_storage_adapter:latest
+    docker_image_alertmanager: docker-prod-virtual.docker.mirantis.net/openstack-docker/alertmanager:latest
+    docker_image_pushgateway: docker-prod-virtual.docker.mirantis.net/openstack-docker/pushgateway:latest
+    docker_image_prometheus: docker-prod-virtual.docker.mirantis.net/openstack-docker/prometheus:latest
+    docker_image_remote_agent: docker-prod-virtual.docker.mirantis.net/openstack-docker/telegraf:latest
+    docker_image_remote_storage_adapter: docker-prod-virtual.docker.mirantis.net/openstack-docker/remote_storage_adapter:latest
     docker_image_grafana: grafana/grafana:4.3.2
     grafana_admin_password: admin
     keepalived_prometheus_vip_address: ${_param:cluster_vip_address}
diff --git a/classes/cluster/virtual-mcp11-k8s-calico/stacklight/server.yml b/classes/cluster/virtual-mcp11-k8s-calico/stacklight/server.yml
index 4de8d96..63c1443 100644
--- a/classes/cluster/virtual-mcp11-k8s-calico/stacklight/server.yml
+++ b/classes/cluster/virtual-mcp11-k8s-calico/stacklight/server.yml
@@ -34,11 +34,11 @@
   _param:
     cluster_vip_address: ${_param:stacklight_monitor_address}
     cluster_public_host: mon
-    docker_image_alertmanager: mirantis/alertmanager:latest
-    docker_image_pushgateway: mirantis/pushgateway:latest
-    docker_image_prometheus: mirantis/prometheus:latest
-    docker_image_remote_agent: mirantis/telegraf:latest
-    docker_image_remote_storage_adapter: mirantis/remote_storage_adapter:latest
+    docker_image_alertmanager: docker-prod-virtual.docker.mirantis.net/openstack-docker/alertmanager:latest
+    docker_image_pushgateway: docker-prod-virtual.docker.mirantis.net/openstack-docker/pushgateway:latest
+    docker_image_prometheus: docker-prod-virtual.docker.mirantis.net/openstack-docker/prometheus:latest
+    docker_image_remote_agent: docker-prod-virtual.docker.mirantis.net/openstack-docker/telegraf:latest
+    docker_image_remote_storage_adapter: docker-prod-virtual.docker.mirantis.net/openstack-docker/remote_storage_adapter:latest
     docker_image_grafana: grafana/grafana:4.3.2
     grafana_admin_password: admin
     keepalived_prometheus_vip_address: ${_param:cluster_vip_address}
diff --git a/classes/cluster/virtual-mcp11-k8s-contrail/stacklight/server.yml b/classes/cluster/virtual-mcp11-k8s-contrail/stacklight/server.yml
index 33033d9..761616f 100644
--- a/classes/cluster/virtual-mcp11-k8s-contrail/stacklight/server.yml
+++ b/classes/cluster/virtual-mcp11-k8s-contrail/stacklight/server.yml
@@ -34,11 +34,11 @@
   _param:
     cluster_public_host: mon
     cluster_vip_address: ${_param:stacklight_monitor_address}
-    docker_image_alertmanager: mirantis/alertmanager:latest
-    docker_image_pushgateway: mirantis/pushgateway:latest
-    docker_image_prometheus: mirantis/prometheus:latest
-    docker_image_remote_agent: mirantis/telegraf:latest
-    docker_image_remote_storage_adapter: mirantis/remote_storage_adapter:latest
+    docker_image_alertmanager: docker-prod-virtual.docker.mirantis.net/openstack-docker/alertmanager:latest
+    docker_image_pushgateway: docker-prod-virtual.docker.mirantis.net/openstack-docker/pushgateway:latest
+    docker_image_prometheus: docker-prod-virtual.docker.mirantis.net/openstack-docker/prometheus:latest
+    docker_image_remote_agent: docker-prod-virtual.docker.mirantis.net/openstack-docker/telegraf:latest
+    docker_image_remote_storage_adapter: docker-prod-virtual.docker.mirantis.net/openstack-docker/remote_storage_adapter:latest
     docker_image_grafana: grafana/grafana:4.3.2
     grafana_admin_password: admin
     keepalived_prometheus_vip_address: ${_param:cluster_vip_address}
diff --git a/scripts/bootstrap_all.sh b/scripts/bootstrap_all.sh
index 4e4d248..445464e 100755
--- a/scripts/bootstrap_all.sh
+++ b/scripts/bootstrap_all.sh
@@ -16,9 +16,6 @@
 if [[ "$K8S_BOOTSTRAP" == "true" ]]; then
     "$CWD"/kubernetes_install.sh
 fi
-if [[ "$STACKLIGHTV2_BOOTSTRAP" == "true" ]]; then
-    "$CWD"/stacklightv2_infra_install.sh
-fi
 if [[ "$OPENSTACK_BOOTSTRAP" == "true" ]]; then
     "$CWD"/openstack_control_install.sh
     "$CWD"/stacklight_infra_install.sh
@@ -30,3 +27,6 @@
     fi
     "$CWD"/stacklight_monitor_install.sh
 fi
+if [[ "$STACKLIGHTV2_BOOTSTRAP" == "true" ]]; then
+    "$CWD"/stacklightv2_infra_install.sh
+fi
diff --git a/scripts/stacklightv2_infra_install.sh b/scripts/stacklightv2_infra_install.sh
index 08cb962..8ce538a 100755
--- a/scripts/stacklightv2_infra_install.sh
+++ b/scripts/stacklightv2_infra_install.sh
@@ -14,14 +14,14 @@
 INFLUXDB_SERVICE=$(salt -C 'I@influxdb:server' test.ping 1>/dev/null 2>&1 && echo true)
 
 # Configure Telegraf
-salt -C 'I@telegraf:agent' state.sls telegraf
+salt -C 'I@telegraf:agent or I@telegraf:remote_agent' state.sls telegraf
+
+# Configure log_collector
+salt -C 'I@heka:log_collector' state.sls heka.log_collector
 
 # Configure Elasticsearch/Kibana services
 salt -C 'I@elasticsearch:server' state.sls elasticsearch.server -b 1
 salt -C 'I@kibana:server' state.sls kibana.server -b 1
-salt -C 'I@elasticsearch:client' state.sls elasticsearch.client.service
-salt -C 'I@elasticsearch:client' --async service.restart salt-minion
-sleep 10
 salt -C 'I@elasticsearch:client' state.sls elasticsearch.client
 salt -C 'I@kibana:client' state.sls kibana.client
 
@@ -35,16 +35,14 @@
 salt -C 'I@salt:minion' mine.update
 sleep 5
 
-# Configure the services running in Docker Swarm
-salt -C 'I@docker:swarm' state.sls prometheus.server,prometheus.alertmanager -b 1
-for img in pushgateway alertmanager prometheus telegraf remote_storage_adapter; do
-    salt -C 'I@docker:swarm' dockerng.pull "docker-sandbox.sandbox.mirantis.net/bkupidura/$img"
-    salt -C 'I@docker:swarm' dockerng.tag "docker-sandbox.sandbox.mirantis.net/bkupidura/$img:latest" "mirantis/$img:latest"
-done
+# Generate the configuration for services running in Docker Swarm
+salt -C 'I@docker:swarm' state.sls prometheus,heka.remote_collector -b 1
+
+# Kick off the services in Docker Swarm
 salt -C 'I@docker:swarm:role:master' state.sls docker
 salt -C 'I@docker:swarm' dockerng.ps
 
-# Configure Grafana dashboards and datasources
+# Configure the Grafana dashboards and datasources
 stacklight_vip=$(get_param_value stacklight_monitor_address)
 wait_for_http_service "http://${stacklight_vip}:15013/"
 salt -C 'I@grafana:client' state.sls grafana.client