5 # ============LICENSE_START=======================================================
7 # ================================================================================
8 # Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
9 # Modifications Copyright © 2018 Amdocs,Bell Canada
10 # ================================================================================
11 # Licensed under the Apache License, Version 2.0 (the "License");
12 # you may not use this file except in compliance with the License.
13 # You may obtain a copy of the License at
15 # http://www.apache.org/licenses/LICENSE-2.0
17 # Unless required by applicable law or agreed to in writing, software
18 # distributed under the License is distributed on an "AS IS" BASIS,
19 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 # See the License for the specific language governing permissions and
21 # limitations under the License.
22 # ============LICENSE_END=========================================================
23 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
27 # This script takes care of installing the SDNC & APPC platform components
28 # if not already installed, and starts the APPC Docker Container
33 function enable_odl_cluster(){
34 if [ -z $APPC_REPLICAS ]; then
35 echo "APPC_REPLICAS is not configured in Env field"
39 echo "Update cluster information statically"
41 echo "Get current Hostname ${hm}"
43 node=($(echo ${hm} | sed 's/-[0-9]*$//g'))
44 node_index=($(echo ${hm} | awk -F"-" '{print $NF}'))
45 node_list="${node}-0.{{ .Values.service.name }}-cluster.{{.Release.Namespace}}";
47 for ((i=1;i<${APPC_REPLICAS};i++));
49 node_list="${node_list} ${node}-$i.{{ .Values.service.name }}-cluster.{{.Release.Namespace}}"
52 /opt/opendaylight/current/bin/configure_cluster.sh $((node_index+1)) ${node_list}
55 ODL_HOME=${ODL_HOME:-/opt/opendaylight/current}
56 SDNC_HOME=${SDNC_HOME:-/opt/onap/ccsdk}
57 APPC_HOME=${APPC_HOME:-/opt/onap/appc}
58 SLEEP_TIME=${SLEEP_TIME:-120}
59 MYSQL_PASSWD=${MYSQL_ROOT_PASSWORD}
60 ENABLE_ODL_CLUSTER=${ENABLE_ODL_CLUSTER:-false}
61 ENABLE_AAF=${ENABLE_AAF:-true}
62 DBINIT_DIR=${DBINIT_DIR:-/opt/opendaylight/current/daexim}
65 # Wait for database to init properly
67 echo "Waiting for mariadbgalera"
68 until mysql -h {{.Values.config.mariadbGaleraSVCName}}.{{.Release.Namespace}} -u root -p${MYSQL_PASSWD} mysql &> /dev/null
73 echo -e "\nmariadbgalera ready"
75 if [ ! -d ${DBINIT_DIR} ]
77 mkdir -p ${DBINIT_DIR}
80 if [ ! -f ${DBINIT_DIR}/.installed ]
82 sdnc_db_exists=$(mysql -h {{.Values.config.mariadbGaleraSVCName}}.{{.Release.Namespace}} -u root -p${MYSQL_PASSWD} mysql <<-END
83 show databases like 'sdnctl';
86 if [ "x${sdnc_db_exists}" == "x" ]
88 echo "Installing SDNC database"
89 ${SDNC_HOME}/bin/installSdncDb.sh
91 appc_db_exists=$(mysql -h {{.Values.config.mariadbGaleraSVCName}}.{{.Release.Namespace}} -u root -p${MYSQL_PASSWD} mysql <<-END
92 show databases like 'appcctl';
95 if [ "x${appc_db_exists}" == "x" ]
97 echo "Installing APPC database"
98 ${APPC_HOME}/bin/installAppcDb.sh
104 echo "Installed at `date`" > ${DBINIT_DIR}/.installed
108 if [ ! -f ${SDNC_HOME}/.installed ]
110 echo "Installing ODL Host Key"
111 ${SDNC_HOME}/bin/installOdlHostKey.sh
113 # echo "Copying a working version of the logging configuration into the opendaylight etc folder"
114 # cp ${APPC_HOME}/data/org.ops4j.pax.logging.cfg ${ODL_HOME}/etc/org.ops4j.pax.logging.cfg
117 echo "Waiting ${SLEEP_TIME} seconds for OpenDaylight to initialize"
121 if [ -x ${SDNC_HOME}/svclogic/bin/install.sh ]
123 echo "Installing directed graphs"
124 ${SDNC_HOME}/svclogic/bin/install.sh
127 if [ -x ${APPC_HOME}/svclogic/bin/install-converted-dgs.sh ]
129 echo "Installing APPC JSON DGs converted to XML using dg-loader"
130 ${APPC_HOME}/svclogic/bin/install-converted-dgs.sh
133 if $ENABLE_ODL_CLUSTER
135 echo "Enabling Opendaylight cluster features"
139 echo "Copying the aaa shiro configuration into opendaylight"
140 mkdir -p ${ODL_HOME}/etc/opendaylight/datastore/initial/config
143 cp ${APPC_HOME}/data/properties/aaa-app-config.xml ${ODL_HOME}/etc/opendaylight/datastore/initial/config/aaa-app-config.xml
148 # Move journal and snapshots directory to persistent storage
150 hostdir=${ODL_HOME}/daexim/$(hostname -s)
154 if [ -d ${ODL_HOME}/journal ]
156 mv ${ODL_HOME}/journal ${hostdir}
158 mkdir ${hostdir}/journal
160 if [ -d ${ODL_HOME}/snapshots ]
162 mv ${ODL_HOME}/snapshots ${hostdir}
164 mkdir ${hostdir}/snapshots
168 ln -s ${hostdir}/journal ${ODL_HOME}/journal
169 ln -s ${hostdir}/snapshots ${ODL_HOME}/snapshots
171 echo "Starting cdt-proxy-service jar, logging to ${APPC_HOME}/cdt-proxy-service/jar.log"
172 java -jar ${APPC_HOME}/cdt-proxy-service/cdt-proxy-service.jar > ${APPC_HOME}/cdt-proxy-service/jar.log &
174 echo "Starting dmaap-event-service jar, logging to ${APPC_HOME}/dmaap-event-service/jar.log"
175 java -jar -Dorg_onap_appc_bootstrap_path=/opt/onap/appc/data/properties -Dorg_onap_appc_bootstrap_file=appc.properties ${APPC_HOME}/dmaap-event-service/dmaap-event-service.jar > ${APPC_HOME}/dmaap-event-service/jar.log &
177 echo "Adding a property system.properties for AAF cadi.properties location"
178 echo "" >> ${ODL_HOME}/etc/system.properties
179 echo "cadi_prop_files=${APPC_HOME}/data/properties/cadi.properties" >> ${ODL_HOME}/etc/system.properties
180 echo "" >> ${ODL_HOME}/etc/system.properties
182 echo "Adding a value to property appc.asdc.env in appc.properties for appc-asdc-listener feature"
183 echo "" >> $APPC_HOME/data/properties/appc.properties
184 echo "appc.asdc.env=$DMAAP_TOPIC_ENV" >> $APPC_HOME/data/properties/appc.properties
185 echo "" >> $APPC_HOME/data/properties/appc.properties
187 echo "Copying jetty, keystore for https into opendalight"
188 cp ${APPC_HOME}/data/jetty.xml ${ODL_HOME}/etc/jetty.xml
189 cp ${APPC_HOME}/data/keystore ${ODL_HOME}/etc/keystore
190 cp ${APPC_HOME}/data/custom.properties ${ODL_HOME}/etc/custom.properties
192 echo "Copying a working version of the logging configuration into the opendaylight etc folder"
193 cp ${APPC_HOME}/data/org.ops4j.pax.logging.cfg ${ODL_HOME}/etc/org.ops4j.pax.logging.cfg
195 ODL_BOOT_FEATURES_EXTRA="odl-netconf-connector,odl-restconf-noauth,odl-netconf-clustered-topology,odl-mdsal-clustering"
196 sed -i -e "\|featuresBoot[^a-zA-Z]|s|$|,${ODL_BOOT_FEATURES_EXTRA}|" $ODL_HOME/etc/org.apache.karaf.features.cfg
198 exec ${APPC_HOME}/bin/dockerInstall.sh &
199 echo "Starting OpenDaylight"
200 exec ${ODL_HOME}/bin/karaf server