Move scsi id reservation management to the backend

This commit is contained in:
Daniel Markstedt 2021-09-19 15:57:28 -07:00
parent e10231c0e7
commit 587e64e17e
5 changed files with 3 additions and 42 deletions

View File

@ -5,7 +5,7 @@ After=network.target
[Service]
Type=simple
Restart=always
ExecStart=/usr/local/bin/rascsi
ExecStart=/usr/local/bin/rascsi -r 7
# Example: If you want to automatically attach a hard disk at startup, change
# the ExecStart line to:
# ExecStart=/usr/local/bin/rascsi -ID1 /home/pi/images/harddisk.hda

View File

@ -242,18 +242,6 @@ def sort_and_format_devices(devices):
return formatted_devices
def reserve_scsi_ids(reserved_scsi_ids):
'''Sends a command to the server to reserve SCSI IDs. Takes a list of strings as argument.'''
command = proto.PbCommand()
command.operation = proto.PbOperation.RESERVE
command.params["ids"] = ",".join(reserved_scsi_ids)
data = send_pb_command(command.SerializeToString())
result = proto.PbResult()
result.ParseFromString(data)
return {"status": result.status, "msg": result.msg}
def set_log_level(log_level):
'''Sends a command to the server to change the log level. Takes target log level as an argument.'''
command = proto.PbCommand()

View File

@ -5,9 +5,7 @@ After=network.target
[Service]
Type=simple
Restart=always
ExecStart=/home/pi/RASCSI/src/web/start.sh --reserved_ids=7
# Use the --reserved_ids argument to define an id or range of ids that will be unavailable for attaching devices.
# The default is 7 for Macintosh. Ex. to reserve IDs 0, 1, and 7 do: --reserved_ids=017
ExecStart=/home/pi/RASCSI/src/web/start.sh
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=RASCSIWEB

View File

@ -2,22 +2,6 @@
set -e
# set -x # Uncomment to Debug
# parse arguments
while [ "$1" != "" ]; do
PARAM=`echo $1 | awk -F= '{print $1}'`
VALUE=`echo $1 | awk -F= '{print $2}'`
case $PARAM in
-r | --reserved_ids)
RESERVED_IDS=$VALUE
;;
*)
echo "ERROR: unknown parameter \"$PARAM\""
exit 1
;;
esac
shift
done
cd $(dirname $0)
# verify packages installed
ERROR=0
@ -72,4 +56,4 @@ else
fi
echo "Starting web server..."
python3 web.py ${RESERVED_IDS}
python3 web.py

View File

@ -28,7 +28,6 @@ from ractl_cmds import (
eject_by_id,
get_valid_scsi_ids,
detach_all,
reserve_scsi_ids,
get_server_info,
get_network_info,
validate_scsi_id,
@ -432,8 +431,6 @@ def rascsi_restart():
server_info = get_server_info()
rascsi_service("restart")
flash("Restarting RaSCSI Service...")
# Need to turn this into a list of strings from a list of ints
reserve_scsi_ids([str(e) for e in server_info["reserved_ids"]])
return redirect(url_for("index"))
@ -578,12 +575,6 @@ if __name__ == "__main__":
makedirs(app.config["UPLOAD_FOLDER"], exist_ok=True)
app.config["MAX_CONTENT_LENGTH"] = MAX_FILE_SIZE
from sys import argv
if len(argv) >= 2:
# Reserve SCSI IDs on the backend side to prevent use
# Expecting argv as a string of digits such as '017'
reserve_scsi_ids(list(argv[1]))
# Load the default configuration file, if found
from pathlib import Path
default_config_path = Path(base_dir + DEFAULT_CONFIG)