blob: 6383853c32d5f9fcf3667c9080fa4fc818564d8f [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"
Timoney, Dan (dt5972)1bb05c82018-07-24 10:10:08 -040030 cat $ODL_HOME/etc/org.apache.karaf.features.cfg | sed -e "\|featuresBoot=config|s|$|,odl-mdsal-clustering,odl-jolokia|" > $ODL_HOME/etc/org.apache.karaf.features.cfg
31 #${ODL_HOME}/bin/client feature:install odl-mdsal-clustering
32 #${ODL_HOME}/bin/client feature:install odl-jolokia
jmac065e2ce2018-03-29 01:18:02 +000033
34 echo "Update cluster information statically"
35 hm=$(hostname)
36 echo "Get current Hostname ${hm}"
37
Trevor Tait702d1052018-04-20 11:21:09 -040038 node=($(echo ${hm} | sed 's/-[0-9]*$//g'))
39 node_index=($(echo ${hm} | awk -F"-" '{print $NF}'))
40 member_offset=1
jmac065e2ce2018-03-29 01:18:02 +000041
Trevor Tait567ff1e2018-05-01 16:20:54 -040042 if $GEO_ENABLED; then
jmacc21cb7d2018-04-16 19:54:54 +000043 echo "This is a Geo cluster"
44
Trevor Tait567ff1e2018-05-01 16:20:54 -040045 if [ -z $IS_PRIMARY_CLUSTER ] || [ -z $MY_ODL_CLUSTER ] || [ -z $PEER_ODL_CLUSTER ]; then
46 echo "IS_PRIMARY_CLUSTER, MY_ODL_CLUSTER and PEER_ODL_CLUSTER must all be configured in Env field"
47 return
48 fi
49
jmacc21cb7d2018-04-16 19:54:54 +000050 if $IS_PRIMARY_CLUSTER; then
51 PRIMARY_NODE=${MY_ODL_CLUSTER}
52 SECONDARY_NODE=${PEER_ODL_CLUSTER}
53 else
54 PRIMARY_NODE=${PEER_ODL_CLUSTER}
55 SECONDARY_NODE=${MY_ODL_CLUSTER}
56 member_offset=4
57 fi
58
59 node_list="${PRIMARY_NODE} ${SECONDARY_NODE}"
Trevor Tait567ff1e2018-05-01 16:20:54 -040060
jmacc21cb7d2018-04-16 19:54:54 +000061 /opt/onap/sdnc/bin/configure_geo_cluster.sh $((node_index+member_offset)) ${node_list}
Trevor Tait567ff1e2018-05-01 16:20:54 -040062 else
63 echo "This is a local cluster"
64
65 node_list="${node}-0.{{.Values.service.name}}-cluster.{{.Release.Namespace}}";
66
67 for ((i=1;i<${SDNC_REPLICAS};i++));
68 do
69 node_list="${node_list} ${node}-$i.{{.Values.service.name}}-cluster.{{.Release.Namespace}}"
70 done
71
72 /opt/opendaylight/current/bin/configure_cluster.sh $((node_index+1)) ${node_list}
jmacc21cb7d2018-04-16 19:54:54 +000073 fi
jmac065e2ce2018-03-29 01:18:02 +000074}
75
jmacc21cb7d2018-04-16 19:54:54 +000076
77# Install SDN-C platform components if not already installed and start container
78
jmac065e2ce2018-03-29 01:18:02 +000079ODL_HOME=${ODL_HOME:-/opt/opendaylight/current}
80ODL_ADMIN_PASSWORD=${ODL_ADMIN_PASSWORD:-Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U}
81SDNC_HOME=${SDNC_HOME:-/opt/onap/sdnc}
Trevor Tait702d1052018-04-20 11:21:09 -040082CCSDK_HOME=${CCSDK_HOME:-/opt/onap/ccsdk}
jmac065e2ce2018-03-29 01:18:02 +000083SLEEP_TIME=${SLEEP_TIME:-120}
84MYSQL_PASSWD=${MYSQL_PASSWD:-{{.Values.config.dbRootPassword}}}
jmacbc92d132018-04-07 03:46:12 +000085MYSQL_HOST=${MYSQL_HOST:-{{.Release.Name}}-{{.Values.mysql.nameOverride}}-0.{{.Values.mysql.service.name}}.{{.Release.Namespace}}}
Trevor Tait567ff1e2018-05-01 16:20:54 -040086ENABLE_ODL_CLUSTER=${ENABLE_ODL_CLUSTER:-false}
87GEO_ENABLED=${GEO_ENABLED:-false}
jmac065e2ce2018-03-29 01:18:02 +000088
89#
90# Wait for database to init properly
91#
92echo "Waiting for mysql"
jmacbc92d132018-04-07 03:46:12 +000093until mysql -h ${MYSQL_HOST} -u root -p${MYSQL_PASSWD} mysql &> /dev/null
jmac065e2ce2018-03-29 01:18:02 +000094do
95 printf "."
96 sleep 1
97done
98echo -e "\nmysql ready"
99
100if [ ! -f ${SDNC_HOME}/.installed ]
101then
102 echo "Installing SDNC database"
103 ${SDNC_HOME}/bin/installSdncDb.sh
104 echo "Installing SDN-C keyStore"
105 ${SDNC_HOME}/bin/addSdncKeyStore.sh
Timoney, Dan (dt5972)1bb05c82018-07-24 10:10:08 -0400106
107 # No longer needed (this was a workaround for bug in Nitrogen)
108 #${CCSDK_HOME}/bin/installOdlHostKey.sh
109
jmac065e2ce2018-03-29 01:18:02 +0000110 if [ -x ${SDNC_HOME}/svclogic/bin/install.sh ]
111 then
112 echo "Installing directed graphs"
113 ${SDNC_HOME}/svclogic/bin/install.sh
114 fi
115
116 if $ENABLE_ODL_CLUSTER ; then enable_odl_cluster ; fi
117
jmac065e2ce2018-03-29 01:18:02 +0000118 echo "Installed at `date`" > ${SDNC_HOME}/.installed
119fi
120
121exec ${ODL_HOME}/bin/karaf
122