diff --git a/storages/templates/storage.html b/storages/templates/storage.html index 3c50e93..4a02ae5 100644 --- a/storages/templates/storage.html +++ b/storages/templates/storage.html @@ -6,220 +6,223 @@ {% endblock %} {% block content %} - -
-
- {% include 'create_stg_vol_block.html' %} -

{% trans "Storage:" %} {{ pool }}

- -
+ +
+
+ {% include 'create_stg_vol_block.html' %} +

{% trans "Storage:" %} {{ pool }}

+ +
+
+ + +{% include 'errors_block.html' %} +{% include 'messages_block.html' %} + +
+
+

{% trans "Pool name:" %}

+

{% trans "Pool type:" %}

+

{% trans "Pool path:" %}

+

{% trans "Pool status:" %}

+

{% trans "Size:" %} ({{ size|filesizeformat }} / {{ used|filesizeformat }})

+

{% trans "State:" %}

+

{% trans "Autostart:" %}

+
+
+

{{ pool }}

+

{% if not type %}{% trans "None" %}{% else %}{{ type }}{% endif %}

+

{% if not path %}{% trans "None" %}{% else %}{{ path }}{% endif %}

+

{% if not status %}{% trans "None" %}{% else %}{{ status }}{% endif %}

+

{% trans "Usage:" %} {{ percent }}%

+

+

{% csrf_token %} + {% ifequal state 0 %} + + + {% else %} + + {% endifequal %} +
+

+

+

{% csrf_token %} + {% ifequal autostart 0 %} + + {% else %} + + {% endifequal %} +
+

+
+
+
+
+ {% if state %} +
+
+
- + - {% include 'errors_block.html' %} - -
-
-

{% trans "Pool name:" %}

-

{% trans "Pool type:" %}

-

{% trans "Pool path:" %}

-

{% trans "Pool status:" %}

-

{% trans "Size:" %} ({{ size|filesizeformat }} / {{ used|filesizeformat }})

-

{% trans "State:" %}

-

{% trans "Autostart:" %}

-
-
-

{{ pool }}

-

{% if not type %}{% trans "None" %}{% else %}{{ type }}{% endif %}

-

{% if not path %}{% trans "None" %}{% else %}{{ path }}{% endif %}

-

{% if not status %}{% trans "None" %}{% else %}{{ status }}{% endif %}

-

{% trans "Usage:" %} {{ percent }}%

-

-

{% csrf_token %} - {% ifequal state 0 %} - - - {% else %} - - {% endifequal %} +
+ {% if volumes %} +
+ + + + + + + + + + + + + {% for volume in volumes %} + + + + + + + + + + {% endfor %} + +
#{% trans "Name" %}{% trans "Allocated" %}{% trans "Size" %}{% trans "Format" %}{% trans "Action" %}
{{ forloop.counter }}{{ volume.name }}{{ volume.allocation|filesizeformat }}{{ volume.size|filesizeformat }}{{ volume.type }} + + + {% ifnotequal volume.type "iso" %} + + {% else %} + + {% endifnotequal %} + +
{% csrf_token %} + +
-

-

-

{% csrf_token %} - {% ifequal autostart 0 %} - - {% else %} - - {% endifequal %} -
-

- - -
-
- {% if state %} -
-
- -
- - -
- {% if volumes %} -
- - - - - - - - - - - - {% for volume in volumes %} - - - - - - - - - {% endfor %} - -
#{% trans "Name" %}{% trans "Size" %}{% trans "Format" %}{% trans "Action" %}
{{ forloop.counter }}{{ volume.name }}{{ volume.size|filesizeformat }}{{ volume.type }} - - - {% ifnotequal volume.type "iso" %} - - {% else %} - - {% endifnotequal %} - -
{% csrf_token %} - - -
-
-
- {% else %} -
-
- - {% trans "Warning:" %} {% trans "Hypervisor doesn't have any Volumes" %} -
-
- {% endif %} - {% endif %} -
+
+
+ {% else %} +
+
+ + {% trans "Warning:" %} {% trans "Hypervisor doesn't have any Volumes" %}
+
+ {% endif %} + {% endif %} +
+
{% endblock %} {% block script %} - - + - + }); + $(document).on('change', '.image-format', function () { + if ($(this).val() == "qcow2") { + $('.meta-prealloc').show(); + } else { + $('.meta-prealloc').hide(); + } + }); + + {% endblock %} diff --git a/storages/views.py b/storages/views.py index d3f1965..f18cad6 100644 --- a/storages/views.py +++ b/storages/views.py @@ -7,7 +7,7 @@ from computes.models import Compute from storages.forms import AddStgPool, AddImage, CloneImage from vrtManager.storage import wvmStorage, wvmStorages from libvirt import libvirtError - +from django.contrib import messages @login_required def storages(request, compute_id): @@ -155,6 +155,7 @@ def storage(request, compute_id, pool): meta_prealloc = True try: conn.create_volume(data['name'], data['size'], data['format'], meta_prealloc) + messages.success("Image file {} is created successfully".format(data['name']+".img")) return HttpResponseRedirect(request.get_full_path()) except libvirtError as lib_err: error_messages.append(lib_err) @@ -166,6 +167,7 @@ def storage(request, compute_id, pool): try: vol = conn.get_volume(volname) vol.delete(0) + messages.success(request,_('Volume: {} is deleted.'.format(volname))) return HttpResponseRedirect(request.get_full_path()) except libvirtError as lib_err: error_messages.append(lib_err.message) @@ -175,6 +177,7 @@ def storage(request, compute_id, pool): error_messages.append(error_msg) else: handle_uploaded_file(path, request.FILES['file']) + messages.success(request, _('ISO: {} is uploaded.'.format(request.FILES['file']))) return HttpResponseRedirect(request.get_full_path()) if 'cln_volume' in request.POST: form = CloneImage(request.POST) @@ -194,6 +197,8 @@ def storage(request, compute_id, pool): format = None try: conn.clone_volume(data['image'], data['name'], format, meta_prealloc) + messages.success(request, _("{} image cloned as {} successfully".format(data['image'], + data['name'] + ".img"))) return HttpResponseRedirect(request.get_full_path()) except libvirtError as lib_err: error_messages.append(lib_err)