blob: 30b4b29b89d8a163d940c6383f33c919fc9066d5 [file] [log] [blame]
Venkata Harish K Kajur96f120c2017-09-07 22:09:25 -04001#!/bin/bash
2#
3# Copyright © 2017 AT&T Intellectual Property.
4# All rights reserved.
5#
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
18# ECOMP is a trademark and service mark of AT&T Intellectual Property.
19
20source ${SCRIPTS}/common_functions.sh
21
22NEXUS_USERNAME=$(cat /opt/config/nexus_username.txt)
23NEXUS_PASSWD=$(cat /opt/config/nexus_password.txt)
24NEXUS_DOCKER_REPO=$(cat /opt/config/nexus_docker_repo.txt)
25DOCKER_IMAGE_VERSION=$(cat /opt/config/docker_version.txt)
26DOCKER_REGISTRY=${NEXUS_DOCKER_REPO}
Venkata Harish K Kajurcbcc00c2017-09-09 20:30:04 -040027DOCKER_IMAGE_VERSION=1.1-STAGING-latest
Venkata Harish K Kajur96f120c2017-09-07 22:09:25 -040028
29function wait_for_container() {
30
31 CONTAINER_NAME="$1";
32 START_TEXT="$2";
33
Venkata Harish K Kajurcbcc00c2017-09-09 20:30:04 -040034 TIMEOUT=240
Venkata Harish K Kajur96f120c2017-09-07 22:09:25 -040035
36 # wait for the real startup
37 AMOUNT_STARTUP=$(docker logs ${CONTAINER_NAME} 2>&1 | grep "$START_TEXT" | wc -l)
38 while [[ ${AMOUNT_STARTUP} -ne 1 ]];
39 do
40 echo "Waiting for '$CONTAINER_NAME' deployment to finish ..."
41 AMOUNT_STARTUP=$(docker logs ${CONTAINER_NAME} 2>&1 | grep "$START_TEXT" | wc -l)
42 if [ "$TIMEOUT" = "0" ];
43 then
Venkata Harish K Kajurcbcc00c2017-09-09 20:30:04 -040044 docker logs ${CONTAINER_NAME};
Venkata Harish K Kajur96f120c2017-09-07 22:09:25 -040045 echo "ERROR: $CONTAINER_NAME deployment failed."
46 exit 1
47 fi
48 let TIMEOUT-=1
49 sleep 1
50 done
51}
52
53DOCKER_COMPOSE_CMD="docker-compose";
54export MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1);
55export DOCKER_REGISTRY="nexus3.onap.org:10001";
Venkata Harish K Kajurcbcc00c2017-09-09 20:30:04 -040056export AAI_HAPROXY_IMAGE="${AAI_HAPROXY_IMAGE:-aaionap/haproxy}";
Venkata Harish K Kajur96f120c2017-09-07 22:09:25 -040057export HBASE_IMAGE="${HBASE_IMAGE:-harisekhon/hbase}";
58
59docker pull ${DOCKER_REGISTRY}/openecomp/aai-resources:${DOCKER_IMAGE_VERSION};
60docker tag ${DOCKER_REGISTRY}/openecomp/aai-resources:${DOCKER_IMAGE_VERSION} ${DOCKER_REGISTRY}/openecomp/aai-resources:latest;
61
62docker pull ${DOCKER_REGISTRY}/openecomp/aai-traversal:${DOCKER_IMAGE_VERSION};
63docker tag ${DOCKER_REGISTRY}/openecomp/aai-traversal:${DOCKER_IMAGE_VERSION} ${DOCKER_REGISTRY}/openecomp/aai-traversal:latest;
64
65${DOCKER_COMPOSE_CMD} stop
66${DOCKER_COMPOSE_CMD} rm -f -v
67
68# Start the hbase where the data will be stored
69HBASE_CONTAINER_NAME=$(${DOCKER_COMPOSE_CMD} up -d aai.hbase.simpledemo.openecomp.org 2>&1 | grep 'Creating' | grep -v 'volume' | grep -v 'network' | awk '{ print $2; }' | head -1);
70wait_for_container ${HBASE_CONTAINER_NAME} ' Started SelectChannelConnector@0.0.0.0:8085';
71wait_for_container ${HBASE_CONTAINER_NAME} ' Started SelectChannelConnector@0.0.0.0:8080';
72wait_for_container ${HBASE_CONTAINER_NAME} ' Started SelectChannelConnector@0.0.0.0:9095';
73
74# Start the resources microservice
75RESOURCES_CONTAINER_NAME=$(${DOCKER_COMPOSE_CMD} up -d aai-resources.api.simpledemo.openecomp.org 2>&1 | grep 'Creating' | grep -v 'volume' | grep -v 'network' | awk '{ print $2; }' | head -1);
76wait_for_container ${RESOURCES_CONTAINER_NAME} '0.0.0.0:8447';
Venkata Harish K Kajurcbcc00c2017-09-09 20:30:04 -040077docker logs ${CONTAINER_NAME};
Venkata Harish K Kajur96f120c2017-09-07 22:09:25 -040078
79# Start the traversal microservice
Venkata Harish K Kajurcbcc00c2017-09-09 20:30:04 -040080GRAPH_CONTAINER_NAME=$(${DOCKER_COMPOSE_CMD} up -d aai-traversal.api.simpledemo.openecomp.org 2>&1 | grep 'Creating' | awk '{ print $2; }' | head -1);
Venkata Harish K Kajur96f120c2017-09-07 22:09:25 -040081wait_for_container ${GRAPH_CONTAINER_NAME} '0.0.0.0:8446';
82
83# Start the haproxy to route requests between resources and traversal
84HAPROXY_CONTAINER_NAME=$(${DOCKER_COMPOSE_CMD} up -d aai.api.simpledemo.openecomp.org 2>&1 |grep 'Creating' | grep -v 'volume' | grep -v 'network' | awk '{ print $2; }' | head -1);
85
86echo "A&AI Microservices, resources and traversal, are up and running along with HAProxy";
87
Venkata Harish K Kajurcbcc00c2017-09-09 20:30:04 -040088docker exec $GRAPH_CONTAINER_NAME "/opt/app/aai-traversal/scripts/install/updateQueryData.sh" && {
Venkata Harish K Kajur96f120c2017-09-07 22:09:25 -040089 echo "Successfully loaded the widget related data into db";
90} || {
91 echo "Unable to load widget related data into db";
92}
93
Venkata Harish K Kajur96f120c2017-09-07 22:09:25 -040094# Set the host ip for robot from the haproxy
Venkata Harish K Kajurcbcc00c2017-09-09 20:30:04 -040095ROBOT_VARIABLES="-v HOST_IP:`ip addr show docker0 | head -3 | tail -1 | cut -d' ' -f6 | cut -d'/' -f1`"