diff --git a/src/web/file_cmds.py b/src/web/file_cmds.py index d774e27b..6671e18b 100644 --- a/src/web/file_cmds.py +++ b/src/web/file_cmds.py @@ -21,7 +21,8 @@ def list_files(): files = [] for f in result.image_files_info.image_files: size_mb = "{:,.1f}".format(f.size / 1024 / 1024) - files.append({"name": f.name, "size": f.size, "size_mb": size_mb}) + dtype = proto.PbDeviceType.Name(f.type) + files.append({"name": f.name, "size": f.size, "size_mb": size_mb, "detected_type": dtype}) return {"status": result.status, "msg": result.msg, "files": files} diff --git a/src/web/ractl_cmds.py b/src/web/ractl_cmds.py index 3e03bbb3..27ec40cc 100644 --- a/src/web/ractl_cmds.py +++ b/src/web/ractl_cmds.py @@ -29,6 +29,19 @@ def get_network_info(): result.ParseFromString(data) ifs = result.network_interfaces_info.name return {"status": result.status, "ifs": ifs} + + +def get_device_types(): + command = proto.PbCommand() + command.operation = proto.PbOperation.DEVICE_TYPES_INFO + + data = send_pb_command(command.SerializeToString()) + result = proto.PbResult() + result.ParseFromString(data) + device_types = [] + for t in result.device_types_info.properties: + device_types.append(proto.PbDeviceType.Name(t.type)) + return {"status": result.status, "device_types": device_types} def validate_scsi_id(scsi_id): @@ -87,7 +100,8 @@ def attach_image(scsi_id, **kwargs): devices.id = int(scsi_id) if "device_type" in kwargs.keys(): - devices.type = proto.PbDeviceType.Value(str(kwargs["device_type"])) + if kwargs["device_type"] not in [None, ""]: + devices.type = proto.PbDeviceType.Value(str(kwargs["device_type"])) if "unit" in kwargs.keys(): devices.unit = kwargs["unit"] if "image" in kwargs.keys(): @@ -110,13 +124,13 @@ def attach_image(scsi_id, **kwargs): if kwargs["interfaces"] not in [None, ""]: devices.params["interfaces"] = kwargs["interfaces"] if "vendor" in kwargs.keys(): - if kwargs["vendor"] not in [None, ""]: + if kwargs["vendor"] != None: devices.vendor = kwargs["vendor"] if "product" in kwargs.keys(): - if kwargs["product"] not in [None, ""]: + if kwargs["product"] != None: devices.product = kwargs["product"] if "revision" in kwargs.keys(): - if kwargs["revision"] not in [None, ""]: + if kwargs["revision"] != None: devices.revision = kwargs["revision"] if "block_size" in kwargs.keys(): if kwargs["block_size"] not in [None, ""]: @@ -187,6 +201,7 @@ def list_devices(scsi_id=None): device_list = [] n = 0 + # Return an empty list if no devices are attached if len(result.device_info.devices) == 0: return {"status": False, "device_list": []} diff --git a/src/web/settings.py b/src/web/settings.py index 4bcc4b2b..2075ba7d 100644 --- a/src/web/settings.py +++ b/src/web/settings.py @@ -7,11 +7,14 @@ DEFAULT_CONFIG = "default.json" MAX_FILE_SIZE = getenv("MAX_FILE_SIZE", 1024 * 1024 * 1024 * 4) # 4gb HARDDRIVE_FILE_SUFFIX = ("hda", "hdn", "hdi", "nhd", "hdf", "hds") -CDROM_FILE_SUFFIX = ("iso", "cdr", "toast", "img") +SASI_FILE_SUFFIX = ("hdf",) REMOVABLE_FILE_SUFFIX = ("hdr",) +CDROM_FILE_SUFFIX = ("iso",) +MO_FILE_SUFFIX = ("mos",) ARCHIVE_FILE_SUFFIX = ("zip",) -VALID_FILE_SUFFIX = HARDDRIVE_FILE_SUFFIX + REMOVABLE_FILE_SUFFIX + \ - CDROM_FILE_SUFFIX + ARCHIVE_FILE_SUFFIX +VALID_FILE_SUFFIX = HARDDRIVE_FILE_SUFFIX + SASI_FILE_SUFFIX + \ + REMOVABLE_FILE_SUFFIX + CDROM_FILE_SUFFIX + \ + MO_FILE_SUFFIX + ARCHIVE_FILE_SUFFIX # File containing canonical drive properties DRIVE_PROPERTIES_FILE = home_dir + "/drive_properties.json" diff --git a/src/web/templates/index.html b/src/web/templates/index.html index ebc5f45a..49ade5b3 100644 --- a/src/web/templates/index.html +++ b/src/web/templates/index.html @@ -79,9 +79,11 @@ {% endfor %} +
Types: SAHD = SASI HDD | SCHD = SCSI HDD | SCRM = Removable | SCMO = Magneto-Optical | SCCD = CD-ROM | SCBR = Host Bridge | SCDP = DaynaPORT
+ |