Merge "Add systemd unit for sushy emulator in devstack"

This commit is contained in:
Zuul
2019-04-10 05:45:48 +00:00
committed by Gerrit Code Review

View File

@@ -346,7 +346,7 @@ IRONIC_VPDU_SNMPDRIVER=${IRONIC_VPDU_SNMPDRIVER:-apc_rackpdu}
# Redfish configs # Redfish configs
IRONIC_REDFISH_EMULATOR_PORT=${IRONIC_REDFISH_EMULATOR_PORT:-9132} IRONIC_REDFISH_EMULATOR_PORT=${IRONIC_REDFISH_EMULATOR_PORT:-9132}
IRONIC_REDFISH_EMULATOR_PID_FILE=${IRONIC_REDFISH_EMULATOR_PID_FILE:-/var/run/redfish-emulator.pid} IRONIC_REDFISH_EMULATOR_SYSTEMD_SERVICE="devstack@redfish-emulator.service"
# To explicitly enable configuration of Glance with Swift # To explicitly enable configuration of Glance with Swift
# (which is required by some vendor drivers), set this # (which is required by some vendor drivers), set this
@@ -811,14 +811,57 @@ function _generate_pdu_ports {
} }
function start_redfish_emulator { function start_redfish_emulator {
sudo $gunicorn sushy_tools.emulator.main:app --bind "${HOST_IP}:${IRONIC_REDFISH_EMULATOR_PORT}" \ $SYSTEMCTL start $IRONIC_REDFISH_EMULATOR_SYSTEMD_SERVICE
--pid "$IRONIC_REDFISH_EMULATOR_PID_FILE" --daemon
} }
function stop_redfish_emulator { function stop_redfish_emulator {
if [ -f $IRONIC_REDFISH_EMULATOR_PID_FILE ]; then $SYSTEMCTL stop $IRONIC_REDFISH_EMULATOR_SYSTEMD_SERVICE
sudo kill `cat $IRONIC_REDFISH_EMULATOR_PID_FILE` || true }
function cleanup_redfish_emulator {
stop_redfish_emulator
$SYSTEMCTL disable $IRONIC_REDFISH_EMULATOR_SYSTEMD_SERVICE
local unitfile="$SYSTEMD_DIR/$IRONIC_REDFISH_EMULATOR_SYSTEMD_SERVICE"
sudo rm -f $unitfile
$SYSTEMCTL daemon-reload
}
function setup_redfish_emulator {
# TODO(lucasagomes): Use Apache WSGI instead of gunicorn
gunicorn=gunicorn
if python3_enabled; then
gunicorn=${gunicorn}3
fi fi
if is_ubuntu; then
install_package $gunicorn
else
pip_install_gr "gunicorn"
fi
if use_library_from_git "sushy-tools"; then
git_clone_by_name "sushy-tools"
setup_dev_lib "sushy-tools"
else
pip_install "sushy-tools"
fi
local cmd
cmd=$(which $gunicorn)
cmd+=" sushy_tools.emulator.main:app"
cmd+=" --bind ${HOST_IP}:${IRONIC_REDFISH_EMULATOR_PORT}"
cmd+=" --env FLASK_DEBUG=1"
write_user_unit_file $IRONIC_REDFISH_EMULATOR_SYSTEMD_SERVICE "$cmd" "" "root"
$SYSTEMCTL enable $IRONIC_REDFISH_EMULATOR_SYSTEMD_SERVICE
start_redfish_emulator
} }
function setup_redfish { function setup_redfish {
@@ -830,28 +873,7 @@ function setup_redfish {
fi fi
if [[ "$IRONIC_IS_HARDWARE" == "False" ]]; then if [[ "$IRONIC_IS_HARDWARE" == "False" ]]; then
setup_redfish_emulator
# TODO(lucasagomes): Use Apache WSGI instead of gunicorn
gunicorn=gunicorn
if python3_enabled; then
gunicorn=${gunicorn}3
fi
if is_ubuntu; then
install_package $gunicorn
else
pip_install_gr "gunicorn"
fi
if use_library_from_git "sushy-tools"; then
git_clone_by_name "sushy-tools"
setup_dev_lib "sushy-tools"
else
pip_install "sushy-tools"
fi
start_redfish_emulator
fi fi
} }
@@ -994,6 +1016,8 @@ function cleanup_ironic {
# It's noop if no emulator is running # It's noop if no emulator is running
stop_redfish_emulator stop_redfish_emulator
cleanup_redfish_emulator
# Remove the hook to disable log rotate # Remove the hook to disable log rotate
sudo rm -rf $IRONIC_LIBVIRT_HOOKS_PATH/qemu sudo rm -rf $IRONIC_LIBVIRT_HOOKS_PATH/qemu
} }