mirror of
https://github.com/akuker/RASCSI.git
synced 2024-12-25 18:32:56 +00:00
Move scsi id reservation management to the backend
This commit is contained in:
parent
e10231c0e7
commit
587e64e17e
@ -5,7 +5,7 @@ After=network.target
|
|||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
Restart=always
|
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
|
# Example: If you want to automatically attach a hard disk at startup, change
|
||||||
# the ExecStart line to:
|
# the ExecStart line to:
|
||||||
# ExecStart=/usr/local/bin/rascsi -ID1 /home/pi/images/harddisk.hda
|
# ExecStart=/usr/local/bin/rascsi -ID1 /home/pi/images/harddisk.hda
|
||||||
|
@ -242,18 +242,6 @@ def sort_and_format_devices(devices):
|
|||||||
return formatted_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):
|
def set_log_level(log_level):
|
||||||
'''Sends a command to the server to change the log level. Takes target log level as an argument.'''
|
'''Sends a command to the server to change the log level. Takes target log level as an argument.'''
|
||||||
command = proto.PbCommand()
|
command = proto.PbCommand()
|
||||||
|
@ -5,9 +5,7 @@ After=network.target
|
|||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
Restart=always
|
Restart=always
|
||||||
ExecStart=/home/pi/RASCSI/src/web/start.sh --reserved_ids=7
|
ExecStart=/home/pi/RASCSI/src/web/start.sh
|
||||||
# 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
|
|
||||||
StandardOutput=syslog
|
StandardOutput=syslog
|
||||||
StandardError=syslog
|
StandardError=syslog
|
||||||
SyslogIdentifier=RASCSIWEB
|
SyslogIdentifier=RASCSIWEB
|
||||||
|
@ -2,22 +2,6 @@
|
|||||||
set -e
|
set -e
|
||||||
# set -x # Uncomment to Debug
|
# 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)
|
cd $(dirname $0)
|
||||||
# verify packages installed
|
# verify packages installed
|
||||||
ERROR=0
|
ERROR=0
|
||||||
@ -72,4 +56,4 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Starting web server..."
|
echo "Starting web server..."
|
||||||
python3 web.py ${RESERVED_IDS}
|
python3 web.py
|
||||||
|
@ -28,7 +28,6 @@ from ractl_cmds import (
|
|||||||
eject_by_id,
|
eject_by_id,
|
||||||
get_valid_scsi_ids,
|
get_valid_scsi_ids,
|
||||||
detach_all,
|
detach_all,
|
||||||
reserve_scsi_ids,
|
|
||||||
get_server_info,
|
get_server_info,
|
||||||
get_network_info,
|
get_network_info,
|
||||||
validate_scsi_id,
|
validate_scsi_id,
|
||||||
@ -432,8 +431,6 @@ def rascsi_restart():
|
|||||||
server_info = get_server_info()
|
server_info = get_server_info()
|
||||||
rascsi_service("restart")
|
rascsi_service("restart")
|
||||||
flash("Restarting RaSCSI Service...")
|
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"))
|
return redirect(url_for("index"))
|
||||||
|
|
||||||
|
|
||||||
@ -578,12 +575,6 @@ if __name__ == "__main__":
|
|||||||
makedirs(app.config["UPLOAD_FOLDER"], exist_ok=True)
|
makedirs(app.config["UPLOAD_FOLDER"], exist_ok=True)
|
||||||
app.config["MAX_CONTENT_LENGTH"] = MAX_FILE_SIZE
|
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
|
# Load the default configuration file, if found
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
default_config_path = Path(base_dir + DEFAULT_CONFIG)
|
default_config_path = Path(base_dir + DEFAULT_CONFIG)
|
||||||
|
Loading…
Reference in New Issue
Block a user