3 # ============LICENSE_START=======================================================
4 # ONAP : ccsdk feature sdnr wt
5 # ================================================================================
6 # Copyright (C) 2021 highstreet technologies GmbH Intellectual Property.
8 # ================================================================================
9 # Licensed under the Apache License, Version 2.0 (the "License");
10 # you may not use this file except in compliance with the License.
11 # You may obtain a copy of the License at
13 # http://www.apache.org/licenses/LICENSE-2.0
15 # Unless required by applicable law or agreed to in writing, software
16 # distributed under the License is distributed on an "AS IS" BASIS,
17 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 # See the License for the specific language governing permissions and
19 # limitations under the License.
20 # ============LICENSE_END=========================================================
23 docker-compose version
24 # update installed docker compose version
25 sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
26 sudo chmod +x /usr/local/bin/docker-compose
27 sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
30 docker-compose version
32 if [[ -z $WORKSPACE ]]; then
33 CUR_PATH="`dirname \"$0\"`" # relative path
34 CUR_PATH="`( cd \"$CUR_PATH\" && pwd )`" # absolutized and normalized
35 if [ -z "$CUR_PATH" ] ; then
36 echo "Permission error!"
40 # define location of workpsace based on where the current script is
41 WORKSPACE=$(cd $CUR_PATH/../../ && pwd)
44 if [[ -z $SCRIPTS ]]; then
45 SCRIPTS=$(cd $WORKSPACE/scripts && pwd)
48 HOST_IP=$(ip route get 8.8.8.8 | awk '/8.8.8.8/ {print $7}')
49 SDNC_WEB_PORT=${SDNC_WEB_PORT:-8282}
50 SDNC_PORT=${SDNC_PORT:-8181}
52 env_file="--env-file ${SCRIPTS}/sdnr/docker-compose/.env"
57 # alternative: MARIADB
58 SDNRDB_TYPE="${SDNRDB_TYPE:-ESDB}"
59 if [[ "$SDNRDB_TYPE" == "ESDB" ]]; then
60 sdnrdb_compose_file="docker-compose-sdnrdb-elasticsearch.yaml"
62 sdnrdb_compose_file="docker-compose-sdnrdb-mariadb.yaml"
66 # Call function with port like:
67 # check_for_ready_state 1234
68 # export SDNC_READY_RETRY_PERIOD and SDNC_READY_TIMEOUT to overwrite default values
69 function check_for_ready_state() {
71 SDNC_READY_RETRY_PERIOD=${SDNC_READY_RETRY_PERIOD:-15}
72 SDNC_READY_TIMEOUT=${SDNC_READY_TIMEOUT:-450}
73 max_retry=$(expr $SDNC_READY_TIMEOUT / $SDNC_READY_RETRY_PERIOD)
74 for ((i=1; i<=$max_retry; i++)); do
75 wait_time=$(expr $i \* $SDNC_READY_RETRY_PERIOD)
76 echo "[INFO] SDNC/R container not yet ready after: $wait_time seconds, Timeout: $SDNC_READY_TIMEOUT seconds"
77 curl -sS -m 1 -k -D - ${HTTPS_PREFIX}${HOST_IP}:${sdnc_port}/ready | grep 200 && break
78 if [ $i == $max_retry ]; then
79 echo "[ERROR] SDNC/R container not ready after ${SDNC_READY_TIMEOUT} seconds!"
80 export SDNC_READY_STATE_TIME_OUT=true
83 echo sleep ${SDNC_READY_RETRY_PERIOD}
84 sleep ${SDNC_READY_RETRY_PERIOD}
86 echo "[INFO] SDNC/R container ready after: $wait_time seconds"
89 function onap_dependent_components_launch() {
90 docker-compose $env_file -f ${WORKSPACE}/scripts/sdnr/docker-compose/docker-compose-onap-addons.yaml pull
91 docker-compose $env_file -f ${WORKSPACE}/scripts/sdnr/docker-compose/docker-compose-onap-addons.yaml up -d
93 function netconfserver_simulator_launch() {
94 docker-compose $env_file -f ${WORKSPACE}/scripts/sdnr/docker-compose/docker-compose-netconfserver-simulator.yaml pull
95 docker-compose $env_file -f ${WORKSPACE}/scripts/sdnr/docker-compose/docker-compose-netconfserver-simulator.yaml up -d
98 function nts_manager_launch() {
99 # starts all ntsim managers defined in the csv file
100 ${SCRIPTS}/sdnr/docker-compose/nts-manager-launch.sh $1
103 function nts_networkfunctions_launch() {
104 # starts all ntsim networkfucntions defined in the csv file
105 ${SCRIPTS}/sdnr/docker-compose/nts-networkfunctions-launch.sh $1
109 function sdnr_launch() {
110 #if [ -n "${CALLHOME}" ] ; then
111 #sdnrwtbootfeatures="-e SDNRWT_BOOTFEATURES=odl-netconf-callhome-ssh,sdnr-wt-feature-aggregator "
112 #callhomeport="-p ${CALL_HOME_PORT}:6666 "
114 if [ "$SDNR_CLUSTER_MODE" == "true" ]; then
115 sdnr_launch_cluster $1
117 sdnr_launch_single_node $1
122 function sdnr_launch_single_node() {
124 # Use locally build sdnr .. no need to pull
125 #docker-compose $env_file -f ${WORKSPACE}/scripts/sdnr/docker-compose/docker-compose-single-sdnr.yaml \
126 # -f ${WORKSPACE}/scripts/sdnr/docker-compose/$sdnrdb_compose_file \
128 docker-compose $env_file -f ${WORKSPACE}/scripts/sdnr/docker-compose/docker-compose-single-sdnr.yaml \
129 -f ${WORKSPACE}/scripts/sdnr/docker-compose/$sdnrdb_compose_file \
131 check_for_ready_state ${SDNC_PORT}
134 function sdnr_web_launch() {
135 # Use locally build sdnr, sdnc-web .. no need to pull
136 #docker-compose $env_file -f ${WORKSPACE}/scripts/sdnr/docker-compose/docker-compose-single-sdnr.yaml \
137 # -f ${WORKSPACE}/scripts/sdnr/docker-compose/docker-compose-single-sdnr-web.override.yaml \
138 # -f ${WORKSPACE}/scripts/sdnr/docker-compose/$sdnrdb_compose_file \
140 docker-compose $env_file -f ${WORKSPACE}/scripts/sdnr/docker-compose/docker-compose-single-sdnr.yaml \
141 -f ${WORKSPACE}/scripts/sdnr/docker-compose/docker-compose-single-sdnr-web.override.yaml \
142 -f ${WORKSPACE}/scripts/sdnr/docker-compose/$sdnrdb_compose_file \
144 check_for_ready_state ${SDNC_WEB_PORT}
147 function sdnr_launch_cluster() {
148 # source ${SCRIPTS}/sdnr/sdnrEnv_Cluster.sh
150 [[ -n "$1" ]] && SDNRDM="true" && echo "SDNRDM arg detected - running in headless mode"
151 echo "SDNR being launched in Cluster mode"
152 #docker-compose $env_file -f ${WORKSPACE}/scripts/sdnr/docker-compose/docker-compose/cluster-sdnr.yaml pull
153 docker-compose $env_file -f ${WORKSPACE}/scripts/sdnr/docker-compose/docker-compose/cluster-sdnr.yaml up -d
154 check_for_ready_state ${SDNC_WEB_PORT}