From 6ca140d842391620da81657a9d6ac067094c5047 Mon Sep 17 00:00:00 2001 From: Daniel Markstedt Date: Sun, 15 Jan 2023 07:38:41 -0800 Subject: [PATCH] Streamline the create iso workflow, removing the attach step (#1069) --- python/web/src/static/themes/modern/style.css | 3 +- python/web/src/templates/index.html | 32 +++++-------------- python/web/src/web.py | 23 +------------ python/web/tests/api/test_files.py | 17 ++-------- 4 files changed, 12 insertions(+), 63 deletions(-) diff --git a/python/web/src/static/themes/modern/style.css b/python/web/src/static/themes/modern/style.css index 741b9fd4..c460d24d 100644 --- a/python/web/src/static/themes/modern/style.css +++ b/python/web/src/static/themes/modern/style.css @@ -741,8 +741,7 @@ section#files p { } section#files table#images form.file-attach input[type="submit"], - section#attach-devices form.device-attach input[type="submit"], - section#create-iso form.iso-attach input[type="submit"] { + section#attach-devices form.device-attach input[type="submit"] { background: #efefef url("icons/file-device-attach.svg") no-repeat 0.5rem center; background-size: 1rem; padding-left: 2rem; diff --git a/python/web/src/templates/index.html b/python/web/src/templates/index.html index 429240ff..01f5511f 100644 --- a/python/web/src/templates/index.html +++ b/python/web/src/templates/index.html @@ -385,7 +385,7 @@
- {{ _("Create CD-ROM Image With File") }} + {{ _("Create CD-ROM Image") }}
  • {{ _("HFS is for Mac OS, Joliet for Windows, and Rock Ridge for POSIX.") }}
  • @@ -394,8 +394,8 @@
-
- + + - - - +
-
- + + - - - +
@@ -476,7 +460,7 @@
- {{ _("Create Empty Disk Image File") }} + {{ _("Create Empty Disk Image") }}
  • {{ _("Please refer to wiki documentation to learn more about the supported image file types.", url="https://github.com/PiSCSI/piscsi/wiki/Supported-Device-Types#image-types") }}
  • diff --git a/python/web/src/web.py b/python/web/src/web.py index ac256897..646f3dc9 100644 --- a/python/web/src/web.py +++ b/python/web/src/web.py @@ -892,7 +892,6 @@ def download_to_iso(): """ Downloads a file and creates a CD-ROM image with the specified file system and the file """ - scsi_id = request.form.get("scsi_id") url = request.form.get("url") iso_type = request.form.get("type") local_file = request.form.get("file") @@ -933,31 +932,11 @@ def download_to_iso(): ), ) - process_attach = piscsi_cmd.attach_device( - scsi_id, - device_type="SCCD", - params={"file": process["file_name"]}, - ) - process_attach = ReturnCodeMapper.add_msg(process_attach) - if process_attach["status"]: - return response( - message=_( - "CD-ROM image %(file_name)s with type %(iso_type)s was created " - "and attached to SCSI ID %(id_number)s", - file_name=process["file_name"], - iso_type=iso_type, - id_number=scsi_id, - ), - ) - return response( - error=True, message=_( - "CD-ROM image %(file_name)s with type %(iso_type)s was created " - "but could not be attached: %(error)s", + "CD-ROM image %(file_name)s with type %(iso_type)s was created.", file_name=process["file_name"], iso_type=iso_type, - error=process_attach["msg"], ), ) diff --git a/python/web/tests/api/test_files.py b/python/web/tests/api/test_files.py index 1fc4e919..fdb15243 100644 --- a/python/web/tests/api/test_files.py +++ b/python/web/tests/api/test_files.py @@ -3,7 +3,6 @@ import uuid import os from conftest import ( - SCSI_ID, FILE_SIZE_1_MIB, STATUS_SUCCESS, ) @@ -333,8 +332,6 @@ def test_create_iso_from_url( httpserver, http_client, list_files, - list_attached_images, - detach_devices, delete_file, ): test_file_name = str(uuid.uuid4()) @@ -355,7 +352,6 @@ def test_create_iso_from_url( response = http_client.post( "/files/create_iso", data={ - "scsi_id": SCSI_ID, "type": ISO_TYPE, "url": url, }, @@ -366,16 +362,13 @@ def test_create_iso_from_url( assert response.status_code == 200 assert response_data["status"] == STATUS_SUCCESS assert iso_file_name in list_files() - assert iso_file_name in list_attached_images() assert ( response_data["messages"][0]["message"] - == f"CD-ROM image {iso_file_name} with type {ISO_TYPE} was created " - f"and attached to SCSI ID {SCSI_ID}" + == f"CD-ROM image {iso_file_name} with type {ISO_TYPE} was created." ) # Cleanup - detach_devices() delete_file(iso_file_name) @@ -384,8 +377,6 @@ def test_create_iso_from_local_file( http_client, create_test_image, list_files, - list_attached_images, - detach_devices, delete_file, ): test_file_name = create_test_image() @@ -396,7 +387,6 @@ def test_create_iso_from_local_file( response = http_client.post( "/files/create_iso", data={ - "scsi_id": SCSI_ID, "type": ISO_TYPE, "file": test_file_name, }, @@ -407,16 +397,13 @@ def test_create_iso_from_local_file( assert response.status_code == 200 assert response_data["status"] == STATUS_SUCCESS assert iso_file_name in list_files() - assert iso_file_name in list_attached_images() assert ( response_data["messages"][0]["message"] - == f"CD-ROM image {iso_file_name} with type {ISO_TYPE} was created " - f"and attached to SCSI ID {SCSI_ID}" + == f"CD-ROM image {iso_file_name} with type {ISO_TYPE} was created." ) # Cleanup - detach_devices() delete_file(iso_file_name)