summaryrefslogtreecommitdiffstats
path: root/bootstrap/bootstrap-deb-functions
diff options
context:
space:
mode:
Diffstat (limited to 'bootstrap/bootstrap-deb-functions')
-rw-r--r--bootstrap/bootstrap-deb-functions250
1 files changed, 250 insertions, 0 deletions
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
+}
+