From 57665c2ab97c9cd1fd78c62a23539e31797bd9cd Mon Sep 17 00:00:00 2001 From: catborise Date: Wed, 22 Jan 2020 14:48:48 +0300 Subject: [PATCH] add cdrom to instance errors fixed. make cdrom readonly, disable cache. --- instances/templates/instance.html | 12 +++++------- instances/views.py | 2 +- vrtManager/instance.py | 4 ++-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/instances/templates/instance.html b/instances/templates/instance.html index 4b9544c..c3cb9c6 100644 --- a/instances/templates/instance.html +++ b/instances/templates/instance.html @@ -767,15 +767,13 @@
{% csrf_token %}

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

{% for cd in media %} diff --git a/instances/views.py b/instances/views.py index 852d112..7c4753c 100644 --- a/instances/views.py +++ b/instances/views.py @@ -663,7 +663,7 @@ def instance(request, compute_id, vname): if 'add_cdrom' in request.POST and allow_admin_or_not_template: bus = request.POST.get('bus', 'ide' if machine == 'pc' else 'sata') target = get_new_disk_dev(media, disks, bus) - conn.attach_disk("", target, device='cdrom', cache='none', targetbus=bus) + conn.attach_disk("", target, disk_device='cdrom', cache_mode='none', target_bus=bus, readonly=True) msg = _('Add CD-ROM: ' + target) addlogmsg(request.user.username, instance.name, msg) return HttpResponseRedirect(request.get_full_path() + '#disks') diff --git a/vrtManager/instance.py b/vrtManager/instance.py index d577094..275363e 100644 --- a/vrtManager/instance.py +++ b/vrtManager/instance.py @@ -650,7 +650,7 @@ class wvmInstance(wvmConnect): cache_mode=None, io_mode=None, discard_mode=None, detect_zeroes_mode=None): additionals = '' - if cache_mode is not None and cache_mode != 'default': + if cache_mode is not None and cache_mode != 'default' and disk_device != 'cdrom': additionals += "cache='%s' " % cache_mode if io_mode is not None and io_mode != 'default': additionals += "io='%s' " % io_mode @@ -666,7 +666,7 @@ class wvmInstance(wvmConnect): xml_disk += "" % (driver_name, driver_type, additionals) xml_disk += """ """ % (source, target_dev, target_bus) - if readonly: + if readonly or disk_device == 'cdrom': xml_disk += """""" if shareable: xml_disk += """"""