From 5e5cc2b2ace3a5fe4b1b2394bfa5a32f4664e52b Mon Sep 17 00:00:00 2001 From: herbert Date: Tue, 18 Feb 2020 17:53:52 +0100 Subject: Fix onap-odl-neon image Add missing configuration scripts Issue-ID: SDNC-1056 Signed-off-by: herbert Change-Id: Id76f855e819baef4eef8f0770c398c86da8c76fc --- opendaylight/neon/neon-alpine/pom.xml | 7 + .../neon/neon-alpine/src/main/docker/Dockerfile | 3 + .../main/odlscripts/configure-cluster-ipdetect.sh | 265 +++++++++++++++++++++ .../src/main/odlscripts/configure_cluster.sh | 228 ++++++++++++++++++ .../src/main/odlscripts/custom_shard_config.txt | 17 ++ .../src/main/odlscripts/set_persistence.sh | 111 +++++++++ 6 files changed, 631 insertions(+) create mode 100755 opendaylight/neon/neon-alpine/src/main/odlscripts/configure-cluster-ipdetect.sh create mode 100755 opendaylight/neon/neon-alpine/src/main/odlscripts/configure_cluster.sh create mode 100755 opendaylight/neon/neon-alpine/src/main/odlscripts/custom_shard_config.txt create mode 100755 opendaylight/neon/neon-alpine/src/main/odlscripts/set_persistence.sh (limited to 'opendaylight/neon/neon-alpine') diff --git a/opendaylight/neon/neon-alpine/pom.xml b/opendaylight/neon/neon-alpine/pom.xml index 072e884e..dc1e8b96 100644 --- a/opendaylight/neon/neon-alpine/pom.xml +++ b/opendaylight/neon/neon-alpine/pom.xml @@ -95,6 +95,13 @@ true + + src/main/odlscripts + + * + + true + diff --git a/opendaylight/neon/neon-alpine/src/main/docker/Dockerfile b/opendaylight/neon/neon-alpine/src/main/docker/Dockerfile index 054a44f7..bd6ff4ae 100644 --- a/opendaylight/neon/neon-alpine/src/main/docker/Dockerfile +++ b/opendaylight/neon/neon-alpine/src/main/docker/Dockerfile @@ -15,6 +15,9 @@ RUN mkdir -p /opt/odl \ && ln -s /opt/opendaylight /opt/opendaylight/${odl.karaf.artifactId}-${ccsdk.opendaylight.version} \ && ln -s /opt/opendaylight /opt/opendaylight/current +# Add missing scripts see SDNC-1056 +COPY configure_cluster.sh configure-cluster-ipdetect.sh custom_shard_config.txt set_persistence.sh $ODL_HOME/bin/ +RUN chmod 755 $ODL_HOME/bin/configure_cluster.sh $ODL_HOME/bin/configure-cluster-ipdetect.sh $ODL_HOME/bin/set_persistence.sh $ODL_HOME/bin/custom_shard_config.txt # ENTRYPOINT exec /opt/opendaylight/bin/karaf EXPOSE 8181 diff --git a/opendaylight/neon/neon-alpine/src/main/odlscripts/configure-cluster-ipdetect.sh b/opendaylight/neon/neon-alpine/src/main/odlscripts/configure-cluster-ipdetect.sh new file mode 100755 index 00000000..7b97ef96 --- /dev/null +++ b/opendaylight/neon/neon-alpine/src/main/odlscripts/configure-cluster-ipdetect.sh @@ -0,0 +1,265 @@ +#!/bin/bash +# +# Copyright (c) 2015 Brocade Communications Systems, Inc. and others. All rights reserved. +# Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. +# +# This program and the accompanying materials are made available under the +# terms of the Eclipse Public License v1.0 which accompanies this distribution, +# and is available at http://www.eclipse.org/legal/epl-v10.html +# + + +function usage() +{ + # Print any error messages + test "$1" != "" && echo " ERROR: $1" + + # Print standard usage help + cat << EOF + This script is used to configure cluster parameters on this + controller. The user should restart controller to apply changes. + + Usage: $0 + - seed_nodes_list: List of seed nodes, separated by comma or space. + + The script checks that one (any) of the the controller's active IP + addresses is present in the seed_nodes_list. When running this script + on multiple seed nodes, keep the seed_node_list same on all nodes. + + Optionally, shards can be configured in a more granular way by + modifying the file "custom_shard_configs.txt" in the same folder + as this tool. Please see that file for more details. + +This script is currently limited to IPv4 addresses. If you have +problems running this script, please use 'configure_cluster.sh'. + +EOF + + exit 1 +} + + +function start_banner +{ +cat < ${MODULESHARDSCONF} + modules_builder > ${MODULESCONF} + cat ${MODULESCONF} + fi + + echo "Configuring replication type in module-shards.conf" + sed -i -e "/^[^#].*replicas[ ]*=/ { :loop /.*\]/ b done; N; b loop; :done s/replicas.*\]/replicas = [${MEMBER_NAME_LIST}]/}" ${MODULESHARDSCONF} +} + + +function verify_configuration_files +{ + # Constants + BIN_DIR=`dirname $0` + test ${BIN_DIR} == '.' && BIN_DIR=${PWD} + CONTROLLER_DIR=`dirname ${BIN_DIR}` + CONF_DIR=${CONTROLLER_DIR}/configuration/initial + AKKACONF=${CONF_DIR}/akka.conf + MODULESCONF=${CONF_DIR}/modules.conf + MODULESHARDSCONF=${CONF_DIR}/module-shards.conf + + # Verify configuration files are present in expected location. + if [ ! -f ${AKKACONF} -o ! -f ${MODULESHARDSCONF} ]; then + # Check if the configuration files exist in the system + # directory, then copy them over. + ORIG_CONF_DIR=${CONTROLLER_DIR}/system/org/opendaylight/controller/sal-clustering-config + version=$(sed -n -e 's/.*\(.*\)<\/version>/\1/p' ${ORIG_CONF_DIR}/maven-metadata-local.xml) + ORIG_CONF_DIR=${ORIG_CONF_DIR}/${version} + ORIG_AKKA_CONF=sal-clustering-config-${version}-akkaconf.xml + ORIG_MODULES_CONF=sal-clustering-config-${version}-moduleconf.xml + ORIG_MODULESHARDS_CONF=sal-clustering-config-${version}-moduleshardconf.xml + + if [ -f ${ORIG_CONF_DIR}/${ORIG_AKKA_CONF} -a \ + -f ${ORIG_CONF_DIR}/${ORIG_MODULES_CONF} -a \ + -f ${ORIG_CONF_DIR}/${ORIG_MODULESHARDS_CONF} ]; then + cat < + - index: Integer within 1..N, where N is the number of seed nodes. + - seed_nodes_list: List of seed nodes, separated by comma or space. + + The address at the provided index should belong this controller. + When running this script on multiple seed nodes, keep the + seed_node_list same, and vary the index from 1 through N. + + Optionally, shards can be configured in a more granular way by + modifying the file "custom_shard_configs.txt" in the same folder + as this tool. Please see that file for more details + +EOF + + exit 1 +} + + +function start_banner +{ +cat < ${MODULESHARDSCONF} + modules_builder > ${MODULESCONF} + cat ${MODULESCONF} + fi + + echo "Configuring replication type in module-shards.conf" + sed -i -e "/^[^#].*replicas[ ]*=/ { :loop /.*\]/ b done; N; b loop; :done s/replicas.*\]/replicas = [${MEMBER_NAME_LIST}]/}" ${MODULESHARDSCONF} +} + + +function verify_configuration_files +{ + # Constants + BIN_DIR=`dirname $0` + test ${BIN_DIR} == '.' && BIN_DIR=${PWD} + CONTROLLER_DIR=`dirname ${BIN_DIR}` + CONF_DIR=${CONTROLLER_DIR}/configuration/initial + AKKACONF=${CONF_DIR}/akka.conf + MODULESCONF=${CONF_DIR}/modules.conf + MODULESHARDSCONF=${CONF_DIR}/module-shards.conf + + # Verify configuration files are present in expected location. + if [ ! -f ${AKKACONF} -o ! -f ${MODULESHARDSCONF} ]; then + # Check if the configuration files exist in the system + # directory, then copy them over. + ORIG_CONF_DIR=${CONTROLLER_DIR}/system/org/opendaylight/controller/sal-clustering-config + version=$(sed -n -e 's/.*\(.*\)<\/version>/\1/p' ${ORIG_CONF_DIR}/maven-metadata-local.xml) + ORIG_CONF_DIR=${ORIG_CONF_DIR}/${version} + ORIG_AKKA_CONF=sal-clustering-config-${version}-akkaconf.xml + ORIG_MODULES_CONF=sal-clustering-config-${version}-moduleconf.xml + ORIG_MODULESHARDS_CONF=sal-clustering-config-${version}-moduleshardconf.xml + + if [ -f ${ORIG_CONF_DIR}/${ORIG_AKKA_CONF} -a \ + -f ${ORIG_CONF_DIR}/${ORIG_MODULES_CONF} -a \ + -f ${ORIG_CONF_DIR}/${ORIG_MODULESHARDS_CONF} ]; then + cat < + +EOF + + exit 1 +} + + +function end_banner +{ +cat <\(.*\)<\/version>/\1/p' ${ORIG_CONF_DIR}/maven-metadata-local.xml) + ORIG_CONF_DIR=${ORIG_CONF_DIR}/${version} + ORIG_CLUSTER_CONF=sal-clustering-config-${version}-datastore.cfg + + if [ -f ${ORIG_CONF_DIR}/${ORIG_CLUSTER_CONF} ]; then + cat <