blob: 70dda84b6a7f9add1d1f9677ffb3ecf6cb4ee0f3 [file] [log] [blame]
Venkata Harish K Kajurd6f0c1e2017-09-27 10:42:28 -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 Kajurf1ffdbc2017-12-12 22:58:54 -050027DOCKER_IMAGE_VERSION=1.2-STAGING-latest
Venkata Harish K Kajurd6f0c1e2017-09-27 10:42:28 -040028
Venkata Harish K Kajur3918ac52018-03-14 10:05:27 -040029export CURRENT_PWD=$(pwd);
30
Venkata Harish K Kajurd6f0c1e2017-09-27 10:42:28 -040031function wait_for_container() {
32
33 CONTAINER_NAME="$1";
34 START_TEXT="$2";
35
36 TIMEOUT=360
37
38 # wait for the real startup
39 AMOUNT_STARTUP=$(docker logs ${CONTAINER_NAME} 2>&1 | grep "$START_TEXT" | wc -l)
40 while [[ ${AMOUNT_STARTUP} -ne 1 ]];
41 do
42 echo "Waiting for '$CONTAINER_NAME' deployment to finish ..."
43 AMOUNT_STARTUP=$(docker logs ${CONTAINER_NAME} 2>&1 | grep "$START_TEXT" | wc -l)
44 if [ "$TIMEOUT" = "0" ];
45 then
46 docker logs ${CONTAINER_NAME};
47 echo "ERROR: $CONTAINER_NAME deployment failed."
48 exit 1
49 fi
50 let TIMEOUT-=1
51 sleep 1
52 done
53}
54
55DOCKER_COMPOSE_CMD="docker-compose";
56export MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1);
57export DOCKER_REGISTRY="nexus3.onap.org:10001";
58export AAI_HAPROXY_IMAGE="${AAI_HAPROXY_IMAGE:-aaionap/haproxy}";
Venkata Harish K Kajurf1ffdbc2017-12-12 22:58:54 -050059export HAPROXY_VERSION="${HAPROXY_VERSION:-1.2.0}";
Venkata Harish K Kajurd6f0c1e2017-09-27 10:42:28 -040060export HBASE_IMAGE="${HBASE_IMAGE:-aaionap/hbase}";
61export HBASE_VERSION="${HBASE_VERSION:-1.2.0}";
62
63docker pull ${HBASE_IMAGE}:${HBASE_VERSION};
Singhsumalee, Pete (ps2418)56bb06b2017-09-25 14:13:15 -050064
Venkata Harish K Kajurf1ffdbc2017-12-12 22:58:54 -050065docker pull ${DOCKER_REGISTRY}/onap/aai-resources:${DOCKER_IMAGE_VERSION};
66docker tag ${DOCKER_REGISTRY}/onap/aai-resources:${DOCKER_IMAGE_VERSION} ${DOCKER_REGISTRY}/onap/aai-resources:latest;
Venkata Harish K Kajurd6f0c1e2017-09-27 10:42:28 -040067
Venkata Harish K Kajurf1ffdbc2017-12-12 22:58:54 -050068docker pull ${DOCKER_REGISTRY}/onap/aai-traversal:${DOCKER_IMAGE_VERSION};
69docker tag ${DOCKER_REGISTRY}/onap/aai-traversal:${DOCKER_IMAGE_VERSION} ${DOCKER_REGISTRY}/onap/aai-traversal:latest;
Venkata Harish K Kajurd6f0c1e2017-09-27 10:42:28 -040070
71${DOCKER_COMPOSE_CMD} stop
72${DOCKER_COMPOSE_CMD} rm -f -v
73
74# Start the hbase where the data will be stored
Kajur, Harish (vk250x)fe335852018-03-29 07:11:11 -040075CASSANDRA_CONTAINER_NAME=$(${DOCKER_COMPOSE_CMD} up -d aai.hbase.simpledemo.onap.org 2>&1 | grep 'Creating' | grep -v 'volume' | grep -v 'network' | awk '{ print $2; }' | head -1);
76wait_for_container $CASSANDRA_CONTAINER_NAME 'Listening for thrift clients';
Venkata Harish K Kajurd6f0c1e2017-09-27 10:42:28 -040077
78USER_EXISTS=$(check_if_user_exists aaiadmin);
79
80function check_if_user_exists(){
81 local user_id=$1;
82
83 if [ -z "$user_id" ]; then
84 echo "Needs to provide at least one argument for check_if_user_exists func";
85 exit 1;
86 fi;
87
88 id -u ${user_id} > /dev/null 2>&1 && {
89 echo "1";
90 } || {
91 echo "0";
92 }
93}
94
95
96if [ "${USER_EXISTS}" -eq 0 ]; then
97 export USER_ID=9000;
Venkata Harish K Kajur3918ac52018-03-14 10:05:27 -040098 export GROUP_ID=9000;
Venkata Harish K Kajurd6f0c1e2017-09-27 10:42:28 -040099else
100 export USER_ID=$(id -u aaiadmin);
Venkata Harish K Kajur3918ac52018-03-14 10:05:27 -0400101 export GROUP_ID=$(id -g aaiadmin);
Venkata Harish K Kajurd6f0c1e2017-09-27 10:42:28 -0400102fi;
103
Kajur, Harish (vk250x)fe335852018-03-29 07:11:11 -0400104$DOCKER_COMPOSE_CMD run --rm aai-resources.api.simpledemo.onap.org createDBSchema.sh
105
Venkata Harish K Kajurf1ffdbc2017-12-12 22:58:54 -0500106RESOURCES_CONTAINER_NAME=$(${DOCKER_COMPOSE_CMD} up -d aai-resources.api.simpledemo.onap.org 2>&1 | grep 'Creating' | grep -v 'volume' | grep -v 'network' | awk '{ print $2; }' | head -1);
Venkata Harish K Kajur3918ac52018-03-14 10:05:27 -0400107wait_for_container $RESOURCES_CONTAINER_NAME 'Resources Microservice Started';
Venkata Harish K Kajurd6f0c1e2017-09-27 10:42:28 -0400108
Venkata Harish K Kajur3918ac52018-03-14 10:05:27 -0400109${DOCKER_COMPOSE_CMD} up -d aai-traversal.api.simpledemo.onap.org aai.api.simpledemo.onap.org
110TRAVERSAL_CONTAINER_NAME=$(echo $RESOURCES_CONTAINER_NAME | sed 's/aai-resources/aai-traversal/g');
Venkata Harish K Kajurd6f0c1e2017-09-27 10:42:28 -0400111
Kajur, Harish (vk250x)fe335852018-03-29 07:11:11 -0400112$DOCKER_COMPOSE_CMD run --rm aai-traversal.api.simpledemo.onap.org install/updateQueryData.sh
113
Venkata Harish K Kajurd6f0c1e2017-09-27 10:42:28 -0400114echo "A&AI Microservices, resources and traversal, are up and running along with HAProxy";
Venkata Harish K Kajur3918ac52018-03-14 10:05:27 -0400115
116wait_for_container $TRAVERSAL_CONTAINER_NAME 'Traversal Microservice Started';
117
Venkata Harish K Kajurd6f0c1e2017-09-27 10:42:28 -0400118# Set the host ip for robot from the haproxy
119ROBOT_VARIABLES="-v HOST_IP:`ip addr show docker0 | head -3 | tail -1 | cut -d' ' -f6 | cut -d'/' -f1`"