mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +00:00
An ISO or a disk image on a web server had to be downloaded by hand and uploaded, or copied onto the host. A pool of files (dir, fs, netfs) now has "Download from a URL" for superusers: a volume.fetch job streams the file (http or https, its size told by the server and within the pool's free space) into a new volume through libvirt, as an upload is written, on any connection type; the job panel shows its progress and it can be cancelled. libvirt reads the file's format (qcow2, raw) when the pool is refreshed. A cancel, a failure or a crash deletes what it wrote; an address that fails says why.
111 lines
8.1 KiB
HTML
111 lines
8.1 KiB
HTML
{% load i18n %}
|
|
{% load operations %}
|
|
{% load django_bootstrap5 %}
|
|
{% load bootstrap_icons %}
|
|
{% if request.user.is_superuser %}
|
|
{% if state != 0 %}
|
|
{% if pool == "iso" %}
|
|
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#IsoUpload">
|
|
<span aria-hidden="true">{% bs_icon 'upload' %}</span> {% trans "Upload ISO" %}
|
|
</button>
|
|
|
|
<div class="modal fade" id="IsoUpload" tabindex="-1" role="dialog" aria-labelledby="IsoUploadLabel" aria-hidden="true">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="IsoUploadLabel">{% trans "Upload ISO Image" %}</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="{% trans "Close" %}"></button>
|
|
</div>
|
|
<form id="isoUploadForm" action="{% url 'storage' compute.id pool %}" enctype="multipart/form-data" method="post" aria-label="{% trans "Upload iso form" %}"
|
|
data-no-file="{% trans 'Please select a file to upload.' %}" data-not-iso="{% trans 'Only .iso files can be uploaded.' %}"
|
|
data-empty="{% trans 'The selected file is empty.' %}" data-starting="{% trans 'Starting upload...' %}"
|
|
data-uploading="{% trans 'Uploading; the job panel shows its progress. Stay on this page until it ends.' %}"
|
|
data-retrying="{% trans 'Retrying upload...' %}" data-failed="{% trans 'An error occurred during upload.' %}">{% csrf_token %}
|
|
<div class="modal-body">
|
|
<label for="id_file" class="form-label">{% trans "ISO file" %}</label>
|
|
<input type="file" name="file" id="id_file" class="form-control" accept=".iso" required aria-describedby="id_file_help">
|
|
<div class="form-text" id="id_file_help">{% trans "The browser sends it: keep the page open until the upload ends." %}</div>
|
|
<div id="upload-status" class="d-none align-items-center gap-2 text-primary mt-3" role="status" aria-live="polite">
|
|
<span class="spinner-border spinner-border-sm" aria-hidden="true"></span>
|
|
<span id="upload-status-text">{% trans "Starting upload..." %}</span>
|
|
</div>
|
|
<div id="upload-error-message" class="alert alert-danger mt-3 d-none" role="alert"></div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<input type="hidden" name="iso_upload" value="true">
|
|
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">{% trans "Cancel" %}</button>
|
|
<button type="submit" class="btn btn-primary">{% trans "Upload" %}</button>
|
|
</div>
|
|
</form>
|
|
|
|
</div> <!-- /.modal-content -->
|
|
</div> <!-- /.modal-dialog -->
|
|
</div> <!-- /.modal -->
|
|
{% else %}
|
|
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#AddImage">
|
|
<span aria-hidden="true">{% bs_icon 'plus-lg' %}</span> {% trans "New volume" %}
|
|
</button>
|
|
|
|
<div class="modal fade" id="AddImage" tabindex="-1" role="dialog" aria-labelledby="AddImageLabel" aria-hidden="true"
|
|
{% if form.errors %}data-open{% endif %}>
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="AddImageLabel">{% trans "New volume" %}</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="{% trans "Close" %}"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<form id="create-volume" method="post" aria-label="{% trans "Create volume to storage form" %}">
|
|
{% csrf_token %}
|
|
<div class="row">
|
|
<div class="col-12">{% bootstrap_field form.name %}</div>
|
|
<div class="col-sm-6">{% bootstrap_field form.size %}</div>
|
|
<div class="col-sm-6">{% bootstrap_field form.format %}</div>
|
|
<div class="col-12">{% bootstrap_field form.meta_prealloc %}</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">{% trans "Cancel" %}</button>
|
|
<button type="submit" form="create-volume" class="btn btn-primary" name="create_volume">{% trans "Create" %}</button>
|
|
</div>
|
|
</div> <!-- /.modal-content -->
|
|
</div> <!-- /.modal-dialog -->
|
|
</div> <!-- /.modal -->
|
|
{% endif %}
|
|
{% if type == "dir" or type == "fs" or type == "netfs" %}
|
|
{# the worker downloads it into the pool; the job panel shows its progress #}
|
|
<button type="button" class="btn btn-outline-primary" data-bs-toggle="modal" data-bs-target="#FetchVolume">
|
|
<span aria-hidden="true">{% bs_icon 'download' %}</span> {% trans "Download from a URL" %}
|
|
</button>
|
|
<div class="modal fade" id="FetchVolume" tabindex="-1" aria-labelledby="FetchVolumeLabel" aria-hidden="true">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="FetchVolumeLabel">{% trans "Download from a URL" %}</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="{% trans "Close" %}"></button>
|
|
</div>
|
|
<form method="post" aria-labelledby="FetchVolumeLabel">{% csrf_token %}{% submission_key %}
|
|
<div class="modal-body">
|
|
<div class="mb-3">
|
|
<label class="form-label" for="fetch-url">{% trans "Address" %}</label>
|
|
<input type="url" class="form-control" name="url" id="fetch-url" required placeholder="https://" aria-describedby="fetch-url-help">
|
|
<div class="form-text" id="fetch-url-help">{% trans "An ISO or a disk image (qcow2, raw) at an http or https address that tells its size. The panel's host downloads it." %}</div>
|
|
</div>
|
|
<div>
|
|
<label class="form-label" for="fetch-name">{% trans "Volume name" %}</label>
|
|
<input type="text" class="form-control" name="name" id="fetch-name" pattern="[a-zA-Z0-9\.\-_]+" aria-describedby="fetch-name-help">
|
|
<div class="form-text" id="fetch-name-help">{% trans "Empty: the file's name in the address. An ISO keeps its .iso ending, or VMs do not list it as media." %}</div>
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">{% trans "Cancel" %}</button>
|
|
<button type="submit" class="btn btn-primary" name="fetch_volume" value="1">{% trans "Download" %}</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endif %}
|