jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 1 | #!/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 | |
| 23 | function 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" |
jmac | dbbe937 | 2018-07-30 20:18:44 +0000 | [diff] [blame] | 30 | mv $ODL_HOME/etc/org.apache.karaf.features.cfg $ODL_HOME/etc/org.apache.karaf.features.cfg.orig |
| 31 | cat $ODL_HOME/etc/org.apache.karaf.features.cfg.orig | sed -e "\|featuresBoot=config|s|$|,odl-mdsal-clustering,odl-jolokia|" > $ODL_HOME/etc/org.apache.karaf.features.cfg |
Timoney, Dan (dt5972) | 1bb05c8 | 2018-07-24 10:10:08 -0400 | [diff] [blame] | 32 | #${ODL_HOME}/bin/client feature:install odl-mdsal-clustering |
| 33 | #${ODL_HOME}/bin/client feature:install odl-jolokia |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 34 | |
| 35 | echo "Update cluster information statically" |
| 36 | hm=$(hostname) |
| 37 | echo "Get current Hostname ${hm}" |
| 38 | |
Trevor Tait | 702d105 | 2018-04-20 11:21:09 -0400 | [diff] [blame] | 39 | node=($(echo ${hm} | sed 's/-[0-9]*$//g')) |
| 40 | node_index=($(echo ${hm} | awk -F"-" '{print $NF}')) |
| 41 | member_offset=1 |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 42 | |
Trevor Tait | 567ff1e | 2018-05-01 16:20:54 -0400 | [diff] [blame] | 43 | if $GEO_ENABLED; then |
jmac | c21cb7d | 2018-04-16 19:54:54 +0000 | [diff] [blame] | 44 | echo "This is a Geo cluster" |
| 45 | |
Trevor Tait | 567ff1e | 2018-05-01 16:20:54 -0400 | [diff] [blame] | 46 | if [ -z $IS_PRIMARY_CLUSTER ] || [ -z $MY_ODL_CLUSTER ] || [ -z $PEER_ODL_CLUSTER ]; then |
| 47 | echo "IS_PRIMARY_CLUSTER, MY_ODL_CLUSTER and PEER_ODL_CLUSTER must all be configured in Env field" |
| 48 | return |
| 49 | fi |
| 50 | |
jmac | c21cb7d | 2018-04-16 19:54:54 +0000 | [diff] [blame] | 51 | if $IS_PRIMARY_CLUSTER; then |
| 52 | PRIMARY_NODE=${MY_ODL_CLUSTER} |
| 53 | SECONDARY_NODE=${PEER_ODL_CLUSTER} |
| 54 | else |
| 55 | PRIMARY_NODE=${PEER_ODL_CLUSTER} |
| 56 | SECONDARY_NODE=${MY_ODL_CLUSTER} |
| 57 | member_offset=4 |
| 58 | fi |
| 59 | |
| 60 | node_list="${PRIMARY_NODE} ${SECONDARY_NODE}" |
Trevor Tait | 567ff1e | 2018-05-01 16:20:54 -0400 | [diff] [blame] | 61 | |
jmac | c21cb7d | 2018-04-16 19:54:54 +0000 | [diff] [blame] | 62 | /opt/onap/sdnc/bin/configure_geo_cluster.sh $((node_index+member_offset)) ${node_list} |
Trevor Tait | 567ff1e | 2018-05-01 16:20:54 -0400 | [diff] [blame] | 63 | else |
| 64 | echo "This is a local cluster" |
| 65 | |
| 66 | node_list="${node}-0.{{.Values.service.name}}-cluster.{{.Release.Namespace}}"; |
| 67 | |
| 68 | for ((i=1;i<${SDNC_REPLICAS};i++)); |
| 69 | do |
| 70 | node_list="${node_list} ${node}-$i.{{.Values.service.name}}-cluster.{{.Release.Namespace}}" |
| 71 | done |
| 72 | |
| 73 | /opt/opendaylight/current/bin/configure_cluster.sh $((node_index+1)) ${node_list} |
jmac | c21cb7d | 2018-04-16 19:54:54 +0000 | [diff] [blame] | 74 | fi |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 75 | } |
| 76 | |
jmac | c21cb7d | 2018-04-16 19:54:54 +0000 | [diff] [blame] | 77 | |
| 78 | # Install SDN-C platform components if not already installed and start container |
| 79 | |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 80 | ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} |
| 81 | ODL_ADMIN_PASSWORD=${ODL_ADMIN_PASSWORD:-Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U} |
| 82 | SDNC_HOME=${SDNC_HOME:-/opt/onap/sdnc} |
DarraghEgan | dbb5b68 | 2019-03-25 18:04:31 +0000 | [diff] [blame] | 83 | SDNC_BIN=${SDNC_BIN:-/opt/onap/sdnc/bin} |
Trevor Tait | 702d105 | 2018-04-20 11:21:09 -0400 | [diff] [blame] | 84 | CCSDK_HOME=${CCSDK_HOME:-/opt/onap/ccsdk} |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 85 | SLEEP_TIME=${SLEEP_TIME:-120} |
| 86 | MYSQL_PASSWD=${MYSQL_PASSWD:-{{.Values.config.dbRootPassword}}} |
jmac | bc92d13 | 2018-04-07 03:46:12 +0000 | [diff] [blame] | 87 | MYSQL_HOST=${MYSQL_HOST:-{{.Release.Name}}-{{.Values.mysql.nameOverride}}-0.{{.Values.mysql.service.name}}.{{.Release.Namespace}}} |
Trevor Tait | 567ff1e | 2018-05-01 16:20:54 -0400 | [diff] [blame] | 88 | ENABLE_ODL_CLUSTER=${ENABLE_ODL_CLUSTER:-false} |
| 89 | GEO_ENABLED=${GEO_ENABLED:-false} |
Timoney, Dan (dt5972) | eaa6a24 | 2018-11-16 17:08:12 -0500 | [diff] [blame] | 90 | DBINIT_DIR=${DBINIT_DIR:-/opt/opendaylight/current/daexim} |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 91 | |
| 92 | # |
| 93 | # Wait for database to init properly |
| 94 | # |
| 95 | echo "Waiting for mysql" |
jmac | bc92d13 | 2018-04-07 03:46:12 +0000 | [diff] [blame] | 96 | until mysql -h ${MYSQL_HOST} -u root -p${MYSQL_PASSWD} mysql &> /dev/null |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 97 | do |
| 98 | printf "." |
| 99 | sleep 1 |
| 100 | done |
| 101 | echo -e "\nmysql ready" |
| 102 | |
Timoney, Dan (dt5972) | eaa6a24 | 2018-11-16 17:08:12 -0500 | [diff] [blame] | 103 | if [ ! -d ${DBINIT_DIR} ] |
Timoney, Dan (dt5972) | e156c23 | 2018-11-14 10:34:31 -0500 | [diff] [blame] | 104 | then |
Timoney, Dan (dt5972) | eaa6a24 | 2018-11-16 17:08:12 -0500 | [diff] [blame] | 105 | mkdir -p ${DBINIT_DIR} |
Timoney, Dan (dt5972) | e156c23 | 2018-11-14 10:34:31 -0500 | [diff] [blame] | 106 | fi |
| 107 | |
Timoney, Dan (dt5972) | eaa6a24 | 2018-11-16 17:08:12 -0500 | [diff] [blame] | 108 | if [ ! -f ${DBINIT_DIR}/.installed ] |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 109 | then |
| 110 | echo "Installing SDNC database" |
| 111 | ${SDNC_HOME}/bin/installSdncDb.sh |
Timoney, Dan (dt5972) | 1bb05c8 | 2018-07-24 10:10:08 -0400 | [diff] [blame] | 112 | |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 113 | if [ -x ${SDNC_HOME}/svclogic/bin/install.sh ] |
| 114 | then |
| 115 | echo "Installing directed graphs" |
| 116 | ${SDNC_HOME}/svclogic/bin/install.sh |
| 117 | fi |
| 118 | |
Timoney, Dan (dt5972) | eaa6a24 | 2018-11-16 17:08:12 -0500 | [diff] [blame] | 119 | echo "Installed at `date`" > ${DBINIT_DIR}/.installed |
| 120 | fi |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 121 | |
Timoney, Dan (dt5972) | eaa6a24 | 2018-11-16 17:08:12 -0500 | [diff] [blame] | 122 | if [ ! -f ${SDNC_HOME}/.installed ] |
| 123 | then |
| 124 | echo "Installing SDN-C keyStore" |
| 125 | ${SDNC_HOME}/bin/addSdncKeyStore.sh |
| 126 | |
| 127 | # No longer needed (this was a workaround for bug in Nitrogen) |
| 128 | #${CCSDK_HOME}/bin/installOdlHostKey.sh |
| 129 | |
| 130 | if $ENABLE_ODL_CLUSTER ; then enable_odl_cluster ; fi |
| 131 | |
| 132 | echo "Installed at `date`" > ${SDNC_HOME}/.installed |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 133 | fi |
| 134 | |
DarraghEgan | dbb5b68 | 2019-03-25 18:04:31 +0000 | [diff] [blame] | 135 | cp /opt/opendaylight/current/certs/* /tmp |
| 136 | |
| 137 | nohup python ${SDNC_BIN}/installCerts.py & |
| 138 | |
| 139 | |
jmac | dbbe937 | 2018-07-30 20:18:44 +0000 | [diff] [blame] | 140 | exec ${ODL_HOME}/bin/karaf server |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 141 | |