mirror of
https://github.com/akuker/RASCSI.git
synced 2024-11-22 01:31:25 +00:00
Streamline the create iso workflow, removing the attach step (#1069)
This commit is contained in:
parent
649655ba40
commit
6ca140d842
@ -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;
|
||||
|
@ -385,7 +385,7 @@
|
||||
<section id="create-iso">
|
||||
<details>
|
||||
<summary class="heading">
|
||||
{{ _("Create CD-ROM Image With File") }}
|
||||
{{ _("Create CD-ROM Image") }}
|
||||
</summary>
|
||||
<ul>
|
||||
<li>{{ _("HFS is for Mac OS, Joliet for Windows, and Rock Ridge for POSIX.") }}</li>
|
||||
@ -394,8 +394,8 @@
|
||||
</details>
|
||||
|
||||
<div>
|
||||
<form action="/files/create_iso" method="post" class="iso-attach">
|
||||
<label for="iso_url">{{ _("Create ISO from URL:") }}</label>
|
||||
<form action="/files/create_iso" method="post">
|
||||
<label for="iso_url">{{ _("Download file from URL:") }}</label>
|
||||
<input name="url" id="iso_url" required="" type="url">
|
||||
<label for="iso_url_type">{{ _("Type:") }}</label>
|
||||
<select name="type" id="iso_url_type">
|
||||
@ -418,20 +418,12 @@
|
||||
Rock Ridge
|
||||
</option>
|
||||
</select>
|
||||
<label for="iso_url_scsi_id">{{ _("ID") }}</label>
|
||||
<select name="scsi_id" id="iso_url_scsi_id">
|
||||
{% for id in scsi_ids["valid_ids"] %}
|
||||
<option value="{{ id }}"{% if id == scsi_ids["recommended_id"] %} selected{% endif %}>
|
||||
{{ id }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<input type="submit" value="{{ _("Create and Attach") }}" onclick="processNotify('{{ _("Downloading file and generating CD-ROM image...") }}')">
|
||||
<input type="submit" value="{{ _("Create") }}" onclick="processNotify('{{ _("Downloading file and generating CD-ROM image...") }}')">
|
||||
</form>
|
||||
</div>
|
||||
<div>
|
||||
<form action="/files/create_iso" method="post" class="iso-attach">
|
||||
<label for="iso_file">{{ _("Create ISO from local file:") }}</label>
|
||||
<form action="/files/create_iso" method="post">
|
||||
<label for="iso_file">{{ _("Use local file:") }}</label>
|
||||
<select name="file" id="iso_file">
|
||||
{% for f in files|sort(attribute='name') %}
|
||||
<option value="{{ f["name"] }}">{{ f["name"].replace(env["image_dir"], '') }}</option>
|
||||
@ -458,15 +450,7 @@
|
||||
Rock Ridge
|
||||
</option>
|
||||
</select>
|
||||
<label for="iso_file_scsi_id">{{ _("ID") }}</label>
|
||||
<select name="scsi_id" id="iso_file_scsi_id">
|
||||
{% for id in scsi_ids["valid_ids"] %}
|
||||
<option value="{{ id }}"{% if id == scsi_ids["recommended_id"] %} selected{% endif %}>
|
||||
{{ id }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<input type="submit" value="{{ _("Create and Attach") }}" onclick="processNotify('{{ _("Generating CD-ROM image...") }}')">
|
||||
<input type="submit" value="{{ _("Create") }}" onclick="processNotify('{{ _("Generating CD-ROM image...") }}')">
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
@ -476,7 +460,7 @@
|
||||
<section id="create-image">
|
||||
<details>
|
||||
<summary class="heading">
|
||||
{{ _("Create Empty Disk Image File") }}
|
||||
{{ _("Create Empty Disk Image") }}
|
||||
</summary>
|
||||
<ul>
|
||||
<li>{{ _("Please refer to <a href=\"%(url)s\" target=\"_blank\">wiki documentation</a> to learn more about the supported image file types.", url="https://github.com/PiSCSI/piscsi/wiki/Supported-Device-Types#image-types") }}</li>
|
||||
|
@ -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"],
|
||||
),
|
||||
)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user