From 587e64e17e06b8e2bb3c27f7eba9a374a5f75ad3 Mon Sep 17 00:00:00 2001 From: Daniel Markstedt Date: Sun, 19 Sep 2021 15:57:28 -0700 Subject: [PATCH] Move scsi id reservation management to the backend --- src/raspberrypi/os_integration/rascsi.service | 2 +- src/web/ractl_cmds.py | 12 ------------ src/web/service-infra/rascsi-web.service | 4 +--- src/web/start.sh | 18 +----------------- src/web/web.py | 9 --------- 5 files changed, 3 insertions(+), 42 deletions(-) diff --git a/src/raspberrypi/os_integration/rascsi.service b/src/raspberrypi/os_integration/rascsi.service index 62fe6528..4a36e0c7 100644 --- a/src/raspberrypi/os_integration/rascsi.service +++ b/src/raspberrypi/os_integration/rascsi.service @@ -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 diff --git a/src/web/ractl_cmds.py b/src/web/ractl_cmds.py index 16d787e2..818a34f3 100644 --- a/src/web/ractl_cmds.py +++ b/src/web/ractl_cmds.py @@ -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() diff --git a/src/web/service-infra/rascsi-web.service b/src/web/service-infra/rascsi-web.service index 9d9110de..9c75d28f 100644 --- a/src/web/service-infra/rascsi-web.service +++ b/src/web/service-infra/rascsi-web.service @@ -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 diff --git a/src/web/start.sh b/src/web/start.sh index c1b10a95..de50c04a 100755 --- a/src/web/start.sh +++ b/src/web/start.sh @@ -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 diff --git a/src/web/web.py b/src/web/web.py index ad15b7e4..5a70a0b5 100644 --- a/src/web/web.py +++ b/src/web/web.py @@ -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)