From c212a60bbab5f5978956ee79d93cc292bf6c6751 Mon Sep 17 00:00:00 2001 From: catborise Date: Mon, 28 Oct 2019 11:20:39 +0300 Subject: [PATCH] Delete instance disk: detach and delete. Notification added if detach completed but not deleted --- instances/views.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/instances/views.py b/instances/views.py index 0ef489f..1a1c5c0 100644 --- a/instances/views.py +++ b/instances/views.py @@ -576,10 +576,14 @@ def instance(request, compute_id, vname): path = request.POST.get('path', '') name = request.POST.get('name', '') - conn.detach_disk(dev) - conn_delete.del_volume(name) - msg = _('Delete disk: ' + dev) + conn.detach_disk(dev) + try: + conn_delete.del_volume(name) + except libvirtError as err: + msg = _('The disk: ' + dev + ' is detached but not deleted. ' + err.message) + messages.warning(request, msg) + addlogmsg(request.user.username, instance.name, msg) return HttpResponseRedirect(request.get_full_path() + '#disks')