From a7e0e490077d81232e1b5211904d7fc449493447 Mon Sep 17 00:00:00 2001 From: catborise Date: Mon, 28 Jan 2019 16:38:15 +0300 Subject: [PATCH] Make visible add cdrom/media space/button even if instance is running. Check media and disk for cdrom target dev --- instances/templates/instance.html | 62 ++++++++++++++++--------------- instances/views.py | 10 ++--- 2 files changed, 37 insertions(+), 35 deletions(-) diff --git a/instances/templates/instance.html b/instances/templates/instance.html index de572df..3ba2a59 100644 --- a/instances/templates/instance.html +++ b/instances/templates/instance.html @@ -475,11 +475,9 @@
- - - - - + + + {% for snap in snapshots %} @@ -605,25 +603,25 @@

{% trans 'Boot Order' %}

- {% csrf_token %} -
-
- {% ifequal status 5 %} -

{% trans "Enable Boot Menu for your instance when it starts up " %} - {% ifequal bootmenu 0 %} - + {% csrf_token %} +

+
+ {% ifequal status 5 %} +

{% trans "Enable Boot Menu for your instance when it starts up " %} + {% ifequal bootmenu 0 %} + + {% else %} + + {% endifequal %} {% else %} - + {% ifequal bootmenu 0 %} +

{% trans "**** Please shutdown instance to modify boot menu ****" %}

+ {% endifequal %} {% endifequal %} - {% else %} - {% ifequal bootmenu 0 %} -

{% trans "**** Please shutdown instance to modify boot menu ****" %} - {% endifequal %} - {% endifequal %} -

+
-
- + +

{% ifequal bootmenu 1 %}
@@ -665,16 +663,20 @@
- {% if status == 5 %} -
{% csrf_token %} -

- {% trans "Instance Media" %} - -

- +
{% csrf_token %} +

+ {% trans "Instance Media" %} + {% if status == 5 %} + + {% else %} + {% endif %} +

+ {% for cd in media %}
{% csrf_token %}
diff --git a/instances/views.py b/instances/views.py index 36b7327..a7f9e72 100644 --- a/instances/views.py +++ b/instances/views.py @@ -194,7 +194,7 @@ def instance(request, compute_id, vname): msg += " (%s > %s)" % (disk_size, ua.max_disk_size) return msg - def get_new_disk_dev(disks, bus): + def get_new_disk_dev(media, disks, bus): if bus == "virtio": dev_base = "vd" elif bus == "ide": @@ -465,7 +465,7 @@ def instance(request, compute_id, vname): meta_prealloc = request.POST.get('meta_prealloc', False) bus = request.POST.get('bus', default_bus) cache = request.POST.get('cache', default_cache) - target = get_new_disk_dev(disks, bus) + target = get_new_disk_dev(None, disks, bus) path = connCreate.create_volume(storage, name, size, format, meta_prealloc, default_owner) conn.attach_disk(path, target, subdriver=format, cache=cache, targetbus=bus) @@ -487,7 +487,7 @@ def instance(request, compute_id, vname): format = connCreate.get_volume_type(name) path = connCreate.get_target_path() - target = get_new_disk_dev(disks, bus) + target = get_new_disk_dev(None, disks, bus) source = path + "/" + name; conn.attach_disk(source, target, subdriver=format, cache=cache, targetbus=bus) @@ -523,9 +523,9 @@ def instance(request, compute_id, vname): if 'add_cdrom' in request.POST and allow_admin_or_not_template: bus = request.POST.get('bus', 'ide') - target = get_new_disk_dev(media, bus) + target = get_new_disk_dev(media, disks, bus) conn.attach_disk("", target, device='cdrom', cache='none', targetbus=bus) - msg = _('Add CD-Rom: ' + target) + msg = _('Add CD-ROM: ' + target) addlogmsg(request.user.username, instance.name, msg) return HttpResponseRedirect(request.get_full_path() + '#disks')
{% trans "Name" %}{% trans "Date" %}{% trans "Action" %}
{% trans "Name" %}{% trans "Date" %}{% trans "Action" %}