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


-

Image File Management

+ +

Valid Image Files

@@ -98,7 +100,7 @@ -
+
@@ -107,6 +109,16 @@ {% endfor %} + {% if file["detected_type"] != "UNDEFINED" %} + {{file["detected_type"]}} + {% else %} + + {% endif %}
@@ -162,6 +174,7 @@

Upload File

Uploads file to {{base_dir}}. The largest file size accepted is {{max_file_size}} MB. Zip files will be unzipped.

+

For unrecognized file types, try renaming hard drive images to '.hds' and CD-ROM images to '.iso' before uploading.

@@ -233,10 +246,7 @@ diff --git a/src/web/web.py b/src/web/web.py index bc84828f..b5796ce5 100644 --- a/src/web/web.py +++ b/src/web/web.py @@ -42,6 +42,7 @@ from ractl_cmds import ( detach_all, get_server_info, get_network_info, + get_device_types, validate_scsi_id, set_log_level, ) @@ -55,6 +56,7 @@ def index(): server_info = get_server_info() disk = disk_space() devices = list_devices() + device_types=get_device_types() files=list_files() config_files=list_config_files() @@ -78,6 +80,7 @@ def index(): running_env=running_env(), server_info=server_info, netinfo=get_network_info(), + device_types=device_types["device_types"], free_disk=int(disk["free"] / 1024 / 1024), valid_file_suffix="."+", .".join(VALID_FILE_SUFFIX), removable_device_types=REMOVABLE_DEVICE_TYPES, @@ -319,6 +322,7 @@ def attach(): file_name = request.form.get("file_name") file_size = request.form.get("file_size") scsi_id = request.form.get("scsi_id") + device_type = request.form.get("type") validate = validate_scsi_id(scsi_id) if validate["status"] == False: @@ -327,14 +331,8 @@ def attach(): kwargs = {"image": file_name} - # Validate image type by file name suffix - # Supplementing file ending based image type detection on the backend side - if file_name.lower().endswith(CDROM_FILE_SUFFIX): - kwargs["device_type"] = "SCCD" - elif file_name.lower().endswith(REMOVABLE_FILE_SUFFIX): - kwargs["device_type"] = "SCRM" - else: - kwargs["device_type"] = "SCHD" + if device_type != "": + kwargs["device_type"] = device_type # Attempt to load the device properties file: # same base path but PROPERTIES_SUFFIX instead of the original suffix.