bb093ee6ed
Separate nfv configurations from install function and put them into a configure function to be consistent with Devstack pattern. Story: 2003163 Task: 28350 Depends-On: https://review.openstack.org/#/c/623410 Change-Id: I1acd15d628a2636ac2897abcbe446368821973bc Signed-off-by: Yi Wang <yi.c.wang@intel.com>
329 lines
13 KiB
Bash
329 lines
13 KiB
Bash
#!/bin/bash
|
|
#
|
|
# lib/stx-nfv
|
|
# Functions to control the configuration and operation of stx-nfv
|
|
|
|
_XTRACE_STX_NFV=$(set +o | grep xtrace)
|
|
set -o xtrace
|
|
|
|
STXNFV_DIR=$DEST/stx-nfv
|
|
STXNFV_SYSCONFDIR=/etc
|
|
STXNFV_OCF_ROOT=/usr/lib/ocf
|
|
|
|
STX_BIN_DIR=$(get_python_exec_prefix)
|
|
STX_PREFIX=${STX_BIN_DIR%/*}
|
|
|
|
NFV_DIR=$STXNFV_DIR/nfv
|
|
NFV_CONF_DIR=$STXNFV_SYSCONFDIR/nfv
|
|
NFV_OCF_DIR=$STXNFV_OCF_ROOT/resource.d/nfv
|
|
NFV_CLIENT_DIR=$NFV_DIR/nfv-client
|
|
NFV_COMMON_DIR=$NFV_DIR/nfv-common
|
|
NFV_PLUGINS_DIR=$NFV_DIR/nfv-plugins
|
|
NFV_TOOLS_DIR=$NFV_DIR/nfv-tools
|
|
NFV_VIM_DIR=$NFV_DIR/nfv-vim
|
|
|
|
NOVA_API_PROXY_CONF=$STXNFV_SYSCONFDIR/proxy
|
|
NOVA_API_PROXY_DIR=$STXNFV_DIR/nova-api-proxy/nova-api-proxy
|
|
|
|
GUEST_CLIENT_VERSION="3.0.1"
|
|
|
|
STX_SDK_DEPLOY_DIR=${STX_SDK_DEPLOY_DIR:-/opt/deploy/cgcs_sdk}
|
|
|
|
PYTHON_SITE_DIR=$(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
|
|
|
|
function cleanup_guest_client {
|
|
sudo rm -rf $STX_PREFIX/include/guest-client
|
|
sudo rm -rf $STX_SDK_DEPLOY_DIR
|
|
sudo rm -rf $STXNFV_SYSCONFDIR/systemd/system/guest-client.service
|
|
sudo rm -rf $STXNFV_SYSCONFDIR/guest-client
|
|
sudo rm -rf $STX_PREFIX/bin/guest-client
|
|
sudo rm -rf $STX_PREFIX/lib/libguest_common_api.so.$GUEST_CLIENT_VERSION
|
|
sudo rm -rf $STX_PREFIX/lib/libguest_heartbeat_api.so.$GUEST_CLIENT_VERSION
|
|
}
|
|
|
|
function cleanup_nfv {
|
|
sudo rm -rf $NFV_CONF_DIR
|
|
sudo rm -rf $NFV_OCF_DIR
|
|
sudo rm -rf $STXNFV_SYSCONFDIR/bash_completion.d/sw-manager
|
|
|
|
sudo rm -rf $STXNFV_SYSCONFDIR/systemd/system/devstack@nfv-vim.service
|
|
sudo rm -rf $STXNFV_SYSCONFDIR/systemd/system/devstack@nfv-vim-api.service
|
|
sudo rm -rf $STXNFV_SYSCONFDIR/systemd/system/devstack@nfv-vim-webserver.service
|
|
|
|
cleanup_nfv_vim
|
|
cleanup_nfv_common
|
|
cleanup_nfv_plugins
|
|
cleanup_nfv_tools
|
|
cleanup_nfv_client
|
|
}
|
|
|
|
function cleanup_nfv_client {
|
|
pip_uninstall nfv-client
|
|
}
|
|
|
|
function cleanup_nfv_common {
|
|
pip_uninstall windriver-nfv-common-plugins
|
|
}
|
|
|
|
function cleanup_nfv_plugins {
|
|
pip_uninstall windriver-nfv-plugins
|
|
}
|
|
|
|
function cleanup_nfv_tools {
|
|
pip_uninstall nfv-tools
|
|
}
|
|
|
|
function cleanup_nfv_vim {
|
|
pip_uninstall nfv-vim
|
|
}
|
|
|
|
function cleanup_nova_api_proxy {
|
|
pip_uninstall api-proxy
|
|
}
|
|
|
|
function configure_nfv {
|
|
configure_nfv_common
|
|
|
|
if is_service_enabled nfv-vim; then
|
|
configure_nfv_vim
|
|
fi
|
|
if is_service_enabled nfv-vim-api; then
|
|
configure_nfv_vim_api
|
|
fi
|
|
if is_service_enabled nfv-vim-webserver; then
|
|
configure_nfv_vim_webserver
|
|
fi
|
|
}
|
|
|
|
function configure_nfv_common {
|
|
iniset -sudo $NFV_CONF_DIR/nfv_plugins/nfvi_plugins/config.ini "platform" "authorization_ip" "$HOST_IP"
|
|
iniset -sudo $NFV_CONF_DIR/nfv_plugins/nfvi_plugins/config.ini "openstack" "authorization_ip" "$HOST_IP"
|
|
iniset -sudo $NFV_CONF_DIR/nfv_plugins/nfvi_plugins/config.ini "amqp" "host" "$RABBIT_HOST"
|
|
iniset -sudo $NFV_CONF_DIR/nfv_plugins/nfvi_plugins/config.ini "amqp" "user_id" "$RABBIT_USERID"
|
|
iniset -sudo $NFV_CONF_DIR/nfv_plugins/nfvi_plugins/config.ini "amqp" "password" "$RABBIT_PASSWORD"
|
|
if [[ "${CELLSV2_SETUP}" == "singleconductor" ]]; then
|
|
iniset -sudo $NFV_CONF_DIR/nfv_plugins/nfvi_plugins/config.ini "amqp" "virt_host" "/"
|
|
else
|
|
iniset -sudo $NFV_CONF_DIR/nfv_plugins/nfvi_plugins/config.ini "amqp" "virt_host" "nova_cell1"
|
|
fi
|
|
iniset -sudo $NFV_CONF_DIR/nfv_plugins/nfvi_plugins/config.ini "host-listener" "host" "$HOST_IP"
|
|
|
|
sudo sed -i -e "s|@SYSCONFDIR@|${STXNFV_SYSCONFDIR}|g" $NFV_CONF_DIR/vim/config.ini
|
|
sudo sed -i -e "s|@PYTHONROOT@|${PYTHON_SITE_DIR}|g" $NFV_CONF_DIR/vim/config.ini
|
|
iniset -sudo $NFV_CONF_DIR/vim/config.ini "sw-mgmt-configuration" "single_controller" "True"
|
|
iniset -sudo $NFV_CONF_DIR/vim/config.ini "vim-webserver" "host" "$HOST_IP"
|
|
}
|
|
|
|
function configure_nfv_vim {
|
|
sudo sed -i -e "s|@SYSCONFDIR@|${STXNFV_SYSCONFDIR}|g" $NFV_OCF_DIR/vim
|
|
sudo sed -i -e 's|${OCF_ROOT}|@OCF_ROOT@|g' $NFV_OCF_DIR/vim
|
|
sudo sed -i -e "s|@OCF_ROOT@|${STXNFV_OCF_ROOT}|g" $NFV_OCF_DIR/vim
|
|
|
|
iniset -sudo $STXNFV_SYSCONFDIR/systemd/system/devstack@nfv-vim.service "Service" "Type" "forking"
|
|
iniset -sudo $STXNFV_SYSCONFDIR/systemd/system/devstack@nfv-vim.service "Service" "PIDFile" "/var/run/nfv-vim.pid"
|
|
}
|
|
|
|
function configure_nfv_vim_api {
|
|
sudo sed -i -e "s|@SYSCONFDIR@|${STXNFV_SYSCONFDIR}|g" $NFV_OCF_DIR/vim-api
|
|
sudo sed -i -e 's|${OCF_ROOT}|@OCF_ROOT@|g' $NFV_OCF_DIR/vim-api
|
|
sudo sed -i -e "s|@OCF_ROOT@|${STXNFV_OCF_ROOT}|g" $NFV_OCF_DIR/vim-api
|
|
|
|
iniset -sudo $STXNFV_SYSCONFDIR/systemd/system/devstack@nfv-vim-api.service "Service" "Type" "forking"
|
|
iniset -sudo $STXNFV_SYSCONFDIR/systemd/system/devstack@nfv-vim-api.service "Service" "PIDFile" "/var/run/nfv-vim-api.pid"
|
|
}
|
|
|
|
function configure_nfv_vim_webserver {
|
|
sudo sed -i -e "s|@SYSCONFDIR@|${STXNFV_SYSCONFDIR}|g" $NFV_OCF_DIR/vim-webserver
|
|
sudo sed -i -e 's|${OCF_ROOT}|@OCF_ROOT@|g' $NFV_OCF_DIR/vim-webserver
|
|
sudo sed -i -e "s|@OCF_ROOT@|${STXNFV_OCF_ROOT}|g" $NFV_OCF_DIR/vim-webserver
|
|
|
|
iniset -sudo $STXNFV_SYSCONFDIR/systemd/system/devstack@nfv-vim-webserver.service "Service" "Type" "forking"
|
|
iniset -sudo $STXNFV_SYSCONFDIR/systemd/system/devstack@nfv-vim-webserver.service "Service" "PIDFile" "/var/run/nfv-vim-webserver.pid"
|
|
}
|
|
|
|
function configure_nova_api_proxy {
|
|
iniset -sudo $NOVA_API_PROXY_CONF/nova-api-proxy.conf "DEFAULT" "pool_size" "256"
|
|
iniset -sudo $NOVA_API_PROXY_CONF/nova-api-proxy.conf "DEFAULT" "nfvi_compute_listen_port" "30003"
|
|
iniset -sudo $NOVA_API_PROXY_CONF/nova-api-proxy.conf "DEFAULT" "nfvi_compute_listen" "127.0.0.1"
|
|
iniset -sudo $NOVA_API_PROXY_CONF/nova-api-proxy.conf "keystone_authtoken" "auth_type" "password"
|
|
iniset -sudo $NOVA_API_PROXY_CONF/nova-api-proxy.conf "keystone_authtoken" "auth_url" "$KEYSTONE_SERVICE_URI"
|
|
iniset -sudo $NOVA_API_PROXY_CONF/nova-api-proxy.conf "keystone_authtoken" "user_domain_name" "$SERVICE_DOMAIN_NAME"
|
|
iniset -sudo $NOVA_API_PROXY_CONF/nova-api-proxy.conf "keystone_authtoken" "username" "nova"
|
|
iniset -sudo $NOVA_API_PROXY_CONF/nova-api-proxy.conf "keystone_authtoken" "password" "$SERVICE_PASSWORD"
|
|
iniset -sudo $NOVA_API_PROXY_CONF/nova-api-proxy.conf "keystone_authtoken" "project_domain_name" "$SERVICE_DOMAIN_NAME"
|
|
iniset -sudo $NOVA_API_PROXY_CONF/nova-api-proxy.conf "keystone_authtoken" "project_name" "$SERVICE_PROJECT_NAME"
|
|
iniset -sudo $NOVA_API_PROXY_CONF/nova-api-proxy.conf "keystone_authtoken" "admin_user" "nova"
|
|
iniset -sudo $NOVA_API_PROXY_CONF/nova-api-proxy.conf "keystone_authtoken" "admin_tenant_name" "$SERVICE_PROJECT_NAME"
|
|
|
|
iniset -sudo $STXNFV_SYSCONFDIR/systemd/system/devstack@nova-api-proxy.service "Service" "Type" "simple"
|
|
iniset -sudo $STXNFV_SYSCONFDIR/systemd/system/devstack@nova-api-proxy.service "Service" "PIDFile" "/var/run/nova-api-proxy.pid"
|
|
}
|
|
|
|
function install_guest_client {
|
|
pushd $STXNFV_DIR/guest-client/guest-client-$GUEST_CLIENT_VERSION
|
|
|
|
make clean
|
|
make build sysconfdir=$STXNFV_SYSCONFDIR
|
|
make sample
|
|
make tar ARCHIVE_NAME=wrs-guest-heartbeat-$GUEST_CLIENT_VERSION
|
|
find build
|
|
|
|
# Sudo Install for guest-client package
|
|
sudo install -m 755 -d $STX_PREFIX/include/guest-client
|
|
sudo install -m 644 -p -D guest_client/src/heartbeat/guest_heartbeat_msg_defs.h $STX_PREFIX/include/guest-client/guest_heartbeat_msg_defs.h
|
|
sudo install -d $STX_SDK_DEPLOY_DIR
|
|
sudo install -m 640 build/wrs-guest-heartbeat-$GUEST_CLIENT_VERSION.tgz $STX_SDK_DEPLOY_DIR
|
|
|
|
# Systemd services
|
|
sudo install -m 644 -p -D guest_client/scripts/guest-client.service $STXNFV_SYSCONFDIR/systemd/system/guest-client.service
|
|
sudo install -m 744 -p -D guest_client/scripts/guest-client.systemd $STXNFV_SYSCONFDIR/guest-client/guest-client.systemd
|
|
|
|
sudo install -m 750 -d $STXNFV_SYSCONFDIR/guest-client/heartbeat
|
|
sudo install -m 755 -p -D guest_client/scripts/guest_heartbeat.conf $STXNFV_SYSCONFDIR/guest-client/heartbeat/guest_heartbeat.conf
|
|
sudo install -m 755 -p -D guest_client/scripts/sample_event_handling_script $STXNFV_SYSCONFDIR/guest-client/heartbeat/sample_event_handling_script
|
|
sudo install -m 755 -p -D guest_client/scripts/sample_health_check_script $STXNFV_SYSCONFDIR/guest-client/heartbeat/sample_health_check_script
|
|
sudo install -m 640 -p -D build/guest-client $STX_PREFIX/bin/guest-client
|
|
sudo install -m 640 -p -D build/libguest_common_api.so.$GUEST_CLIENT_VERSION $STX_PREFIX/lib/libguest_common_api.so.$GUEST_CLIENT_VERSION
|
|
sudo install -m 640 -p -D build/libguest_heartbeat_api.so.$GUEST_CLIENT_VERSION $STX_PREFIX/lib/libguest_heartbeat_api.so.$GUEST_CLIENT_VERSION
|
|
|
|
popd
|
|
}
|
|
|
|
function install_nfv {
|
|
install_nfv_vim
|
|
install_nfv_common
|
|
install_nfv_plugins
|
|
install_nfv_tools
|
|
install_nfv_client
|
|
}
|
|
|
|
function install_nfv_client {
|
|
pushd $NFV_CLIENT_DIR
|
|
python setup.py build
|
|
sudo python setup.py install --root=/ --install-lib=${PYTHON_SITE_DIR} --single-version-externally-managed
|
|
popd
|
|
|
|
sudo install -d -m 755 $STXNFV_SYSCONFDIR/bash_completion.d
|
|
sudo install -m 444 $NFV_CLIENT_DIR/scripts/sw-manager.completion $STXNFV_SYSCONFDIR/bash_completion.d/sw-manager
|
|
}
|
|
|
|
function install_nfv_common {
|
|
pushd $NFV_COMMON_DIR
|
|
python setup.py build
|
|
sudo python setup.py install --root=/ --install-lib=${PYTHON_SITE_DIR} --single-version-externally-managed
|
|
popd
|
|
}
|
|
|
|
function install_nfv_plugins {
|
|
pushd $NFV_PLUGINS_DIR
|
|
python setup.py build
|
|
sudo python setup.py install --root=/ --install-lib=${PYTHON_SITE_DIR} --single-version-externally-managed
|
|
popd
|
|
|
|
sudo install -d -m 755 $NFV_CONF_DIR/nfv_plugins/
|
|
|
|
sudo install -d -m 755 $NFV_CONF_DIR/nfv_plugins/alarm_handlers/
|
|
sudo install -p -D -m 644 $NFV_PLUGINS_DIR/nfv_plugins/alarm_handlers/config.ini $NFV_CONF_DIR/nfv_plugins/alarm_handlers/config.ini
|
|
|
|
sudo install -d -m 755 $NFV_CONF_DIR/nfv_plugins/event_log_handlers/
|
|
sudo install -p -D -m 644 $NFV_PLUGINS_DIR/nfv_plugins/event_log_handlers/config.ini $NFV_CONF_DIR/nfv_plugins/event_log_handlers/config.ini
|
|
|
|
sudo install -d -m 755 $NFV_CONF_DIR/nfv_plugins/nfvi_plugins/
|
|
sudo install -p -D -m 644 $NFV_PLUGINS_DIR/nfv_plugins/nfvi_plugins/config.ini $NFV_CONF_DIR/nfv_plugins/nfvi_plugins/config.ini
|
|
sudo install -p -D -m 644 $NFV_PLUGINS_DIR/scripts/nfvi-plugins.logrotate $STXNFV_SYSCONFDIR/logrotate.d/nfvi-plugins.logrotate
|
|
}
|
|
|
|
function install_nfv_tools {
|
|
pushd $NFV_TOOLS_DIR
|
|
python setup.py build
|
|
sudo python setup.py install --root=/ --install-lib=${PYTHON_SITE_DIR} --single-version-externally-managed
|
|
popd
|
|
}
|
|
|
|
function install_nfv_vim {
|
|
pushd $NFV_VIM_DIR
|
|
python setup.py build
|
|
sudo python setup.py install --root=/ --install-lib=${PYTHON_SITE_DIR} --single-version-externally-managed
|
|
popd
|
|
|
|
sudo install -d -m 755 $NFV_CONF_DIR
|
|
sudo install -d -m 755 $NFV_OCF_DIR
|
|
sudo install -p -D -m 755 $NFV_VIM_DIR/scripts/vim $NFV_OCF_DIR/vim
|
|
sudo install -p -D -m 755 $NFV_VIM_DIR/scripts/vim-api $NFV_OCF_DIR/vim-api
|
|
sudo install -p -D -m 755 $NFV_VIM_DIR/scripts/vim-webserver $NFV_OCF_DIR/vim-webserver
|
|
|
|
sudo install -d -m 755 $NFV_CONF_DIR/vim/
|
|
sudo install -p -D -m 644 $NFV_VIM_DIR/nfv_vim/config.ini $NFV_CONF_DIR/vim/config.ini
|
|
sudo install -p -D -m 644 $NFV_VIM_DIR/nfv_vim/debug.ini $NFV_CONF_DIR/vim/debug.ini
|
|
}
|
|
|
|
function install_nova_api_proxy {
|
|
pushd $NOVA_API_PROXY_DIR
|
|
python setup.py build
|
|
sudo python setup.py install --root=/ --install-lib=${PYTHON_SITE_DIR} --single-version-externally-managed
|
|
popd
|
|
|
|
sudo install -d -m 755 $NOVA_API_PROXY_CONF
|
|
sudo install -p -D -m 744 $NOVA_API_PROXY_DIR/nova_api_proxy/nova-api-proxy.conf $NOVA_API_PROXY_CONF/nova-api-proxy.conf
|
|
sudo install -p -D -m 744 $NOVA_API_PROXY_DIR/nova_api_proxy/api-proxy-paste.ini $NOVA_API_PROXY_CONF/api-proxy-paste.ini
|
|
}
|
|
|
|
function start_nfv {
|
|
if is_service_enabled nfv-vim; then
|
|
start_nfv_vim
|
|
fi
|
|
if is_service_enabled nfv-vim-api; then
|
|
start_nfv_vim_api
|
|
fi
|
|
if is_service_enabled nfv-vim-webserver; then
|
|
start_nfv_vim_webserver
|
|
fi
|
|
}
|
|
|
|
function start_nfv_vim {
|
|
run_process nfv-vim "$NFV_OCF_DIR/vim start" root root
|
|
}
|
|
|
|
function start_nfv_vim_api {
|
|
run_process nfv-vim-api "$NFV_OCF_DIR/vim-api start" root root
|
|
}
|
|
|
|
function start_nfv_vim_webserver {
|
|
run_process nfv-vim-webserver "$NFV_OCF_DIR/vim-webserver start" root root
|
|
}
|
|
|
|
function start_nova_api_proxy {
|
|
local daemon=$(which nova-api-proxy)
|
|
run_process nova-api-proxy "$daemon --config-file=$NOVA_API_PROXY_CONF/nova-api-proxy.conf" root root
|
|
}
|
|
|
|
function stop_nfv {
|
|
if is_service_enabled nfv-vim; then
|
|
stop_nfv_vim
|
|
fi
|
|
if is_service_enabled nfv-vim-api; then
|
|
stop_nfv_vim_api
|
|
fi
|
|
if is_service_enabled nfv-vim-webserver; then
|
|
stop_nfv_vim_webserver
|
|
fi
|
|
}
|
|
|
|
function stop_nfv_vim {
|
|
stop_process nfv-vim
|
|
}
|
|
|
|
function stop_nfv_vim_api {
|
|
stop_process nfv-vim-api
|
|
}
|
|
|
|
function stop_nfv_vim_webserver {
|
|
stop_process nfv-vim-webserver
|
|
}
|
|
|
|
function stop_nova_api_proxy {
|
|
stop_process nova-api-proxy
|
|
}
|
|
|
|
$_XTRACE_STX_NFV
|