summaryrefslogtreecommitdiffstats
path: root/bootstrap
diff options
context:
space:
mode:
Diffstat (limited to 'bootstrap')
-rwxr-xr-xbootstrap/bootstrap273
-rw-r--r--bootstrap/bootstrap-common-functions356
-rw-r--r--bootstrap/bootstrap-config-file71
-rw-r--r--bootstrap/bootstrap-deb-functions250
-rw-r--r--bootstrap/bootstrap-src-functions518
5 files changed, 1468 insertions, 0 deletions
diff --git a/bootstrap/bootstrap b/bootstrap/bootstrap
new file mode 100755
index 0000000..dcc762f
--- /dev/null
+++ b/bootstrap/bootstrap
@@ -0,0 +1,273 @@
+#!/bin/sh
+#
+# This script allows you to install openbaton. To execute it:
+#
+# sh <(curl -s http://get.openbaton.org/bootstrap) [help | clean | enable-persistence] | [[release | develop] [--openbaton-bootstrap-version=X.Y.Z (with X.Y.Z >= 3.2.0)] [--config-file=<absolute path to configuration file>]]
+
+
+
+##########################
+#### General Settings ####
+##########################
+
+set -u
+#set -x # only for DEBUG
+
+# Make available the functions defined in /lib/lsb/init-functions
+. /lib/lsb/init-functions
+
+
+##########################
+#### Global Variables ####
+##########################
+
+OPENBATON_BOOTSTRAP_VERSION_DEFAULT=""
+openbaton_bootstrap_version=${openbaton_bootstrap_version:-$OPENBATON_BOOTSTRAP_VERSION_DEFAULT}
+
+OPENBATON_BOOTSTRAP_ENV_FILE="/tmp/bootstrap_env"
+
+OPENBATON_BOOTSTRAP_FUNCTIONS_BASE_URL=http://get.openbaton.org/bootstraps/orchestra/euphrates/
+
+USER="$(id -un 2>/dev/null || true)"
+
+OS_ARCHITECTURE=$(uname -m)
+OS_TYPE=$(uname -a | awk -F' ' '{ print $1 }')
+
+case "${OS_TYPE}" in
+ 'Linux')
+ OS_DISTRIBUTION_ID=$( lsb_release -a 2>/dev/null | grep "Distributor ID" | sed "s/[ \t]*//g" | awk -F':' '{ print $2 }')
+ OS_DISTRIBUTION_RELEASE=$( lsb_release -a 2>/dev/null | grep "Release" | sed "s/[ \t]*//g" | awk -F':' '{ print $2 }' )
+ OS_DISTRIBUTION_CODENAME=$( lsb_release -a 2>/dev/null | grep "Codename" | sed "s/[ \t]*//g" | awk -F':' '{ print $2 }' )
+ ;;
+ 'Darwin')
+ OS_DISTRIBUTION_ID=$( sw_vers -productName )
+ OS_DISTRIBUTION_RELEASE=$( sw_vers -productVersion )
+ ;;
+ *)
+ OS_DISTRIBUTION_ID=undefined
+ OS_DISTRIBUTION_RELEASE=undefined
+ ;;
+esac
+
+if [ ${OS_DISTRIBUTION_RELEASE} != 'undefined' ]; then
+ OS_DISTRIBUTION_RELEASE_MAJOR=$( echo ${OS_DISTRIBUTION_RELEASE} | awk -F'.' '{ print $1 }' )
+else
+ OS_DISTRIBUTION_RELEASE_MAJOR=undefined
+fi
+
+OPENBATON_BOOTSTRAP_SUBCOMMAND_DEFAULT=release
+
+
+###############
+#### Usage ####
+###############
+
+usage () {
+ echo " * Usage: (The 'release' installation is the DEFAULT)"
+ echo " ./bootstrap [help | clean | enable-persistence] | [[release | develop] [--openbaton-bootstrap-version=X.Y.Z (with X.Y.Z >= 3.2.0)] [--config-file=<absolute path to configuration file>]] (if bootstrap already locally available)"
+ echo " sh <(curl -s http://get.openbaton.org/bootstrap) [help | clean | enable-persistence] | [[release | develop] [--openbaton-bootstrap-version=X.Y.Z (with X.Y.Z >= 3.2.0)] [--config-file=<absolute path to configuration file>]] (otherwise)"
+}
+
+
+##############################
+#### Execution privileges ####
+##############################
+
+check_binary () {
+ echo -n " * Checking for '${1}' ... "
+ if command -v ${1} >/dev/null 2>&1; then
+ echo "OK"
+ return 0
+ else
+ echo >&2 "FAILED"
+ return 1
+ fi
+}
+
+_ex='sh -c'
+if [ "${USER}" != "root" ]; then
+ if check_binary sudo; then
+ _ex='sudo -E sh -c'
+ elif check_binary su; then
+ _ex='su -c'
+ fi
+fi
+
+
+##############
+#### Main ####
+##############
+
+prereq () {
+ $_ex 'apt-get install -y wget'
+
+ wget -O bootstrap-common-functions "${OPENBATON_BOOTSTRAP_FUNCTIONS_BASE_URL}/${openbaton_bootstrap_version}/bootstrap-common-functions"
+ . ./bootstrap-common-functions
+}
+
+main_src () {
+ prereq
+
+ wget -O bootstrap-src-functions "${OPENBATON_BOOTSTRAP_FUNCTIONS_BASE_URL}/${openbaton_bootstrap_version}/bootstrap-src-functions"
+ . ./bootstrap-src-functions
+ src_bootstrap
+}
+
+main_deb () {
+ prereq
+
+ wget -O bootstrap-deb-functions "${OPENBATON_BOOTSTRAP_FUNCTIONS_BASE_URL}/${openbaton_bootstrap_version}/bootstrap-deb-functions"
+ . ./bootstrap-deb-functions
+ deb_bootstrap "${1}" "${2}" # ${1} = release/nightly ; ${2} = distribution codename
+}
+
+main () {
+ # In case of "noninteractive" FRONTEND the latest RELEASE package will be installed
+ if [ "${DEBIAN_FRONTEND}" != "Noninteractive" -a "${DEBIAN_FRONTEND}" != "noninteractive" ]; then
+ echo " * Welcome to the Open Baton menu installation."
+ echo " * Available installation types are the following:"
+ echo " 1. develop (SOURCE): it will be downloaded the source code for all the components which will be executed in screens"
+ echo " 2. release (DEBIAN): it will be installed the binary version of the latest released version"
+ echo " 3. nightly (DEBIAN): it will be installed the binary version of the latest nightly build"
+ read -p " * Select the Open Baton installation type you prefer [2]: " install_type
+ case ${install_type} in
+ 1 )
+ main_src
+ ;;
+ 3 )
+ main_deb nightly "${OS_DISTRIBUTION_CODENAME}"
+ ;;
+ * )
+ main_deb release "${OS_DISTRIBUTION_CODENAME}"
+ ;;
+ esac
+ else
+ # Non interactive debian release installation with the default values (when non interactive installation and no config file has been passed)
+ main_deb release "${OS_DISTRIBUTION_CODENAME}"
+ fi
+
+ log_success_msg "Open Baton installation complete"
+}
+
+
+#####################
+#### Entry Point ####
+#####################
+
+if [ -n "${1+1}" ]; then
+ if [ -f ${OPENBATON_BOOTSTRAP_ENV_FILE} ]; then
+ rm ${OPENBATON_BOOTSTRAP_ENV_FILE}
+ fi
+
+ for arg in $@ ; do
+ arg_id=$(echo $arg | cut -c1-2)
+ arg_key=${arg}
+ arg_value=
+
+ if [ ${arg_id} != "--" ]; then
+ case ${arg} in
+ "release" | "develop" | "clean" | "enable-persistence" )
+ bootstrap_subcommand=${arg}
+ ;;
+ * )
+ # TODO: temporary fix
+ #########################################################################################################################################
+ arg_key=$( echo ${arg} | cut -c2- | awk -F'=' '{ print $1}' )
+ if [ "${arg_key}" = "configFile" ]; then
+ log_failure_msg "The argument '-configFile' will be not supported anymore from the next version. Please use '--config-file' instead."
+ arg_value=$( echo ${arg} | cut -c2- | awk -F'=' '{ print $2}' )
+ if [ -f ${arg_value} ]; then
+ echo " * Installing Open Baton using the following configuration file:"
+ echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
+ cat ${arg_value}
+ echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
+ export DEBIAN_FRONTEND=noninteractive
+ set -a # Mark the variables set in the configuration file for export to the environment of subsequent commands
+ . ${arg_value}
+ else
+ log_failure_msg "Configuration file '${arg_value}' does not exist."
+ fi
+ continue
+ fi
+ #########################################################################################################################################
+
+ usage
+ exit 1
+ ;;
+ esac
+ else
+ arg_key=$( echo ${arg} | cut -c3- | awk -F'=' '{ print $1}' )
+ arg_value=$( echo ${arg} | cut -c3- | awk -F'=' '{ print $2}' )
+
+ if [ "${arg_key}" = "config-file" ]; then
+ if [ -f ${arg_value} ]; then
+ echo " * Installing Open Baton using the following configuration file:"
+ echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
+ cat ${arg_value}
+ echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
+ export DEBIAN_FRONTEND=noninteractive
+ set -a # Mark the variables set in the configuration file for export to the environment of subsequent commands
+ . ${arg_value}
+ else
+ log_failure_msg "Configuration file '${arg_value}' does not exist."
+ fi
+ else
+ arg_key=$(echo ${arg_key} | tr '-' '_')
+ echo "${arg_key}=${arg_value}" >> ${OPENBATON_BOOTSTRAP_ENV_FILE}
+ fi
+ fi
+ done
+
+ if [ -f ${OPENBATON_BOOTSTRAP_ENV_FILE} ]; then
+ set -a # Mark the arguments passed by command line for export to the environment of subsequent commands
+ . ${OPENBATON_BOOTSTRAP_ENV_FILE}
+ fi
+
+ echo " * System Details:"
+ echo " OS Architecture: ${OS_ARCHITECTURE}"
+ echo " OS Type: ${OS_TYPE}"
+ echo " OS Distribution ID: ${OS_DISTRIBUTION_ID}"
+ echo " OS Distribution Codename: ${OS_DISTRIBUTION_CODENAME}"
+ echo " OS Distribution Release: ${OS_DISTRIBUTION_RELEASE}"
+
+ bootstrap_subcommand=${bootstrap_subcommand:-$OPENBATON_BOOTSTRAP_SUBCOMMAND_DEFAULT}
+ case ${bootstrap_subcommand} in
+ "help")
+ usage
+ exit 1
+ ;;
+ "release" )
+ echo " * Installing the latest RELEASE package"
+ main_deb release "${OS_DISTRIBUTION_CODENAME}"
+ ;;
+ "develop" )
+ echo " * Installing the latest source code"
+ main_src
+ ;;
+ "clean" )
+ echo " * Cleaning the Open Baton installation"
+ prereq
+ clean
+ exit 0
+ ;;
+ "enable-persistence" )
+ prereq
+ install_mysql
+ exit 0
+ ;;
+ *)
+ usage
+ exit 1
+ ;;
+ esac
+else # When invoked with 0 arguments: 'sh <(curl -s http://get.openbaton.org/bootstrap)'
+ echo " * System Details:"
+ echo " OS Architecture: ${OS_ARCHITECTURE}"
+ echo " OS Type: ${OS_TYPE}"
+ echo " OS Distribution ID: ${OS_DISTRIBUTION_ID}"
+ echo " OS Distribution Codename: ${OS_DISTRIBUTION_CODENAME}"
+ echo " OS Distribution Release: ${OS_DISTRIBUTION_RELEASE}"
+
+ main
+fi
+
diff --git a/bootstrap/bootstrap-common-functions b/bootstrap/bootstrap-common-functions
new file mode 100644
index 0000000..cdd06fb
--- /dev/null
+++ b/bootstrap/bootstrap-common-functions
@@ -0,0 +1,356 @@
+#!/bin/sh
+
+##########################
+#### General Settings ####
+##########################
+
+set -u
+#set -x # only for DEBUG
+
+
+##########################
+#### Global Variables ####
+##########################
+
+DEBIAN_FRONTEND_DEFAULT=dialog
+DEBIAN_FRONTEND=${openbaton_installation_manner:-$DEBIAN_FRONTEND_DEFAULT}
+
+BOOTSTRAP_DIR=$(pwd)
+
+OPENBATON_NFVO_REPO_URL="https://github.com/openbaton/NFVO"
+OPENBATON_PLUGINS_VIMDRIVERS_OPENSTACK_4J_REPO_URL="https://github.com/openbaton/openstack4j-plugin"
+OPENBATON_VNFM_GENERIC_REPO_URL="https://github.com/openbaton/generic-vnfm"
+OPENBATON_FMS_REPO_URL="https://github.com/openbaton/fm-system"
+OPENBATON_ASE_REPO_URL="https://github.com/openbaton/autoscaling-engine"
+OPENBATON_NSE_REPO_URL="https://github.com/openbaton/network-slicing-engine"
+
+OPENJDK_7_LINUX_X86_64_SECURITYFILE="/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/security/java.security"
+OPENJDK_7_LINUX_I386_SECURITYFILE="/usr/lib/jvm/java-7-openjdk-i386/jre/lib/security/java.security"
+OPENJDK_8_LINUX_X86_64_SECURITYFILE="/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/security/java.security"
+OPENJDK_8_LINUX_I386_SECURITYFILE="/usr/lib/jvm/java-8-openjdk-i386/jre/lib/security/java.security"
+OPENJDK_7_OSX_SECURITYFILE="/Library/Java/JavaVirtualMachines/jdk1.7.*.jdk/Contents/Home/jre/lib/security/java.security"
+
+HTTPS_DEFAULT=no
+MYSQL_DEFAULT=yes
+OPENBATON_NFVO_MYSQL_USER_DEFAULT=admin
+OPENBATON_NFVO_MYSQL_USER_PASSWORD_DEFAULT=changeme
+MYSQL_ROOT_PASSWORD_DEFAULT=root
+
+OPENBATON_BASE_CONFIG_DIR="/etc/openbaton"
+OPENBATON_SOURCE_INSTALLATION_BASE_DIR=/opt/openbaton
+
+OPENBATON_PLUGIN_VIMDRIVER_OPENSTACK_DEFAULT=yes
+OPENBATON_VNFM_GENERIC_DEFAULT=yes
+OPENBATON_FMS_DEFAULT=no
+OPENBATON_ASE_DEFAULT=no
+OPENBATON_NSE_DEFAULT=no
+OPENBATON_CLI_DEFAULT=no
+openbaton_plugin_vimdriver_openstack=${openbaton_plugin_vimdriver_openstack:-$OPENBATON_PLUGIN_VIMDRIVER_OPENSTACK_DEFAULT}
+openbaton_vnfm_generic=${openbaton_vnfm_generic:-$OPENBATON_VNFM_GENERIC_DEFAULT}
+openbaton_fms=${openbaton_fms:-$OPENBATON_FMS_DEFAULT}
+openbaton_ase=${openbaton_ase:-$OPENBATON_ASE_DEFAULT}
+openbaton_nse=${openbaton_nse:-$OPENBATON_NSE_DEFAULT}
+openbaton_cli=${openbaton_cli:-$OPENBATON_CLI_DEFAULT}
+
+OPENBATON_NFVO_VERSION_DEFAULT="4.0.0"
+OPENBATON_PLUGIN_VIMDRIVER_OPENSTACK_VERSION_DEFAULT="4.0.1"
+OPENBATON_VNFM_GENERIC_VERSION_DEFAULT="4.0.0"
+OPENBATON_FMS_VERSION_DEFAULT="1.2.5"
+OPENBATON_ASE_VERSION_DEFAULT="1.2.3"
+OPENBATON_NSE_VERSION_DEFAULT="1.1.2"
+openbaton_nfvo_version=${openbaton_nfvo_version:-$OPENBATON_NFVO_VERSION_DEFAULT}
+openbaton_plugin_vimdriver_openstack_version=${openbaton_plugin_vimdriver_openstack_version:-$OPENBATON_PLUGIN_VIMDRIVER_OPENSTACK_VERSION_DEFAULT}
+openbaton_vnfm_generic_version=${openbaton_vnfm_generic_version:-$OPENBATON_VNFM_GENERIC_VERSION_DEFAULT}
+openbaton_fms_version=${openbaton_fms_version:-$OPENBATON_FMS_VERSION_DEFAULT}
+openbaton_ase_version=${openbaton_ase_version:-$OPENBATON_ASE_VERSION_DEFAULT}
+openbaton_nse_version=${openbaton_nse_version:-$OPENBATON_NSE_VERSION_DEFAULT}
+
+
+##################
+#### Security ####
+##################
+
+enable_https () {
+ export properties_file_name=${1}
+
+ # In case of "noninteractive" FRONTEND the default value will remain valid (see in lines below)
+ if [ "${DEBIAN_FRONTEND}" != "Noninteractive" -a "${DEBIAN_FRONTEND}" != "noninteractive" ]; then
+ read -p " * Do you want to enable HTTPS? [N/y]: " https
+ fi
+
+ https=${https:-$HTTPS_DEFAULT}
+
+ if [ "${https}" = "y" -o "${https}" = "Y" -o "${https}" = "yes" ]; then
+ log_success_msg "Enabling HTTPS .."
+
+ # server.port = 8443
+ $_ex 'sed -i "s|#\s*server.port\s*=\s*8443|server.port=8443|g" /etc/openbaton/${properties_file_name}'
+ # server.ssl.enabled = true
+ $_ex 'sed -i "s|#\s*server.ssl.enabled\s*=\s*true|server.ssl.enabled=true|g" /etc/openbaton/${properties_file_name}'
+ # server.ssl.key-store = /etc/openbaton/keystore.p12
+ $_ex 'sed -i "s|#\s*server.ssl.key-store\s*=\s*\/etc\/openbaton\/keystore.p12|server.ssl.key-store=\/etc\/openbaton\/keystore.p12|g" /etc/openbaton/${properties_file_name}'
+ # server.ssl.key-store-password = password
+ $_ex 'sed -i "s|#\s*server.ssl.key-store-password\s*=\s*password|server.ssl.key-store-password=password|g" /etc/openbaton/${properties_file_name}'
+ # server.ssl.keyStoreType = PKCS12
+ $_ex 'sed -i "s|#\s*server.ssl.keyStoreType\s*=\s*PKCS12|server.ssl.keyStoreType=PKCS12|g" /etc/openbaton/${properties_file_name}'
+ # server.ssl.keyAlias = tomcat
+ $_ex 'sed -i "s|#\s*server.ssl.keyAlias\s*=\s*tomcat|server.ssl.keyAlias=tomcat|g" /etc/openbaton/${properties_file_name}'
+ # nfvo.https = false
+ $_ex 'sed -i "s|#\s*nfvo.https\s*=\s*false|nfvo.https=true|g" /etc/openbaton/${properties_file_name}'
+ fi
+}
+
+fix_jvm_delay_for_random_number_generation () {
+ java7_installed="false"
+ result=$( dpkg -l | grep "openjdk-7-jre" | wc -l)
+ if [ ${result} -gt 0 ]; then
+ java7_installed="true"
+ fi
+
+ if [ "${OS_TYPE}" = "Linux" ]; then
+ if [ "${OS_ARCHITECTURE}" = "x86_64" ]; then
+ if [ "${OS_DISTRIBUTION_RELEASE_MAJOR}" -ge "16" -a "${java7_installed}" != "true" ]; then # Ubuntu 16
+ export OPENJDK_8_LINUX_X86_64_SECURITYFILE=${OPENJDK_8_LINUX_X86_64_SECURITYFILE}
+ $_ex 'sed -i "s|securerandom.source=file:/dev/random|securerandom.source=file:/dev/./urandom|g" ${OPENJDK_8_LINUX_X86_64_SECURITYFILE}'
+ else # Ubuntu 14
+ export OPENJDK_7_LINUX_X86_64_SECURITYFILE=${OPENJDK_7_LINUX_X86_64_SECURITYFILE}
+ $_ex 'sed -i "s|securerandom.source=file:/dev/urandom|securerandom.source=file:/dev/./urandom|g" ${OPENJDK_7_LINUX_X86_64_SECURITYFILE}'
+ fi
+ else # i386
+ if [ "${OS_DISTRIBUTION_RELEASE_MAJOR}" -ge "16" -a "${java7_installed}" != "true" ]; then # Ubuntu 16
+ export OPENJDK_8_LINUX_I386_SECURITYFILE=${OPENJDK_8_LINUX_I386_SECURITYFILE}
+ $_ex 'sed -i "s|securerandom.source=file:/dev/random|securerandom.source=file:/dev/./urandom|g" ${OPENJDK_8_LINUX_I386_SECURITYFILE}'
+ else # Ubuntu 14
+ export OPENJDK_7_LINUX_I386_SECURITYFILE=${OPENJDK_7_LINUX_I386_SECURITYFILE}
+ $_ex 'sed -i "s|securerandom.source=file:/dev/urandom|securerandom.source=file:/dev/./urandom|g" ${OPENJDK_7_LINUX_I386_64_SECURITYFILE}'
+ fi
+ fi
+ elif [ "${ostype}" = "Darwin" ]; then
+ export OPENJDK_7_OSX_SECURITYFILE=${OPENJDK_7_OSX_SECURITYFILE}
+ $_ex 'sed -i "" "s|securerandom.source=file:/dev/urandom|securerandom.source=file:/dev/./urandom|g" ${OPENJDK_7_OSX_SECURITYFILE}'
+ fi
+}
+
+
+###############
+#### MySQL ####
+###############
+
+configure_mysql () {
+ export properties_file_name=${1}
+
+ log_success_msg "Configuring MySQL for Open Baton .."
+
+ $_ex 'sed -i "s|spring.datasource.url\s*=\s*jdbc:hsqldb:file:\/tmp\/openbaton\/openbaton.hsdb|spring.datasource.url=jdbc:mysql:\/\/localhost:3306\/openbaton|g" /etc/openbaton/${properties_file_name}'
+ $_ex 'sed -i "s|spring.datasource.driver-class-name\s*=\s*org.hsqldb.jdbc.JDBCDriver|spring.datasource.driver-class-name=org.mariadb.jdbc.Driver|g" /etc/openbaton/${properties_file_name}'
+ $_ex 'sed -i "s|spring.jpa.database-platform\s*=\s*org.hibernate.dialect.HSQLDialect|spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect|g" /etc/openbaton/${properties_file_name}'
+
+ $_ex 'sed -i "s|spring.jpa.hibernate.ddl-auto\s*=\s*.*|spring.jpa.hibernate.ddl-auto=update|g" /etc/openbaton/${properties_file_name}'
+
+ $_ex 'sed -i "s|#\s*spring.datasource.validationQuery\s*=\s*SELECT 1|spring.datasource.validationQuery=SELECT 1|g" /etc/openbaton/${properties_file_name}'
+ $_ex 'sed -i "s|#\s*spring.datasource.testOnBorrow\s*=\s*true|spring.datasource.testOnBorrow=true|g" /etc/openbaton/${properties_file_name}'
+
+ # Enable MySQL
+
+ # In case of "noninteractive" FRONTEND the default value will remain valid (openbaton_nfvo_mysql_user: admin ; openbaton_nfvo_mysql_user_password: changeme)
+ if [ "${DEBIAN_FRONTEND}" != "Noninteractive" -a "${DEBIAN_FRONTEND}" != "noninteractive" ]; then
+ read -p " * Please, type the name of the MySQL user you would like the Open Baton NFVO to use [admin]: " openbaton_nfvo_mysql_user
+
+ # Turning echo ON and OFF between password reading
+ stty -echo
+ read -p " * Please, provide the password for this user [changeme]: " openbaton_nfvo_mysql_user_password ; echo
+ stty echo
+
+ # Turning echo ON and OFF batween password reading
+ stty -echo
+ read -p " * Please, provide the password of the 'root' user of MySQL [root]: " mysql_root_password ; echo
+ stty echo
+ fi
+
+ # Set the mysql user
+ export openbaton_nfvo_mysql_user=${openbaton_nfvo_mysql_user:-$OPENBATON_NFVO_MYSQL_USER_DEFAULT}
+ $_ex 'sed -i "s|spring.datasource.username\s*=\s*.*|spring.datasource.username=${openbaton_nfvo_mysql_user}|g" /etc/openbaton/${properties_file_name}'
+
+ # Set the mysql user's password
+ export openbaton_nfvo_mysql_user_password=${openbaton_nfvo_mysql_user_password:-$OPENBATON_NFVO_MYSQL_USER_PASSWORD_DEFAULT}
+ $_ex 'sed -i "s|spring.datasource.password\s*=\s*.*|spring.datasource.password=${openbaton_nfvo_mysql_user_password}|g" /etc/openbaton/${properties_file_name}'
+
+ result=$(ps aux | grep -v 'grep' | grep 'mysql' | wc -l)
+ if [ ${result} -le 0 ]; then
+ $_ex 'service mysql start'
+ fi
+ export mysql_root_password=${mysql_root_password:-$MYSQL_ROOT_PASSWORD_DEFAULT}
+ # Create the Database
+ mysql -uroot -p${mysql_root_password} -e "CREATE DATABASE openbaton /*\!40100 DEFAULT CHARACTER SET utf8 */;"
+ mysql -uroot -p${mysql_root_password} -e "CREATE USER ${openbaton_nfvo_mysql_user}@localhost IDENTIFIED BY '${openbaton_nfvo_mysql_user_password}';"
+ mysql -uroot -p${mysql_root_password} -e "GRANT ALL ON openbaton.* TO '${openbaton_nfvo_mysql_user}'@'localhost';"
+ mysql -uroot -p${mysql_root_password} -e "FLUSH PRIVILEGES;"
+ mysql -uroot -p${mysql_root_password} -e "USE openbaton;"
+}
+
+install_mysql () {
+ # TODO: fix properties files' names in DEBIAN and SOURCE installation
+ if [ -f "${OPENBATON_BASE_CONFIG_DIR}/openbaton.properties" ]; then
+ properties_file_name="openbaton.properties"
+ elif [ -f "${OPENBATON_BASE_CONFIG_DIR}/openbaton-nfvo.properties" ]; then
+ properties_file_name="openbaton-nfvo.properties"
+ else
+ log_failure_msg "Open Baton properties file not found in properties standard directory ('${OPENBATON_BASE_CONFIG_DIR}'). Cannot enable persistence."
+ fi
+
+ mysql=${mysql:-$MYSQL_DEFAULT}
+
+ # In case of "noninteractive" FRONTEND the default value will remain valid (mysql: yes)
+ if [ "${DEBIAN_FRONTEND}" != "Noninteractive" -a "${DEBIAN_FRONTEND}" != "noninteractive" ]; then
+ read -p " * Do you want to enable the Open Baton persistence through MySQL? [Y/n]: " mysql
+ else
+ if [ "${mysql}" = "" -o "${mysql}" = "y" -o "${mysql}" = "Y" -o "${mysql}" = "yes" ]; then
+ export mysql_root_password=${mysql_root_password:-$MYSQL_ROOT_PASSWORD_DEFAULT}
+ log_warning_msg "The root password used for the installation is: '${mysql_root_password}'"
+
+ # TODO OSX support for non interactive installation
+ $_ex 'apt-get install -y debconf-utils'
+ $_ex 'echo mysql-server mysql-server/root_password password ${mysql_root_password} | debconf-set-selections'
+ $_ex 'echo mysql-server mysql-server/root_password_again password ${mysql_root_password} | debconf-set-selections'
+ fi
+ fi
+
+ if [ "${mysql}" = "" -o "${mysql}" = "y" -o "${mysql}" = "Y" -o "${mysql}" = "yes" ]; then
+ echo " * Enabling MySQL Persistence"
+ $_ex 'apt-get update'
+ $_ex 'apt-get install -y mysql-server'
+ configure_mysql ${properties_file_name}
+ else
+ echo " * NOT Enabling MySQL Persistence"
+ fi
+}
+
+
+##############
+#### Main ####
+##############
+
+wait_for_nfvo_up () {
+ max_wait=300
+ i_wait=${max_wait}
+
+ while ! nc -z localhost 8080; do
+ sleep 1 # wait for 1 second before check again
+ i_wait=$((${i_wait}-1))
+ if [ ${i_wait} -eq 0 ]; then
+ echo " * The NFVO is not up after ${max_wait} seconds. Please, check the problem into the log file."
+ exit 1
+ fi
+ done
+}
+
+clean_db () {
+ component_name_fancy="${1}"
+ component_db_name="${2}"
+ component_mysql_user="${3}"
+
+ # Clean MySQL for Components
+ component_mysql_user=${component_mysql_user:-"undefined"}
+ if [ "${component_mysql_user}" != "undefined" ]; then
+ read -p " * Do you want to delete the Open Baton ${component_name_fancy} database: '${component_db_name}' (this will also delete the associated user: '${component_mysql_user}')? (if you skip this step then you won't be able, later on, to delete this database and its user using this script) [Y/n]: " mysql
+ if [ "${mysql}" = "" -o "${mysql}" = "y" -o "${mysql}" = "Y" -o "${mysql}" = "yes" ]; then
+ stty -echo
+ read -p " * Please, provide the password of the 'root' user of mysql [root]: " mysql_root_password ; echo
+ stty echo
+
+ echo " * Deleting Open Baton ${component_name_fancy} database and its associated user."
+ mysql_root_password=${mysql_root_password:-$MYSQL_ROOT_PASSWORD_DEFAULT}
+ mysql -uroot -p${mysql_root_password} -e "DROP DATABASE IF EXISTS ${component_db_name};" >/dev/null 2>&1
+ mysql -uroot -p${mysql_root_password} -e "DROP USER ${component_mysql_user}@localhost;" >/dev/null 2>&1
+
+ 1>$(tty)
+ else
+ echo " * NOT deleting Open Baton ${component_name_fancy} database and its associated user."
+ fi
+ fi
+}
+
+clean () {
+ mysql=$( dpkg -l | grep "mysql-client" | wc -l)
+
+ # TODO: fix properties files' names in DEBIAN and SOURCE installation
+ # Retrieve mysql credentials and rabbitmq user, ip, and management port
+ if [ -f "/etc/openbaton/openbaton-nfvo.properties" ]; then
+ nfvo_mysql_user=$( awk -F'=' '{ if($0 ~ "spring.datasource.username=") { print $2 }}' /etc/openbaton/openbaton-nfvo.properties )
+ if [ -f "/etc/openbaton/openbaton-fms.properties" ]; then
+ fms_mysql_user=$( awk -F'=' '{ if($0 ~ "spring.datasource.username=") { print $2 }}' /etc/openbaton/openbaton-fms.properties )
+ fi
+
+ rabbitmq_user=$( awk -F'=' '{ if($0 ~ "spring.rabbitmq.username=") { print $2 }}' /etc/openbaton/openbaton-nfvo.properties )
+ rabbitmq_ip=$( awk -F'=' '{ if($0 ~ "nfvo.rabbit.brokerIp=") { print $2 }}' /etc/openbaton/openbaton-nfvo.properties )
+ rabbitmq_management_port=$( awk -F'=' '{ if($0 ~ "nfvo.rabbit.management.port=") { print $2 }}' /etc/openbaton/openbaton-nfvo.properties )
+ elif [ -f "/etc/openbaton/openbaton.properties" ]; then
+ nfvo_mysql_user=$( awk -F'=' '{ if($0 ~ "spring.datasource.username=") { print $2 }}' /etc/openbaton/openbaton.properties )
+ if [ -f "/etc/openbaton/openbaton-fms.properties" ]; then
+ fms_mysql_user=$( awk -F'=' '{ if($0 ~ "spring.datasource.username=") { print $2 }}' /etc/openbaton/openbaton-fms.properties )
+ fi
+
+ rabbitmq_user=$( awk -F'=' '{ if($0 ~ "spring.rabbitmq.username=") { print $2 }}' /etc/openbaton/openbaton.properties )
+ rabbitmq_ip=$( awk -F'=' '{ if($0 ~ "nfvo.rabbit.brokerIp=") { print $2 }}' /etc/openbaton/openbaton.properties )
+ rabbitmq_management_port=$( awk -F'=' '{ if($0 ~ "nfvo.rabbit.management.port=") { print $2 }}' /etc/openbaton/openbaton.properties )
+ fi
+
+ # Clean Open Baton binaries and properties files
+ debian_packages_num=$( dpkg -l | grep openbaton | wc -l )
+ for i in $( seq 1 ${debian_packages_num}); do
+ package=$( dpkg -l | grep openbaton | head -1 | awk '{print $2}' )
+ $_ex "apt-get purge -y ${package}"
+ done
+
+ # Clean Open Baton source code and properties files
+ if [ -d ${OPENBATON_SOURCE_INSTALLATION_BASE_DIR} ]; then
+ $_ex "rm -r ${OPENBATON_SOURCE_INSTALLATION_BASE_DIR}"
+ if [ -d ${OPENBATON_BASE_CONFIG_DIR} ]; then
+ $_ex "rm -r ${OPENBATON_BASE_CONFIG_DIR}"
+ fi
+ fi
+
+ if [ ${mysql} -gt 0 ]; then
+ # Clean MySQL for NFVO
+ nfvo_mysql_user=${nfvo_mysql_user:-"undefined"}
+ if [ "${nfvo_mysql_user}" != "undefined" ]; then
+ clean_db "NFVO" "openbaton" "${nfvo_mysql_user}"
+ fi
+ # Clean MySQL for FMS
+ fms_mysql_user=${fms_mysql_user:-"undefined"}
+ if [ "${fms_mysql_user}" != "undefined" ]; then
+ clean_db "FMS" "faultmanagement" "${fms_mysql_user}"
+ fi
+ fi
+
+ # Retrieve rabbitmqadmin cli
+ wget -O rabbitmqadmin http://${rabbitmq_ip}:${rabbitmq_management_port}/cli/rabbitmqadmin
+ if [ $? -ne 0 ]; then
+ log_failure_msg "rabbitmqadmin utility not retrievable: impossible to clean the RabbitMQ installation"
+ echo " * Cleaning of Open Baton installation completed"
+ exit 0
+ fi
+
+ $_ex "chmod +x ./rabbitmqadmin"
+ $_ex "apt-get install -y python"
+
+ # Clean RabbitMQ
+ #./rabbitmqadmin delete vhost name="openbaton" #TODO
+ echo " * Deleting Open Baton RabbitMQ user and its associated exchanges (if any)."
+ ./rabbitmqadmin delete user name="${rabbitmq_user}"
+ result=$(./rabbitmqadmin list exchanges | grep "openbaton-exchange" | wc -l)
+ if [ ${result} -gt 0 ]; then
+ ./rabbitmqadmin delete exchange name="openbaton-exchange"
+ fi
+ result=$(./rabbitmqadmin list exchanges | grep "plugin-exchange" | wc -l)
+ if [ ${result} -gt 0 ]; then
+ ./rabbitmqadmin delete exchange name="plugin-exchange"
+ fi
+
+ # Delete rabbitmqadmin cli
+ $_ex "rm ./rabbitmqadmin"
+
+ 1>$(tty)
+ echo " * Cleaning of Open Baton installation completed"
+}
+
diff --git a/bootstrap/bootstrap-config-file b/bootstrap/bootstrap-config-file
new file mode 100644
index 0000000..be34c94
--- /dev/null
+++ b/bootstrap/bootstrap-config-file
@@ -0,0 +1,71 @@
+# This is a configuration file for the Open Baton bootstrap.
+# It allows you to specify the parameters needed during the bootstrap for the configuration of the Open Baton projects.
+#
+# Usage: sh <(curl -s http://get.openbaton.org/bootstrap) [help | clean | enable-persistence] | [[release | develop] [--openbaton-bootstrap-version=X.Y.Z (with X.Y.Z >= 3.2.0)] [--config-file=<absolute path to configuration file>]]
+#
+# IMPORTANT NOTE: Avoid spaces before and after the '=': i.e. a parameter needs to be specified as 'parameter=value'
+
+
+#################
+#### General ####
+#################
+
+#openbaton_bootstrap_version=latest # Deafult is 'latest' therefore if left empty ('openbaton_bootstrap_version=') or commented the bootstrap used will be the latest. Use format X.Y.Z for a specific version: the oldest VERSION installable is 3.2.0
+openbaton_installation_manner=noninteractive # Deafult is 'interactive' therefore if left empty ('openbaton_installation_manner=') or commented the installation will be interactive. Use 'noninteractive' or 'Noninteractive' for a not interactive installation
+openbaton_component_autostart=true # Deafult is 'true' therefore if left empty ('openbaton_component_autostart=') or commented the debian component will start automatically at the end of the installation
+
+
+##############
+#### NFVO ####
+##############
+
+rabbitmq_broker_ip=localhost # Default is 'localhost' therefore if left empty ('rabbitmq_broker_ip=') or commented the 'localhost' value will be used
+rabbitmq_management_port=15672 # Default is '15672' therefore if left empty ('rabbitmq_management_port=') or commented the '15672' value will be used
+openbaton_nfvo_ip=localhost # Default is 'localhost' therefore if left empty ('openbaton_nfvo_ip=') or commented the 'localhost' value will be used
+openbaton_admin_password=openbaton # Default is 'openbaton' therefore if left empty ('openbaton_admin_password=') or commented the 'openbaton' value will be used
+
+https=no # Default is 'NO' therefore if left empty ('https=') or commented the HTTPS will NOT be enabled
+mysql=yes # Default is 'YES' therefore if left empty ('mysql=') or commented the MYSQL DB will be installed and the Open Baton persistence will be enabled
+mysql_root_password=root # Default is 'root' therefore if left empty ('mysql_root_password=') or commented the 'root' value will be used (NOTE: you should insert here the actual mysql root password if mysql is already installed in the system)
+openbaton_nfvo_mysql_user=admin # Default is 'admin' therefore if left empty ('openbaton_nfvo_mysql_user=') or commented the 'admin' value will be used
+openbaton_nfvo_mysql_user_password=changeme # Default is 'changeme' therefore if left empty ('openbaton_nfvo_mysql_user_password=') or commented the 'changeme' value will be used
+
+
+##########################################
+#### Open Baton additional components ####
+##########################################
+
+openbaton_plugin_vimdriver_openstack=yes # Default is 'YES' therefore if left empty ('openbaton_plugin_vimdriver_openstack=') or commented the 'openbaton_plugin_vimdriver_openstack' debian package will be installed
+openbaton_vnfm_generic=yes # Default is 'YES' therefore if left empty ('openbaton_vnfm_generic=') or commented the 'openbaton_vnfm_generic' debian package will be installed
+openbaton_fms=yes # Default is 'NO' therefore if left empty ('openbaton_fms=') or commented the 'openbaton_fms' debian package will NOT be installed
+openbaton_ase=yes # Default is 'NO' therefore if left empty ('openbaton_ase=') or commented the 'openbaton_ase' debian package will NOT be installed
+openbaton_nse=yes # Default is 'NO' therefore if left empty ('openbaton_nse=') or commented the 'openbaton_nse' debian package will NOT be installed
+openbaton_cli=yes # Default is 'NO' therefore if left empty ('openbaton_cli=') or commented the 'openbaton_cli' debian package will NOT be installed
+
+# NOTE: The VERSION is to be interptreted as "debian package version" or "source TAG" respectively for RELEASE / DEVELOP installation
+# Possible values are: 'latest' (only for RELEASE), 'develop' (only for DEVELOP), 'X.Y.Z' (for both types of installation)
+openbaton_nfvo_version=4.0.0 # Default is 'latest' / 'develop' therefore if left empty ('openbaton_nfvo_version=') or commented the 'latest' debian version / the 'develop' TAG will be installed. NOTE: Check the list of available tags at: https://github.com/openbaton/generic-vnfm/tags - The oldest VERSION installable is 3.2.0
+openbaton_plugin_vimdriver_openstack_version=4.0.1 # Default is 'latest' / 'develop' therefore if left empty ('openbaton_nfvo_version=') or commented the 'latest' debian version / the 'develop' TAG will be installed. NOTE: Check the list of available tags at: https://github.com/openbaton/openstack4j-plugin/tags - The oldest VERSION installable is 3.2.0
+openbaton_vnfm_generic_version=4.0.0 # Default is 'latest' / 'develop' therefore if left empty ('openbaton_vnfm_generic_version=') or commented the 'latest' debian version / the 'develop' TAG will be deployed. NOTE: Check the list of available tags at: https://github.com/openbaton/generic-vnfm/tags - The oldest VERSION installable is 3.2.0
+openbaton_fms_version=1.2.5 # Default is 'latest' / 'develop' therefore if left empty ('openbaton_fms_version=') or commented the 'latest' debian version / the 'develop' TAG will be deployed. NOTE: Check the list of available tags at: https://github.com/openbaton/fm-system/tags - The oldest VERSION installable is 1.2.1
+openbaton_ase_version=1.2.3 # Default is 'latest' / 'develop' therefore if left empty ('openbaton_ase_version=') or commented the 'latest' debian version / the 'develop' TAG will be deployed. NOTE: Check the list of available tags at: https://github.com/openbaton/autoscaling-engine/tags - The oldest VERSION installable is 1.2.2
+openbaton_nse_version=1.1.2 # Default is 'latest' / 'develop' therefore if left empty ('openbaton_nse_version=') or commented the 'latest' debian version / the 'develop' TAG will be deployed. NOTE: Check the list of available tags at: https://github.com/openbaton/network-slicing-engine/tags - The oldest VERSION installable is 1.1.2
+
+
+#############
+#### FMS ####
+#############
+
+openbaton_fms_mysql_user=fmsuser # Default is 'fmsuser' therefore if left empty ('mysql_user=') or commented the 'admin' value will be used
+openbaton_fms_mysql_user_password=changeme # Default is 'changeme' therefore if left empty ('mysql_user_password=') or commented the 'changeme' value will be used
+
+
+######################################################
+#### Zabbix Plugin (required by FMS, ASE and NSE) ####
+######################################################
+
+# NOTE: Currently the ZABBIX configuration parameters are supported only for the RELEASE installation
+zabbix_plugin_ip= # Default is 'localhost' therefore if left empty ('zabbix_plugin_ip=') or commented the 'admin' value will be used
+zabbix_server_ip= # Default is 'localhost' therefore if left empty ('zabbix_server_ip=') or commented the 'admin' value will be used
+zabbix_user= # Default is 'Admin' therefore if left empty ('zabbix_user=') or commented the 'Admin' value will be used
+zabbix_user_password= # Default is 'zabbix' therefore if left empty ('zabbix_user_password=') or commented the 'zabbix' value will be used
diff --git a/bootstrap/bootstrap-deb-functions b/bootstrap/bootstrap-deb-functions
new file mode 100644
index 0000000..caadbc2
--- /dev/null
+++ b/bootstrap/bootstrap-deb-functions
@@ -0,0 +1,250 @@
+#!/bin/sh
+
+##########################
+#### General Settings ####
+##########################
+
+set -u
+#set -x # only for DEBUG
+
+
+##########################
+#### Global Variables ####
+##########################
+
+OPENBATON_COMPONENT_AUTOSTART_DEFAULT="true"
+
+
+####################
+#### Open Baton ####
+####################
+
+deb_add_openbaton_repo_reference () {
+ export release_nightly="${1}"
+ export distribution_codename="${2}"
+
+ # Add Open Baton Public Key to the APT keys
+ $_ex 'wget -O - http://get.openbaton.org/keys/openbaton.public.key | apt-key add -'
+
+ # Add Open Baton Repo to sources.list file
+ result=$(grep /etc/apt/sources.list -e "deb http://get.openbaton.org/repos/openbaton/${distribution_codename}/${release_nightly} ${distribution_codename} main" | wc -l)
+ if [ ${result} -eq 0 ]; then
+ $_ex 'echo "\n## Open Baton repository" >> /etc/apt/sources.list'
+ $_ex 'echo "deb http://get.openbaton.org/repos/openbaton/${distribution_codename}/${release_nightly} ${distribution_codename} main" >> /etc/apt/sources.list'
+ fi
+ $_ex 'apt-get update'
+}
+
+##############
+#### NFVO ####
+
+deb_install_nfvo () {
+ export release_nightly="${1}"
+ export oldest_nfvo_version_supported="${2}"
+ export nfvo_version="${3}"
+
+ if [ "${DEBIAN_FRONTEND}" != "Noninteractive" -a "${DEBIAN_FRONTEND}" != "noninteractive" ]; then
+ valid_version=false
+ while [ "${valid_version}" = "false" ]; do
+ # Ask for the NFVO version to be installed
+ read -p " * Which VERSION of the Open Baton NFVO do you want to install (Version Format is X.Y.Z - ** ${oldest_nfvo_version_supported} is the oldest version supported ** - Check the list of available VERSIONs at: ${OPENBATON_NFVO_REPO_URL}/tags )? (latest): " nfvo_version
+
+ if [ "${nfvo_version}" = "" -o "${nfvo_version}" = "latest" ]; then
+ valid_version=true
+ continue
+ else
+ result=$( echo ${nfvo_version} | grep "^[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}$" | wc -l )
+ if [ "${result}" != "0" ]; then
+ valid_version=true
+ continue
+ fi
+ fi
+ done
+ fi
+ if [ "${nfvo_version}" = "" -o "${nfvo_version}" = "latest" ]; then
+ nfvo_version=""
+ else
+ nfvo_version="=${nfvo_version}"
+ fi
+
+ # Install the correct NFVO package according to the given input parameter
+ if [ "${release_nightly}" = "release" ]; then
+ $_ex 'apt-get install -y openbaton-nfvo${nfvo_version}'
+ else
+ $_ex 'apt-get install -y openbaton-nfvo-nightly${nfvo_version}'
+ fi
+}
+
+deb_restart_nfvo () {
+ if $_ex 'systemctl restart openbaton-nfvo.service' >/dev/null 2>&1 ; then
+ log_success_msg "Restarting the Open Baton NFVO .."
+ elif $_ex 'service openbaton-nfvo restart' >/dev/null 2>&1 ; then
+ log_success_msg "Restarting the Open Baton NFVO .."
+ elif $_ex 'restart openbaton-nfvo' >/dev/null 2>&1 ; then
+ log_success_msg "Restarting the Open Baton NFVO .."
+ else
+ log_failure_msg "Restaring the Open Baton NFVO"
+ fi
+}
+
+###############################
+#### Additional Components ####
+
+deb_install_additional_component_versioned () {
+ if [ "${component_version}" = "" -o "${component_version}" = "latest" ]; then
+ component_version=""
+ else
+ component_version="=${component_version}"
+ fi
+
+ if [ "${release_nightly}" = "release" ]; then
+ $_ex 'apt-get install -y openbaton-${component_name}${component_version}'
+ else
+ $_ex 'apt-get install -y openbaton-${component_name}-nightly${component_version}'
+ fi
+}
+
+
+deb_install_additional_component () {
+ export release_nightly="${1}"
+ export component_name="${2}"
+ export component_name_fancy="${3}"
+ export install_during_noninteractive_installation="${4}"
+ export force_component_version="${5}"
+ export oldest_component_version_supported="${6}"
+ export component_repo_url="${7}"
+ export component_version="${8}"
+
+ if [ "${DEBIAN_FRONTEND}" != "Noninteractive" -a "${DEBIAN_FRONTEND}" != "noninteractive" ]; then
+ # Ask for the specified Additional Component installation
+ read -p " * Do you want to install also the Open Baton ${component_name_fancy}? ( if you do not, then you can still install it later with: sudo apt-get install openbaton-${component_name} ) (Y/n): " ac
+
+ # Print correct warning message
+ if [ "${ac}" = "n" -o "${ac}" = "N" -o "${ac}" = "no" -o "${ac}" = "NO" ]; then
+ echo " * Open Baton ${component_name_fancy} not installed"
+ if [ "${release_nightly}" = "release" ]; then
+ echo " * To install the latest release package:"
+ echo " * sudo apt-get install openbaton-${component_name}"
+ else
+ echo " * To install the latest nightly-build package:"
+ echo " * sudo apt-get install openbaton-${component_name}-nightly"
+ fi
+ return
+ else
+ # Install the correct Additional Component package according to the given input parameter
+ if [ ${force_component_version} != "true" ]; then
+ valid_version=false
+ while [ "${valid_version}" = "false" ]; do
+ # Ask for the Additional Component version to be installed
+ read -p " * Which VERSION of the Open Baton ${component_name_fancy} do you want to install (Version Format is X.Y.Z - *** ${oldest_component_version_supported} is the oldest version supported ** - Check the list of available VERSIONs at: ${component_repo_url}/tags )? (latest): " component_version
+
+ if [ "${component_version}" = "" -o "${component_version}" = "latest" ]; then
+ valid_version=true
+ continue
+ else
+ result=$( echo ${component_version} | grep "^[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}$" | wc -l )
+ if [ "${result}" != "0" ]; then
+ valid_version=true
+ continue
+ fi
+ fi
+ done
+ fi
+
+ deb_install_additional_component_versioned
+ fi
+ else
+ if [ "${install_during_noninteractive_installation}" = "y" -o "${install_during_noninteractive_installation}" = "Y" -o "${install_during_noninteractive_installation}" = "yes" ]; then
+ # Install the correct Additional Component package according to the given input parameter
+ deb_install_additional_component_versioned
+ fi
+ fi
+}
+
+deb_restart_additional_component () {
+ export component_name=${1}
+ export component_name_fancy="${2}"
+
+ if $_ex 'systemctl restart openbaton-${component_name}.service' >/dev/null 2>&1 ; then
+ log_success_msg "Restarting the Open Baton ${component_name_fancy} .."
+ elif $_ex 'service openbaton-${component_name} restart' >/dev/null 2>&1 ; then
+ log_success_msg "Restarting the Open Baton ${component_name_fancy} .."
+ elif $_ex 'restart openbaton-${component_name}' >/dev/null 2>&1 ; then
+ log_success_msg "Restarting the Open Baton ${component_name_fancy} .."
+ else
+ log_failure_msg "Restarting the Open Baton ${component_name_fancy}"
+ fi
+}
+
+deb_is_additional_component_installed () {
+ export component_name=${1}
+
+ installed=$(dpkg -l | grep -v grep | grep "openbaton-${component_name}" | wc -l)
+ if [ ${installed} -eq 0 ]; then
+ installed=1 # not installed
+ else
+ installed=0 # installed
+ fi
+}
+
+
+###################
+#### Bootstrap ####
+###################
+
+deb_bootstrap () {
+ export DEBIAN_FRONTEND=${openbaton_installation_manner:-$DEBIAN_FRONTEND_DEFAULT}
+ export OPENBATON_COMPONENT_AUTOSTART="${openbaton_component_autostart:-$OPENBATON_COMPONENT_AUTOSTART_DEFAULT}"
+
+ deb_add_openbaton_repo_reference "${1}" "${2}"
+ deb_install_nfvo "${1}" "3.2.0" "${openbaton_nfvo_version}"
+ install_mysql
+
+ #
+ # Arguments of "deb_install_additional_component": ${1} component-name component-name-fancy install_during_noninteractive_installation force_component_version oldest_component_version_supported component_version
+ #
+
+ # OpenStack VIM Driver Plugin
+ deb_install_additional_component ${1} plugin-vimdriver-openstack-4j "OpenStack VIM-Driver Plugin" ${openbaton_plugin_vimdriver_openstack} false "3.2.2" "${OPENBATON_PLUGINS_VIMDRIVERS_OPENSTACK_4J_REPO_URL}" ${openbaton_plugin_vimdriver_openstack_version}
+
+ # Generic VNFM
+ deb_install_additional_component ${1} vnfm-generic "Generic VNFM" ${openbaton_vnfm_generic} false "3.2.0" "${OPENBATON_VNFM_GENERIC_REPO_URL}" ${openbaton_vnfm_generic_version}
+
+ # Fault Management System
+ deb_install_additional_component ${1} fms "Fault Management System" ${openbaton_fms} false "1.2.4" "${OPENBATON_FMS_REPO_URL}" ${openbaton_fms_version}
+
+ # Auto Scaling Engine
+ deb_install_additional_component ${1} ase "Auto Scaling Engine" ${openbaton_ase} false "1.2.2" "${OPENBATON_ASE_REPO_URL}" ${openbaton_ase_version}
+
+ # Network Slicing Engine
+ deb_install_additional_component ${1} nse "Network Slicing Engine" ${openbaton_nse} false "1.1.2" "${OPENBATON_NSE_REPO_URL}" ${openbaton_nse_version}
+
+ # Command Line Interface
+ openbaton_cli_version=$( echo "${openbaton_nfvo_version}" | sed 's/-//g' )
+ deb_install_additional_component ${1} cli "Command Line Interface (CLI)" ${openbaton_cli} true "ignored" "ignored" "${openbaton_cli_version}"
+
+ fix_jvm_delay_for_random_number_generation
+ enable_https "openbaton-nfvo.properties"
+
+ log_success_msg "Finalising Open Baton installation .."
+ if [ "${OPENBATON_COMPONENT_AUTOSTART}" = "true" ]; then
+ #########
+ # Temporary workaround to avoid the spawning of multiple 'Test VIM Driver Plugin' processes during installation
+ #wait_for_nfvo_up
+ sleep 60
+ #########
+
+ log_success_msg "Restarting Open Baton components .."
+ deb_restart_nfvo
+ wait_for_nfvo_up # Some components needs the NFVO to be up in order to start correctly
+ deb_is_additional_component_installed vnfm-generic ; if [ "${installed}" = "0" ]; then deb_restart_additional_component vnfm-generic "Generic VNFM" ; fi
+ deb_is_additional_component_installed fms ; if [ "${installed}" = "0" ]; then deb_restart_additional_component fms "Fault Management System" ; fi
+ deb_is_additional_component_installed ase ; if [ "${installed}" = "0" ]; then deb_restart_additional_component ase "Auto Scaling Engine" ; fi
+ deb_is_additional_component_installed nse ; if [ "${installed}" = "0" ]; then deb_restart_additional_component nse "Network Slicing Engine" ; fi
+ fi
+
+ if [ -f "${BOOTSTRAP_DIR}/bootstrap-deb-functions" ]; then
+ rm ${BOOTSTRAP_DIR}/bootstrap-deb-functions
+ fi
+}
+
diff --git a/bootstrap/bootstrap-src-functions b/bootstrap/bootstrap-src-functions
new file mode 100644
index 0000000..b291fcc
--- /dev/null
+++ b/bootstrap/bootstrap-src-functions
@@ -0,0 +1,518 @@
+#!/bin/sh
+
+##########################
+#### General Settings ####
+##########################
+
+set -u
+#set -x # only for DEBUG
+
+
+##########################
+#### Global Variables ####
+##########################
+
+OPENBATON_PLUGINS_VIMDRIVERS_STABLE_URL="http://get.openbaton.org/plugins/stable/"
+
+OPENBATON_TMP_FOLDER=`mktemp -d`
+
+OPENBATON_INSTALLATION_BASE_DIR=/opt
+OPENBATON_BASE_DIR="${OPENBATON_INSTALLATION_BASE_DIR}/openbaton"
+OPENBATON_BASE_CONFIG_DIR="/etc/openbaton"
+OPENBATON_LOG="/var/log/openbaton"
+OPENBATON_NFVO_DIR="${OPENBATON_BASE_DIR}/nfvo"
+OPENBATON_PLUGINS_DIR="${OPENBATON_NFVO_DIR}/plugins"
+OPENBATON_PLUGINS_VIMDRIVERS_DIR="${OPENBATON_PLUGINS_DIR}/vim-drivers"
+
+OPENBATON_SRC_NFVO_CONFIG_FILE_NAME="openbaton.properties"
+OPENBATON_SRC_NFVO_CONFIG_FILE_ABSOLUTHE="${OPENBATON_BASE_CONFIG_DIR}/${OPENBATON_SRC_NFVO_CONFIG_FILE_NAME}"
+
+RABBITMQ_BROKER_IP_DEFAULT=localhost
+RABBITMQ_MANAGEMENT_PORT_DEFAULT=15672
+OPENBATON_ADMIN_PASSWORD_DEFAULT=openbaton
+
+OPENBATON_NFVO_IP_DEFAULT=localhost
+
+OPENBATON_FMS_MYSQL_USER_DEFAULT=fmsuser
+OPENBATON_FMS_MYSQL_USER_PASSWORD_DEFAULT=changeme
+OPENBATON_MYSQL_ROOT_PASSWORD_DEFAULT=root
+
+
+##################
+#### RabbitMQ ####
+##################
+
+src_install_rabbitmq () {
+ echo " * Configuring RabbitMQ for Open Baton .."
+ $_ex 'apt-get install -y rabbitmq-server'
+ ulimit -S -n 4096
+ src_configure_rabbitmq
+}
+
+src_configure_rabbitmq () {
+ result=$(ps aux | grep -v 'grep' | grep 'rabbitmq' | wc -l)
+ if [ ${result} -gt 0 ]; then
+ result=$($_ex 'rabbitmqctl list_users' | grep '^admin' | wc -l)
+ if [ ${result} -eq 0 ]; then
+ $_ex 'rabbitmqctl add_user admin openbaton'
+ $_ex 'rabbitmqctl set_user_tags admin administrator'
+ $_ex 'rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"'
+ $_ex 'rabbitmq-plugins enable rabbitmq_management'
+ $_ex 'service rabbitmq-server restart'
+ if [ "$?" != "0" ]; then
+ echo " * ERROR: RabbitMQ is NOT running properly (check the problem in /var/log/rabbitmq)"
+ exit 1
+ fi
+ fi
+ fi
+
+ # In case of "noninteractive" FRONTEND either the value from the configuration file or the default value will be used (DEFAULT: rabbitmq_broker_ip=localhost ; rabbitmq_management_port=15672)
+ if [ "${DEBIAN_FRONTEND}" != "Noninteractive" -a "${DEBIAN_FRONTEND}" != "noninteractive" ]; then
+ read -p " * Enter the rabbitmq broker ip [localhost]: " rabbitmq_broker_ip
+ read -p " * Enter the rabbitmq management port [15672]: " rabbitmq_management_port
+ fi
+
+ export OPENBATON_SRC_NFVO_CONFIG_FILE_ABSOLUTHE=${OPENBATON_SRC_NFVO_CONFIG_FILE_ABSOLUTHE}
+
+ # Set the rabbitmq broker ip
+ export rabbitmq_broker_ip=${rabbitmq_broker_ip:-$RABBITMQ_BROKER_IP_DEFAULT}
+ echo " * Setting new broker IP: ${rabbitmq_broker_ip}"
+ $_ex 'sed -i "s|nfvo.rabbit.brokerIp\s*=\s*localhost|nfvo.rabbit.brokerIp=${rabbitmq_broker_ip}|g" ${OPENBATON_SRC_NFVO_CONFIG_FILE_ABSOLUTHE}'
+
+ # Set the rabbitmq management port
+ export rabbitmq_management_port=${rabbitmq_management_port:-$RABBITMQ_MANAGEMENT_PORT_DEFAULT}
+ echo " * Setting new management port: ${rabbitmq_management_port}"
+ $_ex 'sed -i "s|nfvo.rabbit.management.port\s*=\s*15672|nfvo.rabbit.management.port=${rabbitmq_management_port}|g" ${OPENBATON_SRC_NFVO_CONFIG_FILE_ABSOLUTHE}'
+}
+
+
+############################
+#### VIM-Driver Plugins ####
+############################
+
+src_download_plugins () {
+ echo " * Downloading the Open Baton VIM Driver Plugins .."
+ wget -nH --cut-dirs 2 -r --no-parent --reject "index.html*" "${OPENBATON_PLUGINS_VIMDRIVERS_STABLE_URL}" -P "${OPENBATON_TMP_FOLDER}"
+ mkdir -p ${OPENBATON_PLUGINS_VIMDRIVERS_DIR}
+ cp -r ${OPENBATON_TMP_FOLDER}/* "${OPENBATON_PLUGINS_VIMDRIVERS_DIR}"
+}
+
+
+####################
+#### Open Baton ####
+####################
+
+src_prereq () {
+ if [ "${OS_TYPE}" = "Linux" ]; then
+ if [ "${OS_DISTRIBUTION_RELEASE_MAJOR}" -ge "16" ]; then
+ $_ex 'apt-get update; apt-get -y install openjdk-8-jdk curl wget screen git'
+ else # Ubuntu 14
+ $_ex 'apt-get update; apt-get -y install openjdk-7-jdk curl wget screen git'
+ fi
+ elif [ "${ostype}" = "Darwin" ]; then
+ # TODO
+ echo "TODO"
+ fi
+
+ fix_jvm_delay_for_random_number_generation
+
+ export USER=${USER}
+ src_create_openbaton_base
+ src_create_openbaton_log
+}
+
+src_check_environment () {
+ error=0
+ echo " * Checking environment .."
+ check_binary java; error=$(($error + $?))
+ check_binary javac; error=$(($error + $?))
+ check_binary curl; error=$(($error + $?))
+ check_binary screen; error=$(($error + $?))
+ check_binary wget; error=$(($error + $?))
+ if [ "0" != "$error" ]; then
+ echo >&2 " * ERROR: Please install the above mentioned binaries."
+ exit 1
+ fi
+}
+
+src_create_openbaton_base () {
+ echo " * Creating the Open Baton base folder .."
+ # removing it if exists
+ $_ex 'rm -rf '"${OPENBATON_BASE_DIR}"
+ $_ex 'mkdir -p '"${OPENBATON_NFVO_DIR}"
+ $_ex 'chown -R '"${USER} $OPENBATON_BASE_DIR"
+}
+
+src_create_openbaton_log () {
+ echo " * Creating the Open Baton log folder .."
+ # removing it if exists
+ $_ex 'rm -rf '"${OPENBATON_LOG}"
+ $_ex 'mkdir -p '"${OPENBATON_LOG}"
+ $_ex 'chown -R '"${USER} ${OPENBATON_LOG}"
+}
+
+src_checkout_nfvo () {
+ export oldest_nfvo_version_supported="${1}"
+ export nfvo_version="${2}"
+
+ if [ "${DEBIAN_FRONTEND}" != "Noninteractive" -a "${DEBIAN_FRONTEND}" != "noninteractive" ]; then
+ valid_version=false
+ while [ "${valid_version}" = "false" ]; do
+ # Ask for the NFVO version to be installed
+ read -p " * Which VERSION of the Open Baton NFVO do you want to install? ( Version Format is: X.Y.Z - ${oldest_nfvo_version_supported} is the oldest version installable - Check the list of available VERSIONs at: ${OPENBATON_NFVO_REPO_URL}/tags ) (develop): " nfvo_version
+
+ if [ "${nfvo_version}" = "" -o "${nfvo_version}" = "develop" ]; then
+ valid_version=true
+ continue
+ else
+ result=$( echo ${nfvo_version} | grep "^[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}$" | wc -l )
+ if [ "${result}" != "0" ]; then
+ valid_version=true
+ continue
+ fi
+ fi
+ done
+ fi
+ if [ "${nfvo_version}" = "" ]; then
+ nfvo_version="develop"
+ fi
+
+ echo " * Downloading Open Baton NFVO .."
+ git clone --recursive "${OPENBATON_NFVO_REPO_URL}.git" "${OPENBATON_NFVO_DIR}"
+ cd "${OPENBATON_NFVO_DIR}"
+
+ git checkout ${nfvo_version}
+
+ $_ex 'rm -rf '"${OPENBATON_BASE_CONFIG_DIR}; mkdir -p ${OPENBATON_BASE_CONFIG_DIR}"
+ $_ex 'cp '"${OPENBATON_NFVO_DIR}/etc/openbaton.properties ${OPENBATON_SRC_NFVO_CONFIG_FILE_ABSOLUTHE}"
+ $_ex 'cp '"${OPENBATON_NFVO_DIR}/etc/keystore.p12 ${OPENBATON_BASE_CONFIG_DIR}/keystore.p12"
+}
+
+src_compile_nfvo () {
+ echo " * Compiling the NFVO .."
+ cd "${OPENBATON_NFVO_DIR}"
+ ./openbaton.sh compile
+ if [ "$?" != "0" ]; then
+ echo " * ERROR: The compilation of the NFVO failed."
+ exit 1
+ fi
+}
+
+src_start_nfvo () {
+ echo " * Starting the NFVO .."
+ cd "${OPENBATON_NFVO_DIR}"
+ ./openbaton.sh start
+}
+
+src_deploy_nfvo () {
+ src_compile_nfvo
+ src_set_nfvo_admin_credentials
+ src_start_nfvo
+}
+
+src_set_nfvo_admin_credentials () {
+ # In case of "noninteractive" FRONTEND the default value will remain valid (user: admin ; password: openbaton)
+ if [ "${DEBIAN_FRONTEND}" != "Noninteractive" -a "${DEBIAN_FRONTEND}" != "noninteractive" ]; then
+ # Turning echo ON and OFF between password reading
+ stty -echo
+ read -p " * Provide the new password for 'admin' user of Open Baton [openbaton]: " openbaton_admin_password ; echo
+ stty echo
+
+ if [ "${openbaton_admin_password}" != "" ]; then
+ # Turning echo ON and OFF between password reading
+ stty -echo
+ read -p " * Repeat the 'admin' password: " openbaton_admin_password_again ; echo
+ stty echo
+ if [ "${openbaton_admin_password}" != "${openbaton_admin_password_again}" ]; then
+ src_set_nfvo_admin_credentials
+ fi
+ fi
+ fi
+
+ # Set the openbaton admin password
+ export openbaton_admin_password=${openbaton_admin_password:-$OPENBATON_ADMIN_PASSWORD_DEFAULT}
+ $_ex 'sed -i "s|nfvo.security.admin.password\s*=\s*openbaton|nfvo.security.admin.password=${openbaton_admin_password}|g" ${OPENBATON_SRC_NFVO_CONFIG_FILE_ABSOLUTHE}'
+}
+
+
+##############################
+#### Additional Component ####
+
+src_do_checkout () {
+ component_repo_url=${1}
+ component_name=${2} # the directory on which the repo will be locally cloned
+ component_name_fancy="${3}"
+ component_properties_file_src="${4}"
+ component_properties_file_dest="${5}"
+ component_version="${6}"
+
+ if [ "${component_version}" = "" ]; then
+ component_version="develop"
+ fi
+
+ cd "${OPENBATON_BASE_DIR}"
+ echo "Downloading ${component_name_fancy} .."
+ git clone --recursive "${component_repo_url}.git" "${component_name}"
+ cd "${component_name}"
+
+ git checkout ${component_version}
+
+ $_ex 'cp '"${component_properties_file_src} ${OPENBATON_BASE_CONFIG_DIR}/${component_properties_file_dest}"
+ installed=0
+}
+
+src_checkout_additional_component () {
+ component_repo_url="${1}"
+ component_name="${2}" # the directory on which the repo will be locally cloned
+ component_name_fancy="${3}"
+ component_properties_file_src="${4}"
+ component_properties_file_dest="${5}"
+ install_during_noninteractive_installation="${6}"
+ oldest_component_version_supported="${7}"
+ component_version="${8}"
+
+ if [ "${DEBIAN_FRONTEND}" != "Noninteractive" -a "${DEBIAN_FRONTEND}" != "noninteractive" ]; then
+ # Ask for the specified Additional Component installation
+ read -p " * Do you want to install also the ${component_name_fancy}? ( if you do not, then you can still install it later with: cd ${OPENBATON_BASE_DIR} && git clone ${component_repo_url}.git ) (Y/n): " ac
+
+ if [ "${ac}" = "" -o "${ac}" = "y" -o "${ac}" = "Y" -o "${ac}" = "yes" -o "${ac}" = "YES" ]; then
+ valid_version=false
+ while [ "${valid_version}" = "false" ]; do
+ read -p " * Which VERSION of the Open Baton ${component_name_fancy} do you want to install? ( Version Format is: X.Y.Z - ${oldest_component_version_supported} is the oldest version installable - Check the list of available VERSIONs at: ${component_repo_url}/tags ) (develop): " component_version
+
+ if [ "${component_version}" = "" -o "${component_version}" = "develop" ]; then
+ valid_version=true
+ continue
+ else
+ result=$( echo ${component_version} | grep "^[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}$" | wc -l )
+ if [ "${result}" != "0" ]; then
+ valid_version=true
+ continue
+ fi
+ fi
+ done
+
+ src_do_checkout "${component_repo_url}" "${component_name}" "${component_name_fancy}" "${component_properties_file_src}" "${component_properties_file_dest}" "${component_version}"
+ return
+ fi
+ else
+ # Install the correct Additional Component according to the given input parameters
+ if [ "${install_during_noninteractive_installation}" = "y" -o "${install_during_noninteractive_installation}" = "Y" -o "${install_during_noninteractive_installation}" = "yes" ]; then
+ src_do_checkout "${component_repo_url}" "${component_name}" "${component_name_fancy}" "${component_properties_file_src}" "${component_properties_file_dest}" "${component_version}"
+ return
+ fi
+ fi
+ installed=1
+}
+
+src_compile_additional_component () {
+ component_name="${1}" # the directory on which the repo has been cloned
+ component_name_fancy="${2}"
+
+ echo " * Compiling the ${component_name_fancy} .."
+ cd "${OPENBATON_BASE_DIR}/${component_name}"
+ ./${component_name}.sh compile
+ if [ $? -ne 0 ]; then
+ echo " * ERROR: The compilation of the ${2} failed"
+ exit 1
+ fi
+}
+
+src_start_additional_component () {
+ component_name="${1}" # the directory on which the repo has been cloned
+ component_name_fancy="${2}"
+
+ echo " * Starting the ${component_name_fancy} .."
+ cd "${OPENBATON_BASE_DIR}/${component_name}"
+ ./${component_name}.sh start
+}
+
+src_deploy_additional_component () {
+ src_compile_additional_component "${1}" "${2}"
+ src_start_additional_component "${1}" "${2}"
+}
+
+
+#############
+#### ASE ####
+#############
+
+src_ase_configure_rabbitmq () {
+ # Set the RabbitMQ IP
+ ase_rabbitmq_broker_ip=$( awk '$0 ~ "nfvo.rabbit.brokerIp[[:space:]]*="' "${OPENBATON_SRC_NFVO_CONFIG_FILE_ABSOLUTHE}" | awk -F'=' '{print $2}' )
+ if [ ! -z ${ase_rabbitmq_broker_ip+x} ] ; then # The empty string is considered as unset
+ log_success_msg "Setting RabbitMQ IP into Auto Scaling Engine: ${ase_rabbitmq_broker_ip}"
+ export ase_rabbitmq_broker_ip=${ase_rabbitmq_broker_ip}
+ $_ex 'sed -i "s|autoscaling.rabbitmq.brokerIp\s*=\s*localhost|autoscaling.rabbitmq.brokerIp=${ase_rabbitmq_broker_ip}|g" ${OPENBATON_BASE_CONFIG_DIR}/ase.properties'
+ fi
+
+ # Set the RabbitMQ Management port
+ ase_rabbitmq_management_port=$( awk '$0 ~ "nfvo.rabbit.management.port[[:space:]]*="' "${OPENBATON_SRC_NFVO_CONFIG_FILE_ABSOLUTHE}" | awk -F'=' '{print $2}' )
+ if [ ! -z ${ase_rabbitmq_management_port+x} ] ; then # The empty string is considered as unset
+ log_success_msg "Setting RabbitMQ Management port into Auto Scaling Engine: ${ase_rabbitmq_management_port}"
+ export ase_rabbitmq_management_port=${ase_rabbitmq_management_port}
+ $_ex 'sed -i "s|autoscaling.rabbitmq.management.port\s*=\s*15672|autoscaling.rabbitmq.management.port=${ase_rabbitmq_management_port}|g" ${OPENBATON_BASE_CONFIG_DIR}/ase.properties'
+ fi
+}
+
+src_ase_configure_nfvo_admin_credentials () {
+ # Set the NFVO admin's password
+ ase_nfvo_admin_password=$( awk '$0 ~ "nfvo.security.admin.password[[:space:]]*="' "${OPENBATON_SRC_NFVO_CONFIG_FILE_ABSOLUTHE}" | awk -F'=' '{print $2}' )
+ if [ ! -z ${ase_nfvo_admin_password+x} ] ; then # The empty string is considered as unset
+ log_success_msg "Setting NFVO admin's password into Auto Scaling Engine: ${ase_nfvo_admin_password}"
+ export ase_nfvo_admin_password=${ase_nfvo_admin_password}
+ $_ex 'sed -i "s|nfvo.password\s*=\s*openbaton|nfvo.password=${ase_nfvo_admin_password}|g" ${OPENBATON_BASE_CONFIG_DIR}/ase.properties'
+ fi
+}
+
+src_configure_ase () {
+ src_ase_configure_rabbitmq
+ src_ase_configure_nfvo_admin_credentials
+}
+
+
+#############
+#### FMS ####
+#############
+
+src_fms_configure_rabbitmq () {
+ # Set the RabbitMQ IP
+ rabbitmq_broker_ip=$( awk '$0 ~ "nfvo.rabbit.brokerIp[[:space:]]*="' "${OPENBATON_BASE_CONFIG_DIR}/${OPENBATON_NFVO_CONFIG_FILE}" | awk -F'=' '{print $2}' )
+ if [ ! -z ${rabbitmq_broker_ip+x} ] ; then # The empty string is considered as unset
+ log_success_msg "Setting RabbitMQ IP into Fault Management System: ${rabbitmq_broker_ip}"
+ export rabbitmq_broker_ip=${rabbitmq_broker_ip}
+ sed -i "s|spring.rabbitmq.host\s*=.*|spring.rabbitmq.host=${rabbitmq_broker_ip}|g" ${OPENBATON_BASE_CONFIG_DIR}/${OPENBATON_COMPONENT_CONFIG_FILE}
+ fi
+
+ # Set the RabbitMQ Management port
+ rabbitmq_management_port=$( awk '$0 ~ "nfvo.rabbit.management.port[[:space:]]*="' "${OPENBATON_BASE_CONFIG_DIR}/${OPENBATON_NFVO_CONFIG_FILE}" | awk -F'=' '{print $2}' )
+ if [ ! -z ${rabbitmq_management_port+x} ] ; then # The empty string is considered as unset
+ log_success_msg "Setting RabbitMQ Management port into Fault Management System: ${rabbitmq_management_port}"
+ export rabbitmq_management_port=${rabbitmq_management_port}
+ sed -i "s|spring.rabbitmq.port\s*=\s*15672|spring.rabbitmq.port=${rabbitmq_management_port}|g" ${OPENBATON_BASE_CONFIG_DIR}/${OPENBATON_COMPONENT_CONFIG_FILE}
+ fi
+}
+
+src_fms_configure_nfvo () {
+ # In case of "noninteractive" FRONTEND the default value will remain valid (openbaton_nfvo_ip: localhost)
+ if [ "${DEBIAN_FRONTEND}" != "Noninteractive" -a "${DEBIAN_FRONTEND}" != "noninteractive" ]; then
+ read -p " * Please, provide the IP of the NFVO [localhost]: " openbaton_nfvo_ip
+ fi
+ # Set the NFVO IP
+ export openbaton_nfvo_ip=${openbaton_nfvo_ip:-$OPENBATON_NFVO_IP_DEFAULT}
+ sed -i "s|nfvo.ip\s*=*|nfvo.ip=${openbaton_nfvo_ip}|g" ${OPENBATON_BASE_CONFIG_DIR}/${OPENBATON_COMPONENT_CONFIG_FILE}
+
+ # Set the NFVO credentials
+ export nfvo_admin_user="admin"
+ sed -i "s|nfvo-usr\s*=*|nfvo-usr=${nfvo_admin_user}|g" ${OPENBATON_BASE_CONFIG_DIR}/${OPENBATON_COMPONENT_CONFIG_FILE}
+
+ nfvo_admin_password=$( awk '$0 ~ "nfvo.security.admin.password[[:space:]]*="' "${OPENBATON_BASE_CONFIG_DIR}/${OPENBATON_NFVO_CONFIG_FILE}" | awk -F'=' '{print $2}' )
+ if [ ! -z ${nfvo_admin_password+x} ] ; then # The empty string is considered as unset
+ log_success_msg "Setting NFVO admin's password into Fault Management System: ${nfvo_admin_password}"
+ export nfvo_admin_password=${nfvo_admin_password}
+ sed -i "s|nfvo-pwd\s*=.*|nfvo-pwd=${nfvo_admin_password}|g" ${OPENBATON_BASE_CONFIG_DIR}/${OPENBATON_COMPONENT_CONFIG_FILE}
+ fi
+}
+
+src_fms_configure_mysql () {
+ # In case of "noninteractive" FRONTEND the default value will remain valid (openbaton_fms_mysql_user: fmsuser ; openbaton_fms_mysql_user_password: changeme)
+ if [ "${DEBIAN_FRONTEND}" != "Noninteractive" -a "${DEBIAN_FRONTEND}" != "noninteractive" ]; then
+ read -p " * Please, type the name of the MySQL user you would like the Open Baton FMS to use [fmsuser]: " openbaton_fms_mysql_user
+
+ # Turning echo ON and OFF between password reading
+ stty -echo
+ read -p " * Please, provide the password for this user [changeme]: " openbaton_fms_mysql_user_password ; echo
+ stty echo
+
+ # Turning echo ON and OFF batween password reading
+ stty -echo
+ read -p " * Please, provide the password of the 'root' user of MySQL [root]: " mysql_root_password ; echo
+ stty echo
+ fi
+
+ # Set the MySQL user
+ export openbaton_fms_mysql_user=${openbaton_fms_mysql_user:-$OPENBATON_FMS_MYSQL_USER_DEFAULT}
+ sed -i "s|spring.datasource.username\s*=.*|spring.datasource.username=${openbaton_fms_mysql_user}|g" ${OPENBATON_BASE_CONFIG_DIR}/${OPENBATON_COMPONENT_CONFIG_FILE}
+
+ # Set the MySQL user's password
+ export openbaton_fms_mysql_user_password=${openbaton_fms_mysql_user_password:-$OPENBATON_FMS_MYSQL_USER_PASSWORD_DEFAULT}
+ sed -i "s|spring.datasource.password\s*=.*|spring.datasource.password=${openbaton_fms_mysql_user_password}|g" ${OPENBATON_BASE_CONFIG_DIR}/${OPENBATON_COMPONENT_CONFIG_FILE}
+
+ result=$(ps aux | grep -v 'grep' | grep 'mysql' | wc -l)
+ if [ ${result} -le 0 ]; then
+ $_ex 'service mysql start'
+ fi
+
+ export mysql_root_password=${mysql_root_password:-$OPENBATON_MYSQL_ROOT_PASSWORD_DEFAULT}
+ # Create the Database
+ mysql -uroot -p${mysql_root_password} -e "CREATE DATABASE faultmanagement /*\!40100 DEFAULT CHARACTER SET utf8 */;"
+ mysql -uroot -p${mysql_root_password} -e "CREATE USER ${openbaton_fms_mysql_user}@localhost IDENTIFIED BY '${openbaton_fms_mysql_user_password}';"
+ mysql -uroot -p${mysql_root_password} -e "GRANT ALL ON faultmanagement.* TO '${openbaton_fms_mysql_user}'@'localhost';"
+ mysql -uroot -p${mysql_root_password} -e "FLUSH PRIVILEGES;"
+}
+
+src_configure_fms () {
+ src_fms_configure_mysql
+ src_fms_configure_rabbitmq
+ src_fms_configure_nfvo
+}
+
+
+##############
+#### Main ####
+##############
+
+src_bootstrap () {
+ src_prereq
+
+ src_checkout_nfvo "3.2.0" "${openbaton_nfvo_version}"
+
+ install_mysql
+
+ # VIM Driver Plugins
+ #openbaton_plugin_vimdriver_all_version=${openbaton_plugin_vimdriver_all_version:-$OPENBATON_PLUGIN_VIMDRIVER_OPENSTACK_VERSION_DEFAULT}
+ src_download_plugins
+
+ src_install_rabbitmq
+ src_check_environment
+
+ enable_https "openbaton.properties"
+
+ src_deploy_nfvo
+
+
+ # Generic VNFM
+ src_checkout_additional_component "${OPENBATON_VNFM_GENERIC_REPO_URL}" "generic-vnfm" "Generic VNFM" "src/main/resources/application.properties" "openbaton-vnfm-generic.properties" ${openbaton_vnfm_generic} "3.2.0" "${openbaton_vnfm_generic_version}"
+ if [ "${installed}" = "0" ]; then
+ src_deploy_additional_component "generic-vnfm" "Generic VNFM"
+ fi
+
+ # Fault Management System
+ src_checkout_additional_component "${OPENBATON_FMS_REPO_URL}" "fm-system" "Fault Management System (FMS)" "etc/fms.properties" "openbaton-fms.properties" "${openbaton_fms}" "1.2.4" "${openbaton_fms_version}"
+ if [ "${installed}" = "0" ]; then
+ src_configure_fms
+ src_deploy_additional_component "fm-system" "Fault Management System (FMS)"
+ fi
+
+ # Auto Scaling Engine
+ src_checkout_additional_component "${OPENBATON_ASE_REPO_URL}" "autoscaling-engine" "Auto Scaling Engine (ASE)" "etc/ase.properties" "ase.properties" "${openbaton_ase}" "1.2.2" "${openbaton_ase_version}"
+ if [ "${installed}" = "0" ]; then
+ src_configure_ase
+ src_deploy_additional_component "autoscaling-engine" "Auto Scaling Engine (ASE)"
+ fi
+
+ # Network Slicing Engine
+ src_checkout_additional_component "${OPENBATON_NSE_REPO_URL}" "network-slicing-engine" "Network Slicing Engine (NSE)" "etc/nse.properties" "openbaton-nse.properties" "${openbaton_nse}" "1.1.2" "${openbaton_nse_version}"
+ if [ "${installed}" = "0" ]; then
+ src_deploy_additional_component "network-slicing-engine" "Network Slicing Engine"
+ fi
+
+ echo " * Waiting for Open Baton to be up..."
+ wait_for_nfvo_up
+ echo " * Now open http://localhost:8080/"
+
+ if [ -f "${BOOTSTRAP_DIR}/bootstrap-src-functions" ]; then
+ rm ${BOOTSTRAP_DIR}/bootstrap-src-functions
+ fi
+}
+