Updates to stx-nfv Devstack plugin
1. Refine nfv installation code to modify nfv config files 2. Add dependency resource-agents 3. Add code to start, stop annd clean up nfv services Story: 2003163 Task: 23298 Change-Id: Ic1e95dbaae4b319dcc9b4b20dea82bfb56e09696 Signed-off-by: Yi Wang <yi.c.wang@intel.com>
This commit is contained in:
parent
c626838a33
commit
41a8e350f0
@ -1 +1,2 @@
|
||||
libjson-c-dev
|
||||
resource-agents
|
||||
|
@ -1 +1,2 @@
|
||||
json-c-devel
|
||||
resource-agents
|
||||
|
@ -8,12 +8,14 @@ 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
|
||||
@ -24,6 +26,8 @@ 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
|
||||
@ -34,31 +38,40 @@ function cleanup_guest_client {
|
||||
sudo rm -rf $STX_PREFIX/lib/libguest_heartbeat_api.so.$GUEST_CLIENT_VERSION
|
||||
}
|
||||
|
||||
function cleanup_init_nfv {
|
||||
sudo userdel nfv
|
||||
sudo groupdel nfv
|
||||
sudo rm -rf /opt/platform/nfv
|
||||
}
|
||||
|
||||
function cleanup_nfv {
|
||||
if is_service_enabled stx-nfv; then
|
||||
clean_init_nfv
|
||||
fi
|
||||
if is_service_enabled guest-client; then
|
||||
cleanup_guest_client
|
||||
fi
|
||||
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 init_nfv {
|
||||
# TODO: This is all too specific, remove hard-coded uid and gid references
|
||||
function cleanup_nfv_client {
|
||||
pip_uninstall nfv-client
|
||||
}
|
||||
|
||||
# create the nfv group
|
||||
sudo groupadd -g 172 nfv
|
||||
function cleanup_nfv_common {
|
||||
pip_uninstall windriver-nfv-common-plugins
|
||||
}
|
||||
|
||||
# create the nfv user
|
||||
sudo useradd -d /var/lib/nfv -g 172 -u 172 -G nogroup,nfv -s /sbin/nologin nfv
|
||||
function cleanup_nfv_plugins {
|
||||
pip_uninstall windriver-nfv-plugins
|
||||
}
|
||||
|
||||
sudo mkdir -p /opt/platform/nfv
|
||||
function cleanup_nfv_tools {
|
||||
pip_uninstall nfv-tools
|
||||
}
|
||||
|
||||
function cleanup_nfv_vim {
|
||||
pip_uninstall nfv-vim
|
||||
}
|
||||
|
||||
function install_guest_client {
|
||||
@ -92,80 +105,151 @@ function install_guest_client {
|
||||
}
|
||||
|
||||
function install_nfv {
|
||||
if is_service_enabled nfv-common; then
|
||||
init_nfv
|
||||
install_nfv_common
|
||||
install_nfv_plugins
|
||||
install_nfv_tools
|
||||
fi
|
||||
|
||||
if is_service_enabled nfv-client; then
|
||||
install_nfv_client
|
||||
fi
|
||||
|
||||
if is_service_enabled nfv-vim; then
|
||||
install_nfv_vim
|
||||
fi
|
||||
|
||||
if is_service_enabled guest-client; then
|
||||
install_guest_client
|
||||
fi
|
||||
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
|
||||
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 scripts/sw-manager.completion $STXNFV_SYSCONFDIR/bash_completion.d/sw-manager
|
||||
popd
|
||||
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
|
||||
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
|
||||
|
||||
sudo install -d -m 755 $NFV_CONF_DIR
|
||||
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 600 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 600 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 600 nfv_plugins/nfvi_plugins/config.ini $NFV_CONF_DIR/nfv_plugins/nfvi_plugins/config.ini
|
||||
sudo install -p -D -m 644 scripts/nfvi-plugins.logrotate $STXNFV_SYSCONFDIR/logrotate.d/nfvi-plugins.logrotate
|
||||
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
|
||||
|
||||
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"
|
||||
}
|
||||
|
||||
function install_nfv_tools {
|
||||
pushd $NFV_TOOLS_DIR
|
||||
python setup.py build
|
||||
sudo python setup.py install
|
||||
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
|
||||
|
||||
sudo install -d -m 755 /usr/lib/ocf/resource.d/nfv
|
||||
sudo install -p -D -m 755 scripts/vim /usr/lib/ocf/resource.d/nfv/vim
|
||||
sudo install -p -D -m 755 scripts/vim-api /usr/lib/ocf/resource.d/nfv/vim-api
|
||||
sudo install -p -D -m 755 scripts/vim-webserver /usr/lib/ocf/resource.d/nfv/vim-webserver
|
||||
sudo install -d -m 755 $NFV_CONF_DIR/vim/
|
||||
sudo install -p -D -m 600 nfv_vim/config.ini $NFV_CONF_DIR/vim/config.ini
|
||||
sudo install -p -D -m 600 nfv_vim/debug.ini $NFV_CONF_DIR/vim/debug.ini
|
||||
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 sed -i -e "s|@SYSCONFDIR@|${STXNFV_SYSCONFDIR}|g" $NFV_OCF_DIR/vim
|
||||
sudo sed -i -e "s|@SYSCONFDIR@|${STXNFV_SYSCONFDIR}|g" $NFV_OCF_DIR/vim-api
|
||||
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
|
||||
sudo sed -i -e 's|${OCF_ROOT}|@OCF_ROOT@|g' $NFV_OCF_DIR/vim-api
|
||||
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
|
||||
sudo sed -i -e "s|@OCF_ROOT@|${STXNFV_OCF_ROOT}|g" $NFV_OCF_DIR/vim-api
|
||||
sudo sed -i -e "s|@OCF_ROOT@|${STXNFV_OCF_ROOT}|g" $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
|
||||
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 "vim-webserver" "host" "$HOST_IP"
|
||||
iniset -sudo $NFV_CONF_DIR/vim/config.ini "sw-mgmt-configuration" "single_controller" "True"
|
||||
}
|
||||
|
||||
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 {
|
||||
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"
|
||||
run_process nfv-vim "$NFV_OCF_DIR/vim start" root root
|
||||
}
|
||||
|
||||
function start_nfv_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"
|
||||
run_process nfv-vim-api "$NFV_OCF_DIR/vim-api start" root root
|
||||
}
|
||||
|
||||
function start_nfv_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"
|
||||
run_process nfv-vim-webserver "$NFV_OCF_DIR/vim-webserver start" 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
|
||||
}
|
||||
|
||||
$_XTRACE_STX_NFV
|
||||
|
@ -10,20 +10,40 @@ if is_service_enabled stx-nfv; then
|
||||
if [[ "$1" == "stack" && "$2" == "install" ]]; then
|
||||
# Perform installation of service source
|
||||
echo_summary "Installing stx-nfv"
|
||||
install_nfv
|
||||
if is_service_enabled nfv-vim || is_service_enabled nfv-vim-api || is_service_enabled nfv-vim-webserver; then
|
||||
install_nfv
|
||||
fi
|
||||
if is_service_enabled guest-client; then
|
||||
install_guest_client
|
||||
fi
|
||||
|
||||
elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
|
||||
# Configure after the other layer 1 and 2 services have been configured
|
||||
echo_summary "Configuring stx-nfv"
|
||||
:
|
||||
|
||||
elif [[ "$1" == "stack" && "$2" == "extra" ]]; then
|
||||
echo_summary "Starting stx-nfv"
|
||||
if is_service_enabled nfv-vim || is_service_enabled nfv-vim-api || is_service_enabled nfv-vim-webserver; then
|
||||
start_nfv
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
if [[ "$1" == "unstack" ]]; then
|
||||
:
|
||||
echo_summary "Shutdown stx-nfv"
|
||||
if is_service_enabled nfv-vim || is_service_enabled nfv-vim-api || is_service_enabled nfv-vim-webserver; then
|
||||
stop_nfv
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$1" == "clean" ]]; then
|
||||
echo_summary "Clean stx-nfv"
|
||||
cleanup_nfv
|
||||
if is_service_enabled nfv-vim || is_service_enabled nfv-vim-api || is_service_enabled nfv-vim-webserver; then
|
||||
cleanup_nfv
|
||||
fi
|
||||
if is_service_enabled guest-client; then
|
||||
cleanup_guest_client
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -10,8 +10,8 @@ STX_NFV_NAME=stx-nfv
|
||||
enable_service $STX_NFV_NAME
|
||||
|
||||
if is_service_enabled stx-nfv; then
|
||||
# Enable prerequisites here
|
||||
:
|
||||
# Enable prerequisites here
|
||||
:
|
||||
fi
|
||||
|
||||
# Initial source of lib script
|
||||
|
Loading…
Reference in New Issue
Block a user