blob: 536777ac86e3435eb561e96c730ab4b3cdf4f87c [file] [log] [blame]
tragait9bbcb1b2020-02-24 16:33:50 +00001#!/bin/bash
2#
3# ============LICENSE_START=======================================================
4# Copyright (C) 2020 Nordix Foundation.
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# SPDX-License-Identifier: Apache-2.0
19# ============LICENSE_END=========================================================
20
21# @author Rahul Tyagi (rahul.tyagi@est.tech)
22# setup sdnc
23
24export SDNC_CERT_PATH=${CERT_SUBPATH}
25
26docker pull $NEXUS_DOCKER_REPO/onap/sdnc-image:$SDNC_IMAGE_TAG
27docker tag $NEXUS_DOCKER_REPO/onap/sdnc-image:$SDNC_IMAGE_TAG onap/sdnc-image:latest
28
29#docker pull $NEXUS_DOCKER_REPO/onap/sdnc-ansible-server-image:$SDNC_IMAGE_TAG
30#docker tag $NEXUS_DOCKER_REPO/onap/sdnc-ansible-server-image:$SDNC_IMAGE_TAG onap/sdnc-ansible-server-image:latest
31
32#start SDNC containers with docker compose and configuration from docker-compose.yml
33docker-compose -f $SDNC_DOCKER_PATH/docker-compose.yml -p $PROJECT_NAME up -d
34
35# WAIT 10 minutes maximum and test every 5 seconds if SDNC is up using HealthCheck API
36TIME_OUT=1000
37INTERVAL=30
38TIME=0
39while [ "$TIME" -lt "$TIME_OUT" ]; do
40 response=$(curl --write-out '%{http_code}' --silent --output /dev/null -H "Authorization: Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==" -X POST -H "X-FromAppId: csit-sdnc" -H "X-TransactionId: csit-sdnc" -H "Accept: application/json" -H "Content-Type: application/json" http://localhost:8282/restconf/operations/SLI-API:healthcheck );
41 echo $response
42
43 if [ "$response" == "200" ]; then
44 echo SDNC started in $TIME seconds
45 break;
46 fi
47
48 echo Sleep: $INTERVAL seconds before testing if SDNC is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
49 sleep $INTERVAL
50 TIME=$(($TIME+$INTERVAL))
51done
52
53export LOCAL_IP=$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+')
54sed -i "s/pnfaddr/$LOCAL_IP/g" $REQUEST_DATA_PATH/mount.xml
55
56
57if [ "$TIME" -ge "$TIME_OUT" ]; then
58 echo TIME OUT: karaf session not started in $TIME_OUT seconds... Could cause problems for testing activities...
59fi