Merge "Add systemd unit for sushy emulator in devstack"
This commit is contained in:
commit
7cfdd9ae57
@ -346,7 +346,7 @@ IRONIC_VPDU_SNMPDRIVER=${IRONIC_VPDU_SNMPDRIVER:-apc_rackpdu}
|
||||
|
||||
# Redfish configs
|
||||
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
|
||||
# (which is required by some vendor drivers), set this
|
||||
@ -811,14 +811,57 @@ function _generate_pdu_ports {
|
||||
}
|
||||
|
||||
function start_redfish_emulator {
|
||||
sudo $gunicorn sushy_tools.emulator.main:app --bind "${HOST_IP}:${IRONIC_REDFISH_EMULATOR_PORT}" \
|
||||
--pid "$IRONIC_REDFISH_EMULATOR_PID_FILE" --daemon
|
||||
$SYSTEMCTL start $IRONIC_REDFISH_EMULATOR_SYSTEMD_SERVICE
|
||||
}
|
||||
|
||||
function stop_redfish_emulator {
|
||||
if [ -f $IRONIC_REDFISH_EMULATOR_PID_FILE ]; then
|
||||
sudo kill `cat $IRONIC_REDFISH_EMULATOR_PID_FILE` || true
|
||||
$SYSTEMCTL stop $IRONIC_REDFISH_EMULATOR_SYSTEMD_SERVICE
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
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 {
|
||||
@ -830,28 +873,7 @@ function setup_redfish {
|
||||
fi
|
||||
|
||||
if [[ "$IRONIC_IS_HARDWARE" == "False" ]]; then
|
||||
|
||||
# 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
|
||||
setup_redfish_emulator
|
||||
fi
|
||||
}
|
||||
|
||||
@ -994,6 +1016,8 @@ function cleanup_ironic {
|
||||
# It's noop if no emulator is running
|
||||
stop_redfish_emulator
|
||||
|
||||
cleanup_redfish_emulator
|
||||
|
||||
# Remove the hook to disable log rotate
|
||||
sudo rm -rf $IRONIC_LIBVIRT_HOOKS_PATH/qemu
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user