Changes to stx-config

Change-Id: I72a642be427ea82759c8819e3ef5210157260559
Signed-off-by: Dean Troyer <dtroyer@gmail.com>
This commit is contained in:
Dean Troyer 2019-03-06 09:51:49 -06:00
parent ea8967d48a
commit 57f3316188
3 changed files with 58 additions and 45 deletions

View File

@ -64,12 +64,20 @@ stx_services="sysinv-api sysinv-cond sysinv-agent"
function check_sysinv_services {
local service
for service in $stx_services; do
if $SYSTEMCTL is-enabled devstack@$service.service; then
if [[is_service_enabled $service && $SYSTEMCTL is-enabled devstack@$service.service]]; then
$SYSTEMCTL status devstack@$service.service --no-pager
fi
done
}
function configure_config {
if is_service_enabled sysinv; then
configure_sysinv
create_sysinv_user_group
create_sysinv_accounts
fi
}
function configure_sysinv {
sudo install -d -o $STACK_USER $SYSINV_CONF_DIR
cp $SYSINV_DIR/etc/sysinv/sysinv.conf.sample $SYSINV_CONF_FILE
@ -119,11 +127,9 @@ function create_sysinv_cache_dir {
function create_sysinv_user_group {
if ! getent group sysinv >/dev/null; then
echo "Creating a group called sysinv"
sudo groupadd sysinv
fi
if ! getent passwd sysinv >/dev/null; then
echo "Creating a user called sysinv"
sudo mkdir -p /home/sysinv
sudo useradd -g sysinv -s /bin/bash -d /home/sysinv -m sysinv
echo "Giving user sysinv passwordless sudo privileges"
@ -144,16 +150,17 @@ function create_sysinv_user_group {
}
function init_sysinv {
echo "trigger init sysinv"
# Migrations need this
sudo install -d -m 755 -o ${USER} /var/run/sysinv
if [[ "$HOST_TOPOLOGY_ROLE" != "subnode" ]]; then
# (Re)create sysinv database
echo "recreate_database sysinv and dbsync"
recreate_database sysinv
$SYSINV_BIN_DIR/sysinv-dbsync --config-file=$SYSINV_CONF_FILE
if is_service_enabled sysinv; then
# Migrations need this
sudo install -d -m 755 -o ${USER} /var/run/sysinv
if [[ "$HOST_TOPOLOGY_ROLE" != "subnode" ]]; then
# (Re)create sysinv database
echo "recreate_database sysinv and dbsync"
recreate_database sysinv
$SYSINV_BIN_DIR/sysinv-dbsync --config-file=$SYSINV_CONF_FILE
fi
create_sysinv_cache_dir
fi
create_sysinv_cache_dir
}
function install_cgtsclient {
@ -161,6 +168,20 @@ function install_cgtsclient {
sudo install -D -m 0644 -o $STACK_USER {${GITDIR["$SYSINV_CLIENT_NAME"]}/tools/,/etc/bash_completion.d/}system.bash_completion
}
function install_config {
if is_service_enabled cgtsclient; then
install_cgtsclient
fi
if is_service_enabled sysinv; then
install_configutilities
install_controllerconfig
install_sysinv
fi
if is_service_enabled sysinv-agent; then
install_sysinv_agent
fi
}
function install_configutilities {
# We can't use setup_develop as there is no setup.cfg file present for configutilities
setup_package $STXCONFIG_CONFUTILS -e
@ -176,12 +197,6 @@ function install_controllerconfig {
}
function install_sysinv {
local req_services="key rabbit nova neutron"
for srv in $req_services;do
if ! is_service_enabled "$srv"; then
die $LINENO "$srv should be enabled for SysInv"
fi
done
setup_develop $SYSINV_DIR
sudo install -d -m 755 $SYSINV_ETC_GOENABLEDD
sudo install -p -D -m 755 $SYSINV_DIR/etc/sysinv/sysinv_goenabled_check.sh $SYSINV_ETC_GOENABLEDD/sysinv_goenabled_check.sh
@ -200,10 +215,6 @@ function install_sysinv {
sudo install -p -D -m 755 $SYSINV_DIR/sysinv/cmd/partition_info.sh $SYSINV_BIN_DIR/partition_info.sh
sudo install -p -D -m 755 $SYSINV_DIR/sysinv/cmd/manage-partitions $SYSINV_BIN_DIR/manage-partitions
sudo install -p -D -m 755 $SYSINV_DIR/sysinv/cmd/query_pci_id $SYSINV_BIN_DIR/query_pci_id
if is_service_enabled sysinv-agent; then
echo_summary "Installing sysinv-agent service"
install_sysinv_agent
fi
}
function install_sysinv_agent {
@ -211,35 +222,23 @@ function install_sysinv_agent {
sudo install -p -D -m 755 $SYSINV_AGENT_DIR/sysinv-agent $SYSINV_BIN_DIR/sysinv-agent.sh
}
function install_sysinv_depends {
install_configutilities
install_controllerconfig
}
function start_sysinv {
if is_service_enabled sysinv-api; then
echo "start sysinv-api service"
start_sysinv_api
fi
if is_service_enabled sysinv-cond; then
echo "start sysinv-cond service"
start_sysinv_conductor
fi
if is_service_enabled sysinv-agent; then
echo "start sysinv-agent service"
start_sysinv_agent
fi
}
function start_sysinv_agent {
if is_service_enabled sysinv-agent; then
echo "start sysinv-agent service"
run_process sysinv-agent "$SYSINV_BIN_DIR/sysinv-agent"
fi
run_process sysinv-agent "$SYSINV_BIN_DIR/sysinv-agent"
}
function start_sysinv_api {
echo "trigger start sysinv api"
run_process sysinv-api "$SYSINV_BIN_DIR/sysinv-api --config-file=$SYSINV_CONF_FILE"
# Get right service port for testing
@ -260,7 +259,6 @@ function start_sysinv_api {
}
function start_sysinv_conductor {
echo "trigger start sysinv conductor"
# the 1st will fail
stop_sysinv_conductor
run_process sysinv-cond "$SYSINV_BIN_DIR/sysinv-conductor --config-file=$SYSINV_CONF_FILE"
@ -269,9 +267,15 @@ function start_sysinv_conductor {
}
function stop_sysinv {
stop_sysinv_api
stop_sysinv_conductor
stop_sysinv_agent
if is_service_enabled sysinv-api; then
stop_sysinv_api
fi
if is_service_enabled sysinv-cond; then
stop_sysinv_conductor
fi
if is_service_enabled sysinv-agent; then
stop_sysinv_agent
fi
}
function stop_sysinv_agent {

View File

@ -13,9 +13,7 @@ if is_service_enabled $STX_TIS_NAME; then
echo_summary "Install $STX_TIS_NAME"
if is_service_enabled $STX_CONFIG_NAME; then
install_cgtsclient
install_sysinv_depends
install_sysinv
install_config
fi
if is_service_enabled $STX_FAULT_NAME; then
@ -31,9 +29,7 @@ if is_service_enabled $STX_TIS_NAME; then
echo_summary "Configure $STX_TIS_NAME"
if is_service_enabled $STX_CONFIG_NAME; then
configure_sysinv
create_sysinv_user_group
create_sysinv_accounts
configure_config
fi
if is_service_enabled $STX_FAULT_NAME; then

View File

@ -23,6 +23,19 @@ enable_service platform-util
# stx-update
enable_service sw-patch tsconfig
if is_service_enabled sysinv-agent; then
enable_service sysinv
fi
if is_service_enabled sysinv-agent; then
local req_services="key rabbit nova neutron"
for srv in $req_services;do
if ! is_service_enabled "$srv"; then
die $LINENO "$srv should be enabled for SysInv"
fi
done
fi
# Settings for stx-fault ----------
STX_FAULT_NAME=stx-fault