diff --git a/python/common/src/rascsi/common_settings.py b/python/common/src/rascsi/common_settings.py index 2a975c1a..84b5c2a1 100644 --- a/python/common/src/rascsi/common_settings.py +++ b/python/common/src/rascsi/common_settings.py @@ -8,7 +8,7 @@ WORK_DIR = getcwd() REMOVABLE_DEVICE_TYPES = ("SCCD", "SCRM", "SCMO") NETWORK_DEVICE_TYPES = ("SCDP", "SCBR") -SUPPORT_DEVICE_TYPES = ("SCHS", ) +SUPPORT_DEVICE_TYPES = ("SCLP", "SCHS") # There may be a more elegant way to get the HOME dir of the user that installed RaSCSI HOME_DIR = "/".join(WORK_DIR.split("/")[0:3]) diff --git a/python/common/src/rascsi/file_cmds.py b/python/common/src/rascsi/file_cmds.py index 009edfff..b3e493ec 100644 --- a/python/common/src/rascsi/file_cmds.py +++ b/python/common/src/rascsi/file_cmds.py @@ -450,17 +450,16 @@ class FileCmds: for row in config["devices"]: kwargs = { "device_type": row["device_type"], - "image": row["image"], "unit": int(row["unit"]), "vendor": row["vendor"], "product": row["product"], "revision": row["revision"], "block_size": row["block_size"], + "params": dict(row["params"]), } - params = dict(row["params"]) - for param in params.keys(): - kwargs[param] = params[param] - self.ractl.attach_image(row["id"], **kwargs) + if row["image"]: + kwargs["params"]["file"] = row["image"] + self.ractl.attach_device(row["id"], **kwargs) # The config file format in RaSCSI 21.10 is using a list data type at the top level. # If future config file formats return to the list data type, # introduce more sophisticated format detection logic here. @@ -470,17 +469,17 @@ class FileCmds: kwargs = { "device_type": row["device_type"], "image": row["image"], - # "un" for backwards compatibility "unit": int(row["un"]), "vendor": row["vendor"], "product": row["product"], "revision": row["revision"], "block_size": row["block_size"], + "params": dict(row["params"]), } - params = dict(row["params"]) - for param in params.keys(): - kwargs[param] = params[param] - self.ractl.attach_image(row["id"], **kwargs) + if row["image"]: + kwargs["params"]["file"] = row["image"] + self.ractl.attach_device(row["id"], **kwargs) + logging.warning("%s is in an obsolete config file format", file_name) else: return {"status": False, "return_code": ReturnCodes.READCONFIG_INVALID_CONFIG_FILE_FORMAT} diff --git a/python/common/src/rascsi/ractl_cmds.py b/python/common/src/rascsi/ractl_cmds.py index 2bba4030..5fcbc723 100644 --- a/python/common/src/rascsi/ractl_cmds.py +++ b/python/common/src/rascsi/ractl_cmds.py @@ -125,7 +125,8 @@ class RaCtlCmds: Sends a DEVICE_TYPES_INFO command to the server. Returns a dict with: - (bool) status - - (list) of (str) device_types (device types that RaSCSI supports, ex. SCHD, SCCD, etc) + - (dict) device_types, where keys are the four letter device type acronym, + and the value is a (dict) of supported parameters and their default values. """ command = proto.PbCommand() command.operation = proto.PbOperation.DEVICE_TYPES_INFO @@ -135,9 +136,13 @@ class RaCtlCmds: data = self.sock_cmd.send_pb_command(command.SerializeToString()) result = proto.PbResult() result.ParseFromString(data) - device_types = [] - for prop in result.device_types_info.properties: - device_types.append(proto.PbDeviceType.Name(prop.type)) + device_types = {} + import logging + for device in result.device_types_info.properties: + params = {} + for key, value in device.properties.default_params.items(): + params[key] = value + device_types[proto.PbDeviceType.Name(device.type)] = params return {"status": result.status, "device_types": device_types} def get_image_files_info(self): @@ -167,7 +172,7 @@ class RaCtlCmds: "scan_depth": scan_depth, } - def attach_image(self, scsi_id, **kwargs): + def attach_device(self, scsi_id, **kwargs): """ Takes (int) scsi_id and kwargs containing 0 or more device properties @@ -185,14 +190,15 @@ class RaCtlCmds: devices.id = int(scsi_id) if "device_type" in kwargs.keys(): - if kwargs["device_type"] not in [None, ""]: + if kwargs["device_type"]: devices.type = proto.PbDeviceType.Value(str(kwargs["device_type"])) if "unit" in kwargs.keys(): - if kwargs["unit"] not in [None, ""]: + if kwargs["unit"]: devices.unit = kwargs["unit"] - if "image" in kwargs.keys(): - if kwargs["image"] not in [None, ""]: - devices.params["file"] = kwargs["image"] + if "params" in kwargs.keys(): + if isinstance(kwargs["params"], dict): + for param in kwargs["params"]: + devices.params[param] = kwargs["params"][param] # Handling the inserting of media into an attached removable type device device_type = kwargs.get("device_type", None) @@ -214,23 +220,21 @@ class RaCtlCmds: "parameters": parameters, } command.operation = proto.PbOperation.INSERT + # Handling attaching a new device else: command.operation = proto.PbOperation.ATTACH - if "interfaces" in kwargs.keys(): - if kwargs["interfaces"] not in [None, ""]: - devices.params["interfaces"] = kwargs["interfaces"] if "vendor" in kwargs.keys(): - if kwargs["vendor"] is not None: + if kwargs["vendor"]: devices.vendor = kwargs["vendor"] if "product" in kwargs.keys(): - if kwargs["product"] is not None: + if kwargs["product"]: devices.product = kwargs["product"] if "revision" in kwargs.keys(): - if kwargs["revision"] is not None: + if kwargs["revision"]: devices.revision = kwargs["revision"] if "block_size" in kwargs.keys(): - if kwargs["block_size"] not in [None, ""]: + if kwargs["block_size"]: devices.block_size = int(kwargs["block_size"]) command.devices.append(devices) diff --git a/python/oled/src/rascsi_oled_monitor.py b/python/oled/src/rascsi_oled_monitor.py index 7ecd750a..d6ede5c1 100755 --- a/python/oled/src/rascsi_oled_monitor.py +++ b/python/oled/src/rascsi_oled_monitor.py @@ -188,9 +188,11 @@ def formatted_output(): else: output.append(f"{line['id']} {line['device_type'][2:4]} {line['status']}") # Special handling of devices that don't use image files - elif line["device_type"] in (NETWORK_DEVICE_TYPES + SUPPORT_DEVICE_TYPES): + elif line["device_type"] in (NETWORK_DEVICE_TYPES): output.append(f"{line['id']} {line['device_type'][2:4]} {line['vendor']} " f"{line['product']}") + elif line["device_type"] in (SUPPORT_DEVICE_TYPES): + output.append(f"{line['id']} {line['device_type'][2:4]} {line['product']}") # Print only the Vendor/Product info if it's not generic RaSCSI elif line["vendor"] not in "RaSCSI": output.append(f"{line['id']} {line['device_type'][2:4]} {line['file']} " diff --git a/python/web/src/device_utils.py b/python/web/src/device_utils.py index 02711483..53ca9b31 100644 --- a/python/web/src/device_utils.py +++ b/python/web/src/device_utils.py @@ -68,13 +68,15 @@ def extend_device_names(device_types): elif device_type == "SCMO": device_name = _("Magneto-Optical") elif device_type == "SCCD": - device_name = _("CD-ROM / DVD") + device_name = _("CD / DVD") elif device_type == "SCBR": device_name = _("X68000 Host Bridge") elif device_type == "SCDP": device_name = _("DaynaPORT SCSI/Link") + elif device_type == "SCLP": + device_name = _("Printer") elif device_type == "SCHS": - device_name = _("Host Service") + device_name = _("Host Services") else: device_name = _("Unknown Device") mapped_device_types[device_type] = device_name diff --git a/python/web/src/templates/index.html b/python/web/src/templates/index.html index 200abe91..0716580e 100644 --- a/python/web/src/templates/index.html +++ b/python/web/src/templates/index.html @@ -316,17 +316,6 @@
- - - - - + + + + + - {% for type in SUPPORT_DEVICE_TYPES %} - - {% endfor %} - + + {% for key, value in device_params[type].items() %} + + {% if value.isnumeric() %} + + {% else %} + + {% endif %} + {% endfor %}