blob: 0c41d3e3e039591d827161d7cfa1bd2a1830c0b2 [file] [log] [blame]
jmac065e2ce2018-03-29 01:18:02 +00001#!/bin/bash
2
3###
4# ============LICENSE_START=======================================================
5# SDNC
6# ================================================================================
7# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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
12#
13# http://www.apache.org/licenses/LICENSE-2.0
14#
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=========================================================
21###
22
23function enable_odl_cluster(){
24 if [ -z $SDNC_REPLICAS ]; then
25 echo "SDNC_REPLICAS is not configured in Env field"
26 exit
27 fi
28
29 echo "Installing Opendaylight cluster features"
jmacc74329e2018-04-11 21:52:01 +000030 ${ODL_HOME}/bin/client feature:install odl-mdsal-clustering
31 ${ODL_HOME}/bin/client feature:install odl-jolokia
jmac065e2ce2018-03-29 01:18:02 +000032
33 echo "Update cluster information statically"
34 hm=$(hostname)
35 echo "Get current Hostname ${hm}"
36
37 node=($(echo ${hm} | sed 's/-[0-9]*$//g'))
38 node_index=($(echo ${hm} | awk -F"-" '{print $NF}'))
39 node_list="${node}-0.{{ .Values.service.name }}-cluster.{{.Release.Namespace}}";
40
41 for ((i=1;i<${SDNC_REPLICAS};i++));
42 do
43 node_list="${node_list} ${node}-$i.{{ .Values.service.name }}-cluster.{{.Release.Namespace}}"
44 done
45
46 /opt/opendaylight/current/bin/configure_cluster.sh $((node_index+1)) ${node_list}
47}
48
49ODL_HOME=${ODL_HOME:-/opt/opendaylight/current}
50ODL_ADMIN_PASSWORD=${ODL_ADMIN_PASSWORD:-Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U}
51SDNC_HOME=${SDNC_HOME:-/opt/onap/sdnc}
52SLEEP_TIME=${SLEEP_TIME:-120}
53MYSQL_PASSWD=${MYSQL_PASSWD:-{{.Values.config.dbRootPassword}}}
54ENABLE_ODL_CLUSTER=${ENABLE_ODL_CLUSTER:-false}
jmacbc92d132018-04-07 03:46:12 +000055MYSQL_HOST=${MYSQL_HOST:-{{.Release.Name}}-{{.Values.mysql.nameOverride}}-0.{{.Values.mysql.service.name}}.{{.Release.Namespace}}}
jmac065e2ce2018-03-29 01:18:02 +000056
57#
58# Wait for database to init properly
59#
60echo "Waiting for mysql"
jmacbc92d132018-04-07 03:46:12 +000061until mysql -h ${MYSQL_HOST} -u root -p${MYSQL_PASSWD} mysql &> /dev/null
jmac065e2ce2018-03-29 01:18:02 +000062do
63 printf "."
64 sleep 1
65done
66echo -e "\nmysql ready"
67
68if [ ! -f ${SDNC_HOME}/.installed ]
69then
70 echo "Installing SDNC database"
71 ${SDNC_HOME}/bin/installSdncDb.sh
72 echo "Installing SDN-C keyStore"
73 ${SDNC_HOME}/bin/addSdncKeyStore.sh
74 echo "Starting OpenDaylight"
75 ${ODL_HOME}/bin/start
76 echo "Waiting ${SLEEP_TIME} seconds for OpenDaylight to initialize"
77 sleep ${SLEEP_TIME}
78 echo "Installing SDN-C platform features"
79 ${SDNC_HOME}/bin/installFeatures.sh
80 if [ -x ${SDNC_HOME}/svclogic/bin/install.sh ]
81 then
82 echo "Installing directed graphs"
83 ${SDNC_HOME}/svclogic/bin/install.sh
84 fi
85
86 if $ENABLE_ODL_CLUSTER ; then enable_odl_cluster ; fi
87
88 echo "Restarting OpenDaylight"
89 ${ODL_HOME}/bin/stop
jmacc74329e2018-04-11 21:52:01 +000090
91 echo "Waiting 60 seconds for OpenDaylight stop to complete"
92 sleep 60
93
jmac065e2ce2018-03-29 01:18:02 +000094 echo "Installed at `date`" > ${SDNC_HOME}/.installed
95fi
96
97exec ${ODL_HOME}/bin/karaf
98