3 # ============LICENSE_START=======================================================
5 # ================================================================================
6 # Copyright (C) 2020 Samsung Electronics
7 # Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
8 # Copyright (C) 2020 Highstreet Technologies
9 # ================================================================================
10 # Licensed under the Apache License, Version 2.0 (the "License");
11 # you may not use this file except in compliance with the License.
12 # You may obtain a copy of the License at
14 # http://www.apache.org/licenses/LICENSE-2.0
16 # Unless required by applicable law or agreed to in writing, software
17 # distributed under the License is distributed on an "AS IS" BASIS,
18 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 # See the License for the specific language governing permissions and
20 # limitations under the License.
21 # ============LICENSE_END=========================================================
23 # A single entry point script that can be used in Kubernetes based deployments (via OOM) and standalone docker deployments.
24 # Please see https://wiki.onap.org/display/DW/startODL.sh+-+Important+Environment+variables+and+their+description for more details
28 # Test if repository exists, like this mvn:org.onap.ccsdk.features.sdnr.wt/sdnr-wt-devicemanager-oran-feature/0.7.2/xml/features
31 REPO=$(echo "$1" | sed -E "s#mvn:(.*)/xml/features\$#\1#")
36 path="$ODL_HOME/system/$(echo "$2" | tr '.' '/')/$3/$4"
40 # Add features repository to karaf featuresRepositories configuration
41 # $1 repositories to be added
43 CFG=$ODL_FEATURES_BOOT_FILE
45 if isRepoExisting "$1" ; then
46 printf "%s\n" "Add repository: $1"
47 sed -i "\|featuresRepositories|s|$|, $1|" "$CFG"
49 printf "%s\n" "Repo does not exist: $1"
53 # Append features to karaf boot feature configuration
54 # $1 additional feature to be added
55 # $2 repositories to be added (optional)
57 CFG=$ODL_FEATURES_BOOT_FILE
60 printf "%s\n" "Add repository: $2"
62 sed -e "\|featuresRepositories|s|$|,$2|" "$ORIG" > "$CFG"
64 printf "%s\n" "Add boot feature: $1"
66 sed -e "\|featuresBoot *=|s|$|,$1|" "$ORIG" > "$CFG"
69 # Append features to karaf boot feature configuration
72 replaceFeatureBoot() {
73 CFG="$ODL_HOME"/etc/org.apache.karaf.features.cfg
75 printf "%s %s\n" "Replace boot feature $1 with: $2"
76 sed -i "/featuresBoot/ s/$1/$2/g" "$CFG"
79 # Remove all sdnc specific features
80 cleanupFeatureBoot() {
81 printf "Remove northbound bootfeatures \n"
82 sed -i "/featuresBoot/ s/,ccsdk-sli-core-all.*$//g" "$ODL_FEATURES_BOOT_FILE"
86 printf "SDN-R Database Initialization"
87 INITCMD="$JAVA_HOME/bin/java -jar "
88 INITCMD="${INITCMD} $ODL_HOME/system/org/onap/ccsdk/features/sdnr/wt/sdnr-wt-data-provider-setup/$CCSDKFEATUREVERSION/sdnr-dmt.jar "
89 INITCMD="${INITCMD} $SDNRDBCOMMAND"
90 printf "%s\n" "Execute: $INITCMD"
92 until [ $n -ge 5 ] ; do
100 install_sdnrwt_features() {
101 # Repository setup provided via sdnc dockerfile
103 addRepository "$SDNRDM_BASE_REPO"
104 addRepository "$SDNRDM_ONF_REPO"
110 addToFeatureBoot "$SDNRDM_BOOTFEATURES"
112 addToFeatureBoot "$SDNRWT_BOOTFEATURES"
117 install_sdnr_northbound_features() {
118 addToFeatureBoot "$SDNR_NORTHBOUND_BOOTFEATURES"
121 # Reconfigure ODL from default single node configuration to cluster
123 enable_odl_cluster() {
124 if [ -z "$SDNC_REPLICAS" ]; then
125 printf "SDNC_REPLICAS is not configured in Env field"
130 printf "Installing Opendaylight cluster features for mdsal and netconf\n"
132 #Be sure to remove feature odl-netconf-connector-all from list
133 replaceFeatureBoot "odl-netconf-connector-all,"
135 printf "Installing Opendaylight cluster features\n"
136 replaceFeatureBoot odl-netconf-topology odl-netconf-clustered-topology
137 replaceFeatureBoot odl-mdsal-all odl-mdsal-all,odl-mdsal-clustering
138 addToFeatureBoot odl-jolokia
139 #${ODL_HOME}/bin/client feature:install odl-mdsal-clustering
140 #${ODL_HOME}/bin/client feature:install odl-jolokia
142 # ODL Cluster or Geo cluster configuration
144 printf "Update cluster information statically\n"
146 printf "%s\n" "Get current fqdn ${fqdn}"
148 # Extract node index using first digit after "-"
149 # Example 2 from "sdnr-2.logo.ost.das.r32.com"
150 node_index=$(echo "${fqdn}" | sed -r 's/.*-([0-9]).*/\1/g')
153 if $GEO_ENABLED; then
154 printf "This is a Geo cluster\n"
156 if [ -z "$IS_PRIMARY_CLUSTER" ] || [ -z "$MY_ODL_CLUSTER" ] || [ -z "$PEER_ODL_CLUSTER" ]; then
157 printf "IS_PRIMARY_CLUSTER, MY_ODL_CLUSTER and PEER_ODL_CLUSTER must all be configured in Env field\n"
161 if $IS_PRIMARY_CLUSTER; then
162 PRIMARY_NODE=${MY_ODL_CLUSTER}
163 SECONDARY_NODE=${PEER_ODL_CLUSTER}
165 PRIMARY_NODE=${PEER_ODL_CLUSTER}
166 SECONDARY_NODE=${MY_ODL_CLUSTER}
170 node_list="${PRIMARY_NODE} ${SECONDARY_NODE}"
172 "${SDNC_BIN}"/configure_geo_cluster.sh $((node_index+member_offset)) "${node_list}"
174 printf "This is a local cluster\n"
177 if $OOM_ENABLED; then
178 # Extract node name minus the index
179 # Example sdnr from "sdnr-2.logo.ost.das.r32.com"
180 node_name=$(echo "${fqdn}" | sed 's/-[0-9].*$//g')
181 while [ $i -lt "$SDNC_REPLICAS" ]; do
182 node_list="${node_list} ${node_name}-$i.${SERVICE_NAME}-cluster.${NAMESPACE}"
185 "${ODL_HOME}"/bin/configure_cluster.sh $((node_index+1)) "${node_list}"
187 while [ $i -lt "$SDNC_REPLICAS" ]; do
188 #assemble node list by replacing node-index in hostname with "i"
189 node_name=$(echo "${fqdn}" | sed -r "s/-[0-9]/-$i/g")
190 node_list="${node_list} ${node_name}"
193 "${ODL_HOME}"/bin/configure_cluster.sh $((node_index+1)) "${node_list}"
199 # Install SDN-C platform components if not already installed and start container
201 # -----------------------
202 # Main script starts here
203 printf "Installing SDNC/R from startODL.sh script\n"
204 ODL_HOME=${ODL_HOME:-/opt/opendaylight/current}
205 ODL_FEATURES_BOOT_FILE=$ODL_HOME/etc/org.apache.karaf.features.cfg
207 ODL_REMOVEIDMDB=${ODL_REMOVEIDMDB:-false}
209 ODL_ADMIN_USERNAME=${ODL_ADMIN_USERNAME:-admin}
210 if $ODL_REMOVEIDMDB ; then
211 printf "Remove odl idmdb"
212 rm "$ODL_HOME"/data/idmlight.db.mv.db
213 ODL_ADMIN_PASSWORD=${ODL_ADMIN_PASSWORD:-admin}
215 ODL_ADMIN_PASSWORD=${ODL_ADMIN_PASSWORD:-Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U}
217 ODL_ADMIN_PASSWORD=${ODL_ADMIN_PASSWORD:-Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U}
218 SDNC_HOME=${SDNC_HOME:-/opt/onap/sdnc}
219 SDNC_BIN=${SDNC_BIN:-/opt/onap/sdnc/bin}
220 SDNC_DB_INIT=${SDNC_DB_INIT:-false}
221 CCSDK_HOME=${CCSDK_HOME:-/opt/onap/ccsdk}
222 JDEBUG=${JDEBUG:-false}
223 MYSQL_PASSWD=${MYSQL_PASSWD:-openECOMP1.0}
224 ENABLE_ODL_CLUSTER=${ENABLE_ODL_CLUSTER:-false}
225 GEO_ENABLED=${GEO_ENABLED:-false}
226 SDNC_AAF_ENABLED=${SDNC_AAF_ENABLED:-false}
227 OOM_ENABLED=${OOM_ENABLED:-false}
228 IS_PRIMARY_CLUSTER=${IS_PRIMARY_CLUSTER:-false}
229 MY_ODL_CLUSTER=${MY_ODL_CLUSTER:-127.0.0.1}
230 INSTALLED_DIR=${INSTALLED_FILE:-/opt/opendaylight/current/daexim}
231 SDNRWT=${SDNRWT:-false}
232 SDNRWT_BOOTFEATURES=${SDNRWT_BOOTFEATURES:-sdnr-wt-feature-aggregator}
233 SDNRDM=${SDNRDM:-false}
234 # Add devicemanager base and specific repositories
235 SDNRDM_BASE_REPO=${SDNRDM_BASE_REPO:-mvn:org.onap.ccsdk.features.sdnr.wt/sdnr-wt-feature-aggregator-devicemanager-base/$CCSDKFEATUREVERSION/xml/features}
236 SDNRDM_ONF_REPO=${SDNRDM_ONF_REPO:-mvn:org.onap.ccsdk.features.sdnr.wt/sdnr-wt-devicemanager-onf-feature/$CCSDKFEATUREVERSION/xml/features}
237 # Add devicemanager features
238 SDNRDM_SDM_LIST=${SDNRDM_SDM_LIST:-sdnr-wt-devicemanager-onf-feature}
239 SDNRDM_BOOTFEATURES=${SDNRDM_BOOTFEATURES:-sdnr-wt-feature-aggregator-devicemanager-base, ${SDNRDM_SDM_LIST}}
240 SDNRINIT=${SDNRINIT:-false}
241 SDNRONLY=${SDNRONLY:-false}
242 SDNRDBURL=${SDNRDBURL:-http://sdnrdb:9200}
243 SDNRDBCOMMAND=${SDNRDBCOMMAND:--c init -db $SDNRDBURL -dbu $SDNRDBUSERNAME -dbp $SDNRDBPASSWORD $SDNRDBPARAMETER}
245 SDNR_NORTHBOUND=${SDNR_NORTHBOUND:-false}
246 SDNR_NORTHBOUND_BOOTFEATURES=${SDNR_NORTHBOUND_BOOTFEATURES:-sdnr-northbound-all}
247 export ODL_ADMIN_PASSWORD ODL_ADMIN_USERNAME
250 printf "Activate remote debugging\n"
251 #JSTADTPOLICYFILE="$ODL_HOME/etc/tools.policy"
252 #echo -e "grant codebase \"file:${JAVA_HOME}/lib/tools.jar\" {\n permission java.security.AllPermission;\n };" > $JSTADTPOLICYFILE
254 #$JAVA_HOME/bin/jstatd -p 1089 -J-Djava.security.policy=$JSTADTPOLICYFILE &
255 EXTRA_JAVA_OPTS="${EXTRA_JAVA_OPTS} -Dcom.sun.management.jmxremote.port=1090"
256 EXTRA_JAVA_OPTS="${EXTRA_JAVA_OPTS} -Dcom.sun.management.jmxremote.rmi.port=1090"
257 EXTRA_JAVA_OPTS="${EXTRA_JAVA_OPTS} -Djava.rmi.server.hostname=$(hostname) "
258 EXTRA_JAVA_OPTS="${EXTRA_JAVA_OPTS} -Dcom.sun.management.jmxremote.local.only=false"
259 EXTRA_JAVA_OPTS="${EXTRA_JAVA_OPTS} -Dcom.sun.management.jmxremote.ssl=false"
260 EXTRA_JAVA_OPTS="${EXTRA_JAVA_OPTS} -Dcom.sun.management.jmxremote.authenticate=false"
261 export EXTRA_JAVA_OPTS
266 printf "%s\n" " SDNC_BIN=$SDNC_BIN"
267 printf "%s\n" " SDNC_HOME=$SDNC_HOME"
268 printf "%s\n" " SDNC_DB_INIT=$SDNC_DB_INIT"
269 printf "%s\n" " ODL_CERT_DIR=$ODL_CERT_DIR"
270 printf "%s\n" " CCSDKFEATUREVERSION=$CCSDKFEATUREVERSION"
271 printf "%s\n" " ENABLE_ODL_CLUSTER=$ENABLE_ODL_CLUSTER"
272 printf "%s\n" " ODL_REMOVEIDMDB=$ODL_REMOVEIDMDB"
273 printf "%s\n" " SDNC_REPLICAS=$SDNC_REPLICAS"
274 printf "%s\n" " SDNRWT=$SDNRWT"
275 printf "%s\n" " SDNRDM=$SDNRDM"
276 printf "%s\n" " SDNRONLY=$SDNRONLY"
277 printf "%s\n" " SDNRINIT=$SDNRINIT"
278 printf "%s\n" " SDNRDBURL=$SDNRDBURL"
279 printf "%s\n" " SDNRDBUSERNAME=$SDNRDBUSERNAME"
280 printf "%s\n" " GEO_ENABLED=$GEO_ENABLED"
281 printf "%s\n" " IS_PRIMARY_CLUSTER=$IS_PRIMARY_CLUSTER"
282 printf "%s\n" " MY_ODL_CLUSTER=$MY_ODL_CLUSTER"
283 printf "%s\n" " PEER_ODL_CLUSTER=$PEER_ODL_CLUSTER"
284 printf "%s\n" " SDNR_NORTHBOUND=$SDNR_NORTHBOUND"
285 printf "%s\n" " AAF_ENABLED=$SDNC_AAF_ENABLED"
287 if "$SDNC_AAF_ENABLED"; then
288 export SDNC_AAF_STORE_DIR=/opt/app/osaaf/local
289 export SDNC_AAF_CONFIG_DIR=/opt/app/osaaf/local
290 export SDNC_KEYPASS=$(cat /opt/app/osaaf/local/.pass)
291 export SDNC_KEYSTORE=org.onap.sdnc.p12
292 sed -i '/cadi_prop_files/d' "$ODL_HOME"/etc/system.properties
293 echo "cadi_prop_files=$SDNC_AAF_CONFIG_DIR/org.onap.sdnc.props" >> "$ODL_HOME"/etc/system.properties
295 sed -i '/org.ops4j.pax.web.ssl.keystore/d' "$ODL_HOME"/etc/custom.properties
296 sed -i '/org.ops4j.pax.web.ssl.password/d' "$ODL_HOME"/etc/custom.properties
297 sed -i '/org.ops4j.pax.web.ssl.keypassword/d' "$ODL_HOME"/etc/custom.properties
298 echo "org.ops4j.pax.web.ssl.keystore=$SDNC_AAF_STORE_DIR/$SDNC_KEYSTORE" >> "$ODL_HOME"/etc/custom.properties
299 echo "org.ops4j.pax.web.ssl.password=$SDNC_KEYPASS" >> "$ODL_HOME"/etc/custom.properties
300 echo "org.ops4j.pax.web.ssl.keypassword=$SDNC_KEYPASS" >> "$ODL_HOME"/etc/custom.properties
304 #One time intialization action
307 printf "%s\n" "Result of init script: $init_result"
309 printf "Proceed to initialize sdnr\n"
315 if $OOM_ENABLED; then
319 printf "Waiting for mysql"
320 until mysql -h dbhost -u root -p"${MYSQL_PASSWD}" mysql > /dev/null 2>&1
325 printf "\nmysql ready"
328 if [ ! -d "${INSTALLED_DIR}" ]
330 mkdir -p "${INSTALLED_DIR}"
333 if [ ! -f "${SDNC_HOME}"/.installed ]
335 if $OOM_ENABLED; then
336 # for integration testing. In OOM, a separate job takes care of installing it.
337 if $SDNC_DB_INIT; then
338 printf "Installing SDN-C database\n"
339 "${SDNC_HOME}"/bin/installSdncDb.sh
341 printf "Installing SDN-C keyStore\n"
342 "${SDNC_HOME}"/bin/addSdncKeyStore.sh
343 printf "Installing A1-adapter trustStore\n"
344 "${SDNC_HOME}"/bin/addA1TrustStore.sh
346 #${CCSDK_HOME}/bin/installOdlHostKey.sh
348 if [ -x "${SDNC_HOME}"/svclogic/bin/install.sh ]
350 printf "Installing directed graphs\n"
351 "${SDNC_HOME}"/svclogic/bin/install.sh
355 if $SDNRWT ; then install_sdnrwt_features ; fi
356 # The enable_odl_cluster call should not be moved above this line as the cleanFeatureBoot will overwrite entries. Ex: odl-jolokia
357 if $ENABLE_ODL_CLUSTER ; then enable_odl_cluster ; fi
359 if $SDNR_NORTHBOUND ; then install_sdnr_northbound_features ; fi
360 printf "%s" "Installed at $(date)" > "${SDNC_HOME}"/.installed
363 #cp /opt/opendaylight/current/certs/* /tmp
364 #cp /var/custom-certs/* /tmp
366 if [ -n "$OVERRIDE_FEATURES_BOOT" ] ; then
367 printf "%s\n" "Override features boot: $OVERRIDE_FEATURES_BOOT"
368 sed -i "/$FEATURESBOOTMARKER/c\featuresBoot = $OVERRIDE_FEATURES_BOOT" "$ODL_FEATURES_BOOT_FILE"
371 # Odl configuration done
372 ODL_REPOSITORIES_BOOT=$(sed -n "/$REPOSITORIESBOOTMARKER/p" "$ODL_FEATURES_BOOT_FILE")
373 ODL_FEATURES_BOOT=$(sed -n "/$FEATURESBOOTMARKER/p" "$ODL_FEATURES_BOOT_FILE")
374 export ODL_FEATURES_BOOT
376 # Create ODL data log directory (it nornally is created after karaf
377 # is started, but needs to exist before installCerts.py runs)
378 if [ -z "$ODL_CERT_DIR" ] ; then
379 printf "No certs provided. Skip installation.\n"
381 printf "Start background cert installer\n"
382 mkdir -p /opt/opendaylight/data/log
383 nohup python3 "${SDNC_BIN}"/installCerts.py &
386 printf "Startup opendaylight\n"
387 printf "%s\n" "$ODL_REPOSITORIES_BOOT"
388 printf "%s\n" "$ODL_FEATURES_BOOT"
389 exec "${ODL_HOME}"/bin/karaf server